Discussions

SmileBASIC Community

ClaytonDarkClay88

10/07/2016 12:37 AM ·Spoilers

Open Closed

Need help with two things.

1. How do I move with the circle pad? 2. How do I make my background move when my character moves and stop when it reaches the end.

Advertisement

Comment

This post has no comments.

  • How would I move the sprite with the circle pad and still animate it?

    Yeahs0
    Played
  • have a few if statements that check what direction the sprite is going. 'X/Y=SP X, Y OLDX=X OLDY=Y 'PUT THE SPRITE MOVEING CODE HERE IF OLDX>X THEN 'finds out if the sprite has moved left. Put animation code here You can have multiple IF statements to check what direction the sprite is going in: OLDX>X' left OLDX<X' right OLDY>Y' up OLDY<Y' down

    Yeahs1
    Played
  • You need the following things to make a camera: -Variables to store the position of the camera. -A invisible sprite(Call this the camera sprite) with management number=0 -The speed of the camera. -SPLINK all the sprites you create with the camera sprite Then you need to declare the functions:

    Yeahs1
    Played
  • VAR cameraX%=0,cameraY%=0,cameraVX%=0,cameraVY%=0 VAR cameraBG[0] DEF moveCamera VX%,VY% cameraVX%=VX% cameraVY%=VY% END

    Yeahs1
    Played
  • DEF renderCamera VAR I INC cameraX%,cameraVX% INC cameraY%,cameraVY% SPOFS 0,-cameraX%,-cameraY% FOR I=0 TO LEN(cameraBG)-1 BGOFS cameraBG[I],cameraX%,cameraY% NEXT cameraVX%=0 cameraVY%=0 END

    Yeahs1
    Played
  • Also: -You need to put renderCamera in the part where your code render the changes of the game. -To move background, you need to push the layer on cameraBG Then just call moveCamera somewhere in your code(Try in the one that control the player) to test it.

    Yeahs1
    Played
  • There's apparently an error on line 20. This is a little too big for me to comprehend, can I have more examples so I can understand it a bit more? :)

    Yeahs0
    Played
  • The problem in your code is that the argument of BGOFS are on line 20. Put BGOFS cameraBG[I],cameraX%,cameraY% in the same line. I use this code on a map editor for my tactic rpg game. It's still a work in progress but it is too complex to use it as an example. If you have a code where you want to add the camera, then I can try to add it for you. If not, then I could share my project.

    Yeahs1
    Played
  • I'm trying to make a 2D sidescrolling shooter. I used BGOFS to move the camera around the map. The problem I'm having is the enemies. It's hard to make AI's with BGOFS. It's pretty hard to explain, I would probably have to show you. My question is, will your method help make AI's?

    Yeahs0
    Played
  • Would you like the key to the program to see what I mean? xP

    Yeahs0
    Played
  • Ok, I could try to see what is the problem.

    Yeahs0
    Played
  • The key is: BEENW384 The mummy is suppose to go after the human, but it seems that BGOFS kinda defeats that purpose.

    Yeahs0
    Played
  • Here is your code. S223C38E. I put the camera and solved some issues with the AI. I changed a lot of things and left some commentaries on your code. Important things: -Always store your sprites on variables. Right now, the amount of sprites is low, but if you have to do this if you want to handle more enemies on screen. -Use a speed variable instead of hard coding movement.

    Yeahs2
    Played
  • Now the problems in your code: -The mummy was following X=0. The player is on the center of the screen so I changed it to X+200. -Try to not use goto. I know that in the examples they use that but it make the code confusing and hard to read. Only use it inside a function(Becuase the goto can only jump to a line inside of it). -Declare the variables that you're going to use(Use VAR or DIM)

    Yeahs2
    Played
  • Few more questions, 1. What does SPLINK do in this program? 2. How does adding sprite variables make it better? 3. What does FORMAT$ do? Anyways, Thank you so much! I'm definitely going to include you in the credits. I really don't know how to repay you. xD

    Yeahs1
    Played
  • 1-SPLINK link a sprite(Child) with another(Parent). This mean that the sprite position is relative to the parent. For example, you can make a Boat (Parent) and a person on it (Child). If the boat moves, then the person will move along with it. The person can move inside it too but he will still move with the boat.

    Yeahs0
    Played
  • 2- For now your code is simple: you have one player and one enemy. But if you start to add more enemies, then you'll have problems to do the AI if you handle them without variables. You can use arrays to store all the enemies and iterate the values of it to do things, for example validations to know where is the player and then move all the enemies.

    Yeahs0
    Played
  • Variables also tell you what you're using in functions. For example, if you read "SPOFS 1,X,Y" in your code, then you won't know what is '1'. But if you read "SPOFS SPPlayer,X,Y", then you will know that the player is moving to the position (X,Y)

    Yeahs0
    Played
  • 3- FORMAT let you insert variables in a string and define properties to it. For example '%d' is used to put an integer into the string, "%05d" let you put a integer that will use 5 characters(The unused characters will be '0'). In the code, "%- 5d" let you put an integer that will use 5 characters(The unused characters will be ' ') and aligned to the left.

    Yeahs0
    Played
  • So if I wanted more enemies, would I have to make another Variable called like SPMUM2?

    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-J9J-9CJF

Report Violation to Miiverse Administrators

You cannot report posts made automatically by a software title.

Edit Post

Select an action: