Discussions

SmileBASIC Community

ClaytonDarkClay88

10/11/2016 8:03 PM ·Spoilers

Open Closed

Duplicate Sprites

Is there any way you can duplicate one sprite with different attributes without making a bunch of SPSETS?

Advertisement

Comment

This post has no comments.

  • You would probably have to create a new space, since adding an attribute in the same space would give everyone of that enemy the attributes. So, yea. You're gonna create more space.

    Yeahs0
  • There isn't one. However you can make a function to do that with DEF. Here is an example: 1|DEF clone(I) 2| VAR DN=SPCHR(I) 3| VAR X,Y,W,H 4| VAR SP 5| SPOFS I OUT X,Y 6| SPSCALE I OUT W,H 7| 8| SP=SPSET(DN) 9| SPOFS SP,X,Y 10| SPSCALE SP,W,H 11| RETURN SP 12|END

    Yeahs1
    Played
  • Here is an example to use that: VAR SP1,SP2,SP3 SP1=SPSET(6) SPSCALE SP1,4,4 SP2=clone(SP1) SPOFS SP2 100,100 SP3=clone(SP1) SPOFS SP3 200,100

    Yeahs1
    Played
  • Ooooh okay, I gotcha.

    Yeahs0
    Played
  • raimondz, I need your assistance again. xP I'm having trouble with collision in one of my newer games. I was wondering if you could help me out with it? x)

    Yeahs0
    Played
  • I suppose the problem is the collision with walls. I can't explain you right now how it works but I posted a code to handle that case on smilebasicsource. On the search bar type "wall collision" and click on the first result.

    Yeahs0
    Played
  • Actually it's sprite collision. SPHITSP to be exact. I have this invisible sprite box that pops out when you press B (but for some reason, if you press any button it will pop out). The box is suppose to hit other sprites but it is not working. I did SPCOL and everything.

    Yeahs0
    Played
  • You must call spcol on every sprite that can collide. SPCOL sprite,[Scale adjustment],[MASK] Sprite is the number associated with your sprite. Scale adjustment should be set as true. Mask is a binary variable that let you put category for collision.

    Yeahs0
    Played
  • For example, you could have bullets that will collide with the player but not with the enemy, and viceversa. So you can use 2 categories: 1(&B01) = Player bullet var PLAYER_BULLET=&B01 2(&B10) = Enemy bullet. var ENEMY_BULLET=&B10 SPCOL SPEBullet,1,ENEMY_BULLET If you want a bullet that collide with both the player and the enemy, then: SPCOL SPEBullet,1,ENEMY_BULLET OR PLAYER_BULLET

    Yeahs0
    Played
  • If you don't put value in mask, then the sprite could collide with everything. ========================== Now SPHITSP let you find the first sprite that is overlapping the one in the argument. This mean if two sprites overlap one in a frame, then the function will return the one with the lowest managment number.

    Yeahs0
    Played
  • Almost forgot something about SPCOL: the collider will be a rectangle of the same size as the original sprite. However, you can define a bigger hitbox with SPCOL(See page 3 on the help screen of SPCOL)

    Yeahs0
    Played
  • I'm hitting the hitbox sprite with the tree sprite(s) but it's not doing what they computer is telling it to do. :0

    Yeahs0
    Played
  • Its really odd.

    Yeahs0
    Played
  • That's strange. Can you post a key of your program? maybe I can do something.

    Yeahs0
    Played
  • Ok! I will tonight.

    Yeahs0
    Played
  • Key: LSDQE3A4

    Yeahs0
    Played
  • Well, I found a lot of issues: -From here, if you're creating the same kind of entity(Tree in this case), then use an array to store them and their properties. -You don't need to do SPOFS in the loop if the tree aren't moving. Remember that the camera do that stuff for you. -SPHIT only work if the Sprite is visible. When you're using SPHITSP, the hitbox is already hidden.

    Yeahs0
    Played
  • -If you have plans to add enemies or active entities in the future, then you shouldn't use WAIT to handle the punch. That will pause the entire game. I will upload the code later.

    Yeahs0
    Played
  • KEY: XRE3C2QV V1.0 and V1.0B are almost the same code. However V1.0B use wait to handle the hitbox but the other use a timer instead.

    Yeahs0
    Played
  • Oh wow. I'm dumb. Should've known using wait paused the whole thing. :P

    Yeahs0
    Played

Add a Comment

You must sign in to post a comment.

Sign in using a Nintendo Network ID to connect to users around the world by writing posts and comments and by giving Yeahs to other people's posts. You can create a Nintendo Network ID using your Wii U console or your system in the Nintendo 3DS family.

Use of Miiverse Details about Miiverse

Report Violation to Miiverse Administrators

You are about to report a post with content which violates the Miiverse Code of Conduct. This report will be sent to Nintendo's Miiverse administrators and not to the creator of the post.

Violation Type:

Post ID: 3DB-NBL7-EJ9-9E2H-ZDJ-MWJ3

Report Violation to Miiverse Administrators

You cannot report posts made automatically by a software title.

Edit Post

Select an action: