It is currently Thu Jul 02, 2020 8:18 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject:
PostPosted: Mon Aug 05, 2002 10:16 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by Tron.

Do any of you game programmers have some example code for bullet tracking? I am working on a space invaders type of game, but I can only shoot and track one bullet/keypress on the screen at a time. I know it's a strange request, but here is an example of my code:

#NUM_SHOTS = 6

Structure Shot
x.l
y.l
frame.l[1]
currframe.l
xspeed.l
yspeed.l
direction.l
visible.l
EndStructure

Dim Ship.Shot(#NUM_SHOTS)

Declare Shot_Init()
Declare Game_Run()
Declare Move_Ship(key)
Declare Display_Ship()
Declare Display_Shots()

Procedure Shot_Init()
for count = 1 to #NUM_SHOTS
Ship.Shot(count)\xspeed = 10
Ship.Shot(count)\yspeed = 10
Ship.Shot(count)\visible = 0
EndProcedure

Procedure Game_Run()
While quitgame = 0
Start_Clock() ;custom function that uses the API - you can remove
FlipBuffers()
ClearScreen(0,0,0)
DisplaySprite(background, 0, 0) ;just a backgroup bmp image
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape)
quitgame = 1
Delay(200)
EndIf
If KeyboardPushed(#PB_Key_Left):KEYPRESS=1:EndIf
If KeyboardPushed(#PB_Key_Right):KEYPRESS=2:EndIf
If KeyboardPushed(#PB_Key_Up):KEYPRESS=3:EndIf
If KeyboardPushed(#PB_Key_Down):KEYPRESS=4:EndIf
If KeyboardPushed(#PB_Key_LeftControl):KEYPRESS=5:EndIf
Move_Ship(KEYPRESS) ;sets a FIRING variable = 1 if the leftctrl pushed
Display_Ship() ;displays my ship on the screen
Display_Shots() ;displays my shots on the screen if FIRING = 1
Wait_Clock(33) ;you can remove
Wend
EndProcedure

;Main
Shot_Init()
Game_Run()

Let me know if you need more code or information. I just need to get an idea of what's the best method for getting the input, tracking the shots and then displaying the array of shots. Some of you may have already written Purebasic code that tracks shots on the screen, so I wanted to pick your brains.

Thanks,
Tron

"Honesty is the best policy, but insanity is a much better defense."


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Aug 05, 2002 10:52 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by Pupil.

One little question -have you checked out the source code of 'Waponez II" on the PureBasic site(download section)? I believe you can find almost all the answers in that source code to the questions you ask in your post.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Aug 06, 2002 9:57 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by Tron.

Quote:
One little question -have you checked out the source code of 'Waponez II" on the PureBasic site(download section)? I believe you can find almost all the answers in that source code to the questions you ask in your post.


Doh!!! I should have looked there first! I knew there was some code around here somewhere. Thanks for putting my head back on straight.

Thanks again Pupil!

"Honesty is the best policy, but insanity is a much better defense."


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Aug 07, 2002 4:52 am 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by Paul.

You could check out my cheezy Space Invaders clone on the Resources Site (under Apps). It comes with Source and Graphics and compiles into a single executable.

http://www.reelmediaproductions.com/pb


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye