プレイ日記
*J.P.* DEV NEWPICY3
help needed! here is a code that will fire an arrow (which is a shovel lol), i am trying to make it shoot like bullets, but shoot multiple bullets at the same time, i tried using a for loop but it dident work, so anyone who can help me do this would be greatly appreciated! so what it will do is once the bullet goes off screen it resets to the middle, this is already done though.
2そうだね
プレイ済み
返信[1]
親投稿
*J.P.* DEV NEWPICY3
actually i just had an idea! would it be smarter to just speed up the bullet to make it look like many bullets, instead of just making more of them?
0そうだね
プレイ済み
返信[2]
親投稿
Jacob KulcakKid4
Maybe a repeat loop would do it? Like: REPEAT SHOT ( the SHOT code would INC a variable(a) UNTIL A=10(or however many shots you want it to be.
1そうだね
プレイ済み
返信[3]
親投稿
*J.P.* DEV NEWPICY3
well i think that would make it impossible to move or aim in other directions while firing lol. though usually i find problems using REPEAT.. when i try to use it lol. thats one command i need to really work on using.. ill see if i can figure a way to do it using that though, good idea!
1そうだね
プレイ済み
返信[4]
親投稿
Aaron Krondelo
No, that or any for loop will likely not work, or everything else will pause when shooting. Just spawn 3 (or how ever many) each shot, with a variable for each arrow. You shouldt alter the trajectory on the other two so they spread out a bit.
1そうだね
プレイ済み
返信[5]
親投稿
Stewart segludian1
You want something like the attached picture, right? What you need to do is create and update a sprite for each projectile. One way to do that would be to make a bunch of arrays, put all the data for each sprite into the arrays then update them a little at a time in the main game loop. Another way to do it is to use SPVAR to store the data, then have a SPFUNC and CALL SPRITE update it each frame.
0そうだね
プレイ済み
返信[6]
親投稿
Stewart segludian1
Code part 1. Here we allocate variables call a function to create the player sprite, and enter the main game loop. I do have a few extras in there to give us time based movement so things run the same on old vs new 3ds. Although that really shouldn't be a problem for this example. CALL SPRITE calls all the registered sprite functions.
0そうだね
プレイ済み
返信[7]
親投稿
Stewart segludian1
Next up is the create hero function (the rotating knight). He has one spvar at index 0 to keep track of how many milliseconds remaining to wait before he can fire off a shovel again. Note the SPFUNC call that says what to call to update him each frame.
0そうだね
プレイ済み
返信[8]
親投稿
Stewart segludian1
Now we need Create_Shovel to make a shovel projectile for us. I have SPVAR for x, y, heading, and speed. X, and Y may be redundant but I don't think SPOFS keeps track of position with floating point precision and I don't want cumulative error. Note it too registers a callback to update the shovel.
0そうだね
プレイ済み
返信[9]
親投稿
Stewart segludian1
Forgot the picture :(
0そうだね
プレイ済み
返信[10]
親投稿
Stewart segludian1
The penultimate funtion updates the hero. Note the use of the cooldown timer so we don't fire too fast. This is called when Call Sprite is called in the main game loop. CALLIDX has your sprite id. The max thing is just so I don't have negative cooldown which may not matter unless you leave the game idle for hours and the counter wraps around. We create new shovels to throw here.
0そうだね
プレイ済み
返信[11]
親投稿
Stewart segludian1
Lastly we have update shovel. Note how we have to resave any spvar values we modify at the end. If the sprite goes offscreen it deletes itself. The Step variable is there to keep line length shorter and not calculate that value twice. This function is called for each shovel every frame. Hope this all makes sense let me know if you have questions.
0そうだね
プレイ済み
返信[12]
親投稿
*J.P.* DEV NEWPICY3
its shovel knight! anyways yeah i think i got it.. ill write it all down and do some testing, thank you btw! so i would be able to set custom cooldowns for different weapons, like pistol takes longer but mk47 would be really fast, right? (forgot what you called it) but the weapon equiped would set a bunch of things like range, speed and damage. range would set the boundarys farther and zoom
0そうだね
プレイ済み
返信[13]
親投稿
*J.P.* DEV NEWPICY3
out on the map, or for like a shotgun it will be a small box of the range but powerful. anyways..
0そうだね
プレイ済み
返信[14]
親投稿
Stewart segludian1
That sounds reasonable you would just have to pass more variables around or make different update functions for each type of projectile.
0そうだね
プレイ済み
返信[15]
親投稿
*J.P.* DEV NEWPICY3
yep, ok so were going somewhere today so ill probably copy it down tonight.. but ill start right now lol.
0そうだね
プレイ済み
返信[16]
親投稿
*J.P.* DEV NEWPICY3
oh my.. why do I always forget to do things with code you give me.. oog.. anyways NOW I WILL WRITE IT DOWN!
1そうだね
プレイ済み
返信[17]
親投稿
Jacob KulcakKid4
Hey Stewart, could I have the key for that? I'm going to work it into some code.
0そうだね
プレイ済み
返信[18]
親投稿
*J.P.* DEV NEWPICY3
^
1そうだね
プレイ済み
返信[19]
親投稿
Jacob KulcakKid4
Thanks
0そうだね
プレイ済み
返信[20]
親投稿
Stewart segludian1
SECXE2KE Have fun, and be sure to get it before I need space for new keys.
1そうだね
プレイ済み
返信[21]
親投稿
*J.P.* DEV NEWPICY3
^ok thanks^
0そうだね
プレイ済み
返信[22]
親投稿
Jacob KulcakKid4
Thanks.... also..
1そうだね
プレイ済み