Powered by Invision Power Board

 
    Reply to this topicStart new topicStart Poll

> Bullet Fireing in GM7
United States
Fuzzy
Posted: Jul 31 2008, 07:23 PM
Quote Post



[*][*][*]

Group Icon
Group: Members
Posts: 2411
Member No.: 3024
Joined: 7-December 06

Status: (0d) [--]


How do you allow a character to fire a single bullet out of a gun, not invloving the mouse of course.


--------------------
PMEmail PosterAOLMSN
Top
United States
Datt
Posted: Jul 31 2008, 07:31 PM
Quote Post


I'm having a blast
[*][*]

Group Icon
Group: Members
Posts: 1022
Member No.: 4623
Joined: 24-October 07

Status: (0d) [--]


Create a player object, and a bullet object.

In the Player's create event
CODE

canfire = true
isleft = false
// the rest of your stuff


Create a "press a key" event. Choose whatever key you want to press to shoot.

In that event
CODE

if canfire = true
{
instance_create(x?, y?, bullet)
canfire = false
alarm[0] = 10



In the Players Alarm 0 event
CODE

canfire = true



Whoops, you never specified if the gun is in the sprite of the character...That's what this is for. If you have the gun as a seperate object it shouldn't be too much different. Also, you never said if it was a topdown shooting, fps, or platform shooting. This is for platform or topdown..Sorry sad.gif

This post has been edited by Im4everkool on Jul 31 2008, 07:34 PM


--------------------
QUOTE (Mario_6464SMR's reply to Mrs A)
his name's not Halo it's the master chief, and i don't know what "doesn't afraid of anything" means, have u ever played halo before?

PMUsers Website
Top
United States
RetroXYZ
Posted: Jul 31 2008, 07:32 PM
Quote Post


Standard Member
[*][*]

Group Icon
Group: Members
Posts: 2714
Member No.: 4325
Joined: 27-August 07

Status: (0d) [--]


EDIT: @Above: Built-in alarms are really really really really bad.
Step Event:
CODE
if keyboard_check(vk_shootkey) then
{
instance_create(gunx,guny,obj_bullet);
}

Change "gunx" and "guny" whenever you move.

Bullet Create Event:
CODE
dir=obj_player.dirvar;
pos=0;


Bullet Step Event:
CODE
pos+=4;
x=view_xview+pos;
if pos>view_wview then instance_destroy();


Works best at 60 FPS.

This post has been edited by RetroXYZ on Jul 31 2008, 07:33 PM
PMEmail PosterMSN
Top
United States
Datt
Posted: Jul 31 2008, 07:36 PM
Quote Post


I'm having a blast
[*][*]

Group Icon
Group: Members
Posts: 1022
Member No.: 4623
Joined: 24-October 07

Status: (0d) [--]


QUOTE (RetroXYZ @ Jul 31 2008, 07:32 PM)
@Above: Built-in alarms are really really really really

sad.gif They always work for me...
@Clearness, you should just try the different ways in this topic and see which one works better for you.


--------------------
QUOTE (Mario_6464SMR's reply to Mrs A)
his name's not Halo it's the master chief, and i don't know what "doesn't afraid of anything" means, have u ever played halo before?

PMUsers Website
Top
United States
RetroXYZ
Posted: Jul 31 2008, 07:39 PM
Quote Post


Standard Member
[*][*]

Group Icon
Group: Members
Posts: 2714
Member No.: 4325
Joined: 27-August 07

Status: (0d) [--]


They're buggy, like the Animation End event. I bet you didn't know that the event executed after cycling to the first frame, did you?
PMEmail PosterMSN
Top
United States
Datt
Posted: Jul 31 2008, 07:42 PM
Quote Post


I'm having a blast
[*][*]

Group Icon
Group: Members
Posts: 1022
Member No.: 4623
Joined: 24-October 07

Status: (0d) [--]


QUOTE (RetroXYZ @ Jul 31 2008, 07:39 PM)
They're buggy, like the Animation End event. I bet you didn't know that the event executed after cycling to the first frame, did you?

Actually yes. I did.


--------------------
QUOTE (Mario_6464SMR's reply to Mrs A)
his name's not Halo it's the master chief, and i don't know what "doesn't afraid of anything" means, have u ever played halo before?

PMUsers Website
Top
United States
Fuzzy
Posted: Jul 31 2008, 07:51 PM
Quote Post



[*][*][*]

Group Icon
Group: Members
Posts: 2411
Member No.: 3024
Joined: 7-December 06

Status: (0d) [--]


QUOTE (RetroXYZ @ Jul 31 2008, 06:32 PM)
EDIT: @Above: Built-in alarms are really really really really bad.
Step Event:
CODE
if keyboard_check(vk_shootkey) then
{
instance_create(gunx,guny,obj_bullet);
}

Change "gunx" and "guny" whenever you move.

Bullet Create Event:
CODE
dir=obj_player.dirvar;
pos=0;


Bullet Step Event:
CODE
pos+=4;
x=view_xview+pos;
if pos>view_wview then instance_destroy();


Works best at 60 FPS.

I understand this all but gunx and guny. What exactly am I suppose to put here?

Oh and thanks.


--------------------
PMEmail PosterAOLMSN
Top
Unspecified
mr.mario
Posted: Jul 31 2008, 08:06 PM
Quote Post


and you people thought Mugen coded in GML would never work
[*][*][*]

Group Icon
Group: Members
Posts: 4755
Member No.: 2349
Joined: 17-July 06

Status: (0d) [--]


QUOTE (RetroXYZ @ Jul 31 2008, 07:39 PM)
They're buggy, like the Animation End event. I bet you didn't know that the event executed after cycling to the first frame, did you?

this isn't nessecarly a bad thing, cause if it didn't my attack system in Gmugen would never work laugh3.gif

on topic, gunx and guny is where the gun is at, you'll have to define these, to tell you how to do this I'd have to know what kind of shooter your're making


--------------------
mr.mario's emulated music engine(gamemaker)http://archive.mfgg.net/index.php?showtopic=214636here

Gmugen: here
PMEmail Poster
Top
United States
Fuzzy
Posted: Jul 31 2008, 08:07 PM
Quote Post



[*][*][*]

Group Icon
Group: Members
Posts: 2411
Member No.: 3024
Joined: 7-December 06

Status: (0d) [--]


Ah okay, Its just a basic run-n-jump shooter. Platform of course.


--------------------
PMEmail PosterAOLMSN
Top
Unspecified
mr.mario
Posted: Jul 31 2008, 08:13 PM
Quote Post


and you people thought Mugen coded in GML would never work
[*][*][*]

Group Icon
Group: Members
Posts: 4755
Member No.: 2349
Joined: 17-July 06

Status: (0d) [--]


okay, just open your handy dandy sprite editor, put your mouse over the point you want the bullet to come from and set the bulletx and bullety to these coordinate "bulletx = 13" for example


--------------------
mr.mario's emulated music engine(gamemaker)http://archive.mfgg.net/index.php?showtopic=214636here

Gmugen: here
PMEmail Poster
Top
United States
Fuzzy
Posted: Jul 31 2008, 08:22 PM
Quote Post



[*][*][*]

Group Icon
Group: Members
Posts: 2411
Member No.: 3024
Joined: 7-December 06

Status: (0d) [--]


Eh, nope nothing is working. anything like gunx or playerx or bullet x aint working.


--------------------
PMEmail PosterAOLMSN
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

  Topic Options Topic Options Reply to this topicStart new topicStart Poll

 




[ Script Execution time: 0.0684 ]   [ 13 queries used ]   [ GZIP Enabled ]   [ Server Load: 0.36 ]