This site requires JavaScript, please enable it in your browser!
Greenfoot back
NightRaven
NightRaven wrote ...

2017/6/12

How do i make a shooter code?

NightRaven NightRaven

2017/6/12

#
I want to create a shooter code that when the space bar is pressed it will fire a bullet but I don't know where to start...
danpost danpost

2017/6/12

#
NightRaven wrote...
I want to create a shooter code that when the space bar is pressed it will fire a bullet but I don't know where to start...
Start by creating a subclass of Actor that will create the bullets (a Bullet class). The only thing a bullet does is move and disappears at an edge. It also has a speed state and a direction state that regulate its movement. Then you can work on having the shooter fire (create and direct) the bullets using a change in state of the space bar. I order to detect a change in the key's state, you will need to save the last state of the key to compare to the current state.
You need to login to post a reply.