Hello folks, I m on the start of my new game, is based on a tower defense game with a twist of shooter game, my idea is the player can rotate a turret and the turret fires like a machine gun, I read some code from another languages but I m running out of ideas how to make that on Gideros, I know I need to do with an array, but the creation and update of the bullets is a hard thing for me at the moment, do someone have an example? please :o3 thanks!
Comments
you need a place (the bullets array) to store references to the bullets on screen, so that you can interact again with each bullet (for example just to get them back into a pool, or to make them moving, depending on your code) then:
Likes: yaxxar
I've got a turret in my game. I have a turret class and a bullet class.
I'd better attach the files as the code is a bit long to post here...
My turret might have stuff you don't need but I'm sure you'll see how it works. (I'm really basic at programming!) It rotates, sleeps a bit, then starts up again. But the bullets being fired out will be the same for any kind of turret game. (Trig etc...)
It's in level 7 of my game if you want to see it in action. Although you'll have to play the 6 stages before to see it lol sorry
Good luck and ask if there's anything I can do to help!
Likes: yaxxar
1) you need to put a limit in enterframe, otherwise in 1 second you shoot 60 bullets you can use frameCount or a counter you set up.
2) when you create the bullet, I think it's better if you give it a name already, you risk that bulletIndex is updated before createBullet could get it.
Likes: yaxxar
I had a look at your project file and played around with the code. I've attached the edited version to this post.
I think what you're trying to do is create a 'pool' of bullets, which are used over and over to avoid creating and removing lots of bullets?
If I were you, I'd just let your game create the bullets and remove them when they leave the 'edge' of the screen, or hit a target etc.
Hope this helps and good luck!
Likes: yaxxar