Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / simple bullet example

Author
Message
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 14th Mar 2015 12:15
Hi

I want when Pressed Space key my sprite can fire bullet and destroy it when is out of screen but i don't know how can make it.please if possible, give me an simple example.

Thanks.
george++
AGK Tool Maker
16
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 14th Mar 2015 18:37
You have already an example. Just take a look at the official samples
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 14th Mar 2015 19:02
In addition to george++'s excellent suggestion you can also have a look at this

Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 16th Mar 2015 11:48
Quote: "You have already an example. Just take a look at the official samples.
"


your mean is fire exmple in AppGameKit? if yes, my gun should fire more that one sprite.maybe I can create a gun that can fire several bullet but I want learn correct way.

Quote: "In addition to george++'s excellent suggestion you can also have a look at this
"


thanks, but if I see simple code it's very better for understand.
Jaeg
18
Years of Service
User Offline
Joined: 16th Mar 2006
Location: Indiana
Posted: 16th Mar 2015 23:48
An easy way to do it is to have an array of bullets. As long as you have space in the array create a new bullet. When a bullet is destroyed or off the screen remove it from the array or mark it as destroyed so you can reuse it.

Then in the game loop cycle through the array of bullets to update their position based on their velocities and to do any collision checking on them.

Go ahead. Walk into Mordor.

Ball State University - Computer Science Major
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 17th Mar 2015 11:53
Also, add a timer element so the player cannot shoot until 0.x seconds have passed since the last shot. This will prevent all your bullets flying at the same time, and allow for power-ups (i.e. increase fire rate).

V2 T1 (Mostly)
Uzmadesign
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 31st Mar 2015 10:40
I created a simple bullet system.
but I want this way is correct? or there is better way?
because I want use this for mobile game and want be sure that this way don't reduce FPS when I add some objects in game.

Thanks.

Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 31st Mar 2015 13:25
before any thing please guide me to fix this Problem:

I want my ship can fire several bullet like below code. but problem is when I press SPACE key many times old fired bullets stop in air.

Please Guide Me.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 31st Mar 2015 13:32 Edited at: 31st Mar 2015 13:38
You need to update all bullets, not just one here:


Also you need to store each new bullet correctly here:


Like this:


EDIT: Updated with more detail

Using AppGameKit V2 Tier 1
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 31st Mar 2015 13:43 Edited at: 31st Mar 2015 13:43
thanks baxslash.

but I have AppGameKit v1 and don't work below commands:

Engineer
9
Years of Service
User Offline
Joined: 16th Jul 2014
Location:
Posted: 31st Mar 2015 14:23
Excellent!
Super Bullet

AGK 2 !
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 31st Mar 2015 15:05
Quote: "but I have AppGameKit v1 and don't work below commands:"

Then you need to track the size of your array using a variable and "insert" data as you go along.

If you are unsure about how to do that can I suggest the Newcomers board which was created especially for questions about the 'basics' of AGK.

Using AppGameKit V2 Tier 1
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 31st Mar 2015 15:21
Quote: "If you are unsure about how to do that can I suggest the Newcomers board which was created especially for questions about the 'basics' of AGK.
"


OK, Thanks Baxslash

Login to post a reply

Server time is: 2024-04-25 12:53:33
Your offset time is: 2024-04-25 12:53:33