Computer Science Canada Need help with my Tank Game |
Author: | Dragoon [ Fri May 23, 2003 2:03 pm ] | ||
Post subject: | Need help with my Tank Game | ||
I having trouble trying to get my tank to move while shooting.
|
Author: | Asok [ Fri May 23, 2003 3:23 pm ] |
Post subject: | |
rule of thumb. ALWAYS upload your external bitmaps. just zip them up and attach them so we can actually run this. |
Author: | Tony [ Fri May 23, 2003 4:25 pm ] |
Post subject: | |
if might help if you'd use Input.KeyDown instead... read tutorial... everybody who knows how to use that recomments it over getch... now, you should make a separate procedure for the bullet that will move it along its trajectory. Then set a flag variable in the main loop so that the procedure keeps on getting called to move the bullet while its on screen. This way it moves bullet 1 spot, then returns to tank controls to allow you to move it as well.. are you with me so far? |
Author: | Dragoon [ Fri May 23, 2003 4:51 pm ] |
Post subject: | |
How would i use Input.KeyRight in my code? Can you give me an example please. |
Author: | Dragoon [ Fri May 23, 2003 6:03 pm ] |
Post subject: | |
Okay , i got everything to work except for the Bullet, i made a procedure and now how do i have it so the bullet moves while the tank moves too? |
Author: | Tony [ Fri May 23, 2003 7:17 pm ] |
Post subject: | |
structure it like this: procedure moveBullet bulletX += movementX bulletY += movementY %maye some other stuff like check if it hit something or what not %reset bulletFlag back to flase once bullet is done moving end moveBullet %main loop loop input.ketdown stuff if chars('f') then %or whatever button you want to fire with bulletFlag = true end if if bulletFlag then moveBullet end if move tank here end loop /\Something like that above |
Author: | Dragoon [ Sat May 24, 2003 6:52 am ] |
Post subject: | |
Below is the code i have right now. |
Author: | Dragoon [ Sat May 24, 2003 7:28 am ] | ||
Post subject: | |||
Okay, iam having trouble understanding what you just put, what do i have to do with the bullety and x stuff in the procedure? Also do i have my Draw Bullet in the right spot?
|
Author: | Tony [ Sat May 24, 2003 1:10 pm ] | ||
Post subject: | |||
your procedure should look like this:
so the flag is set to false, only when the bullet goes over the top of the screen. I think your movement variables should be procedure parameters, because otherwise if you turn your tank around, the bullet will turn too. |
Author: | Dragoon [ Sat May 24, 2003 3:16 pm ] |
Post subject: | |
Do i have to declare the BulletX, BulletY, MovementX, MovementY anything? |
Author: | Tony [ Sat May 24, 2003 4:36 pm ] |
Post subject: | |
yes |
Author: | Dragoon [ Sat May 24, 2003 4:47 pm ] |
Post subject: | |
What would i delcare them? Sorry for asking too many questions. |
Author: | Tony [ Sat May 24, 2003 4:56 pm ] |
Post subject: | |
bulletX/Y is a location of the bullet movementX/Y is vector components of bullet's trajectory. You add them to bulletX/Y to move it. tankX/Y is location of your tank. When bullet if first fired, bulletX/Y = tankX/Y... tankMovementX/Y also vector components, store tank movement direction. When bullet is first fired, movementX/Y = tankMovementX/Y you can declear them as integers, but if you want more accurate numbers, use real instead and just round for drawing. |
Author: | Dragoon [ Sat May 24, 2003 5:13 pm ] | ||
Post subject: | |||
Okay, i understand it now, but whenever i start my program the bullet fires. This is what i have.
|
Author: | Tony [ Sat May 24, 2003 8:03 pm ] |
Post subject: | |
thats cuz you initialize your bulletFlag variable to true when you declear it. Make it false instead. |
Author: | Dragoon [ Sun May 25, 2003 6:51 am ] |
Post subject: | |
Okay, thank you. |
Author: | Dragoon [ Sun May 25, 2003 7:21 am ] |
Post subject: | |
I have one more question. How do i get my bullet to start where my tank is? Because each time i fire it fires where my tank started which is in the middle. |
Author: | Tony [ Sun May 25, 2003 11:05 am ] |
Post subject: | |
bulletX = tank's Curren Position X bulletY = tank's Curren Position Y but you do that only when the bullet is just fired |
Author: | Dragoon [ Sun May 25, 2003 11:22 am ] | ||
Post subject: | |||
Do i have to do bulletX += TankX and bulletY += TankY? And i tried putting it under my Pic.Draw Bullet but nothing worked.
|
Author: | Tony [ Sun May 25, 2003 11:24 am ] | ||
Post subject: | |||
no...
|