プレイ日記
nate NJR1432
How would you make a working gun?
2そうだね
プレイ済み
返信[1]
親投稿
duckymomo fluffyofqweam
_________________ l I dont know... l l________________l ._./
1そうだね
プレイ済み
返信[2]
親投稿
SıмΞоп SimeonW
You need an array for the bullet: » x position » y position » x velocity » y velocity » counter since bullet was fired it would look something like this: DIM BPX[0],BPY[0],BVX[0],BVY[0] Then to shoot shoot a bullet: PUSH BPX,gunXPosition PUSH BPY,gunYPosition PUSH BVX,SIN(gunAngle*PI()/180)*SPEED PUSH BVY,COS(gunAngle*PI()/180)*SPEED
1そうだね
プレイ済み
返信[3]
親投稿
PChicken NerdChicken
make a bullet sprite go to the gun when shot, and then make the bullet go forward until it collides with something or goes a certain distance. Use spcol, spcolvec, sphitsp, spofs, spshow, sphide, and a few variables to do these things. its simple and complicated.
2そうだね
プレイ済み
返信[4]
親投稿
SıмΞоп SimeonW
Here, I added a machine gun to the spaceship in this key The code shows you exactly how to make a gun Key: [ RAPXEQD ]
2そうだね
プレイ済み
返信[5]
親投稿
nate NJR1432
Thanks! I need actaully needed a machine gun for my game! :D
0そうだね
プレイ済み
返信[6]
親投稿
nate NJR1432
Simon how would i turn a gun to the left or right when the sprite moves?
0そうだね
プレイ済み
返信[7]
親投稿
SıмΞоп SimeonW
Well thats when you need to use sine and cosine to convert an angle in degrees to a x velocity and y velocity It takes a bit of math unfortunately So lets say the sprites rotation is stored in VAR ROT rotate the sprite to that angle with SPROT SPRITEID,ROT get the x and y velocities of the bullet with XVEL=-10*SIN(-ROT*PI()/180) YVEL=-10*COS(-ROT*PI()/180) [you might need to tweak]
1そうだね
プレイ済み
返信[8]
親投稿
SıмΞоп SimeonW
then you'd move the bullet like so: X=X+XVEL Y=Y+YVEL SPOFS BULLETID,X,Y Keep in mind these variables should be arrays if you want more than one bullet on the screen at once
1そうだね
プレイ済み
返信[9]
親投稿
nate NJR1432
Could you show me the code? I dont understand, sorry :[
1そうだね
プレイ済み
返信[10]
親投稿
SıмΞоп SimeonW
It all fit on one screen
1そうだね
プレイ済み
返信[11]
親投稿
nate NJR1432
Thanks a ton! :D
0そうだね
プレイ済み