トピック
Clayton DarkClay88

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.
3そうだね
プレイ済み
返信[1]
親投稿
Oscar PwnageBlock
1. Use the STICK instruction. It follows this syntax... STICK OUT SX,SY ...where SX and SY are values that range between -1 and 1, which represent the stick's position relative to it's default position. (Note that the actual values will be closer to ±0.86) This values are updated as soon as you call STICK OUT again, so it is recommended to call it within a loop.
2そうだね
プレイ済み
返信[2]
親投稿
Oscar PwnageBlock
I suggest running this simple program to observe the instruction's behavior... WHILE TRUE STICK OUT SX,SY ?"SX:";SX:?"SY:";SY GCIRCLE 200,120,50 GCIRCLE 200+SX*50,120-SY*50,5,#RED WAIT 1 CLS:GCLS WEND Also, if you have a New 3DS or a Circle Pad Pro you can also use STICKEX in the exact same way to receive stick information from the C-Stick.
2そうだね
プレイ済み
返信[3]
親投稿
Oscar PwnageBlock
With this information you can easily offset something's position by incrementing its coordinates using STICK's values, like this... 'X AND Y = COORDINATES OF SMTH TO MOVE STICK OUT SX,SY INC X,SX*2 'MULTIPLY TO "CHANGE MOVE SPEED" DEC Y,SY*2 'DEC Y SINCE SY IS NEGATIVE RELATIVE TO GRAPHIC SCREEN 2. I can't really give you much help with this one right now, sorry. Use BGOFS, maybe?
1そうだね
プレイ済み
返信[4]
親投稿
Clayton DarkClay88
How would I move the sprite with the circle pad and still animate it?
0そうだね
プレイ済み
返信[5]
親投稿
C. Norris 06495a
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
1そうだね
プレイ済み
返信[6]
親投稿
raimondz raimondxz
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:
1そうだね
プレイ済み
返信[7]
親投稿
raimondz raimondxz
VAR cameraX%=0,cameraY%=0,cameraVX%=0,cameraVY%=0 VAR cameraBG[0] DEF moveCamera VX%,VY% cameraVX%=VX% cameraVY%=VY% END
1そうだね
プレイ済み
返信[8]
親投稿
raimondz raimondxz
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
1そうだね
プレイ済み
返信[9]
親投稿
raimondz raimondxz
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.
1そうだね
プレイ済み
返信[10]
親投稿
Clayton DarkClay88
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? :)
0そうだね
プレイ済み
返信[11]
親投稿
raimondz raimondxz
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.
1そうだね
プレイ済み
返信[12]
親投稿
Clayton DarkClay88
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?
0そうだね
プレイ済み
返信[13]
親投稿
Clayton DarkClay88
Would you like the key to the program to see what I mean? xP
0そうだね
プレイ済み
返信[14]
親投稿
raimondz raimondxz
Ok, I could try to see what is the problem.
0そうだね
プレイ済み
返信[15]
親投稿
Clayton DarkClay88
The key is: BEENW384 The mummy is suppose to go after the human, but it seems that BGOFS kinda defeats that purpose.
0そうだね
プレイ済み
返信[16]
親投稿
raimondz raimondxz
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.
2そうだね
プレイ済み
返信[17]
親投稿
raimondz raimondxz
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)
2そうだね
プレイ済み
返信[18]
親投稿
Clayton DarkClay88
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
1そうだね
プレイ済み
返信[19]
親投稿
raimondz raimondxz
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.
0そうだね
プレイ済み
返信[20]
親投稿
raimondz raimondxz
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.
0そうだね
プレイ済み
返信[21]
親投稿
raimondz raimondxz
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)
0そうだね
プレイ済み
返信[22]
親投稿
raimondz raimondxz
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.
0そうだね
プレイ済み
返信[23]
親投稿
Clayton DarkClay88
So if I wanted more enemies, would I have to make another Variable called like SPMUM2?
0そうだね
プレイ済み