Jump to content


Photo

Any ideas how to make sword fighting game?


  • Please log in to reply
15 replies to this topic

#1 123Alvin

123Alvin

    GMC Member

  • GMC Member
  • 64 posts
  • Version:GM8

Posted 20 April 2012 - 10:56 PM

Im thinking of making sword fighting game but i need help. How to make object fight with sword and i need to make thut sword needs to be in colusion with enemmy to kill him or what ever but i have never done anything like this!
So any ideas?
Thanks!

Sry for my poor engl.
  • 0

#2 PWL

PWL

    The non-pixel-artist

  • GMC Member
  • 708 posts
  • Version:GM:Studio

Posted 21 April 2012 - 12:58 AM

(Why is there no answers to such topics..?)
I don't know if you're understanding GML or not, but I will explain it for you.
Make a sepherate object for the sword. Let's say the player is named obj_player, and the sprite of the sword is called spr_sword. We need to "attach" the sword to the player like this:
//End step event
x=obj_player.x; //We set the sword's x-value to obj_player's x-value, so it's at the same spot
y=obj_player.y; //Same for the y-value for the same reason
Now we need it to attack when you press a button. Make an attack-animation called spr_sword_attack
//Key press Space event (for example)
//You can do this without GML as well
sprite_index=spr_sword_attack; //Change sprite to spr_sword_attack
//Animation end
sprite_index=spr_sword; //Change back to the normal sprite

Now for the hurt-the-enemies-part. In the enemy-objects, add something like this.
//Collision with obj_sword event
if other.sprite_index=spr_sword_attack //This may seem a little weird, but this checks if the "other object in the collision" (in this case, the sword), has the attack-sprite right now
{ 
 //We need to do stuff inside these after an "if"
 instance_destroy(); //This destroys the enemy-object (Like the trash can-action)
}
That should be it!! I hope this gives you at least some advice! Give me a shout if it doesn't, lol.
  • 1

#3 drt_t1gg3r

drt_t1gg3r

    GMC Member

  • GMC Member
  • 3230 posts
  • Version:Unknown

Posted 21 April 2012 - 07:47 AM

(Why is there no answers to such topics..?)
...

because this is a forum relating to the understanding of gml and d&d, not a forum on how do I create a game, game design, game development, or a "would you make me this, or that" forum.
  • 0

#4 123Alvin

123Alvin

    GMC Member

  • GMC Member
  • 64 posts
  • Version:GM8

Posted 21 April 2012 - 09:33 AM

(Why is there no answers to such topics..?)
I don't know if you're understanding GML or not, but I will explain it for you.
Make a sepherate object for the sword. Let's say the player is named obj_player, and the sprite of the sword is called spr_sword. We need to "attach" the sword to the player like this:

//End step event
x=obj_player.x; //We set the sword's x-value to obj_player's x-value, so it's at the same spot
y=obj_player.y; //Same for the y-value for the same reason
Now we need it to attack when you press a button. Make an attack-animation called spr_sword_attack
//Key press Space event (for example)
//You can do this without GML as well
sprite_index=spr_sword_attack; //Change sprite to spr_sword_attack
//Animation end
sprite_index=spr_sword; //Change back to the normal sprite

Now for the hurt-the-enemies-part. In the enemy-objects, add something like this.
//Collision with obj_sword event
if other.sprite_index=spr_sword_attack //This may seem a little weird, but this checks if the "other object in the collision" (in this case, the sword), has the attack-sprite right now
{ 
 //We need to do stuff inside these after an "if"
 instance_destroy(); //This destroys the enemy-object (Like the trash can-action)
}
That should be it!! I hope this gives you at least some advice! Give me a shout if it doesn't, lol.

THX Il try it out
  • 0

#5 PWL

PWL

    The non-pixel-artist

  • GMC Member
  • 708 posts
  • Version:GM:Studio

Posted 21 April 2012 - 11:10 AM


(Why is there no answers to such topics..?)
...

because this is a forum relating to the understanding of gml and d&d, not a forum on how do I create a game, game design, game development, or a "would you make me this, or that" forum.

Ok, so maybe I do a little much of the dirty-work when I reply to people..... :P I was just a little surprised that there are several posts like these without a tip-reply on them ;)
  • 1

#6 pikmin4000

pikmin4000

    GMC Member

  • GMC Member
  • 185 posts
  • Version:GM:Studio

Posted 28 May 2012 - 03:01 AM

Hey, what do you think is a good idea to attach the sword. Like you said just to keep the x and y the same. Is that implying that the sprites are ready for that? I mean like, if the player is a 32x32 with some space ready for the sword and the sword is also 32x32 with space ready for the player?

What if there is no extra space ready for each sprite? What would you recommend? Perhaps using the origin on top of the sprite or the length_dir functions?
  • 0

#7 dannyjenn

dannyjenn

    GMC Member

  • GMC Member
  • 2233 posts
  • Version:Mac

Posted 28 May 2012 - 03:11 AM

Hey, what do you think is a good idea to attach the sword. Like you said just to keep the x and y the same. Is that implying that the sprites are ready for that? I mean like, if the player is a 32x32 with some space ready for the sword and the sword is also 32x32 with space ready for the player?

What if there is no extra space ready for each sprite? What would you recommend? Perhaps using the origin on top of the sprite or the length_dir functions?

I'd say plan it out in advanced when making the sprites... or if you have to, change the origin on one of the sprites so that it does match up.
  • 0

#8 pikmin4000

pikmin4000

    GMC Member

  • GMC Member
  • 185 posts
  • Version:GM:Studio

Posted 28 May 2012 - 03:15 AM


Hey, what do you think is a good idea to attach the sword. Like you said just to keep the x and y the same. Is that implying that the sprites are ready for that? I mean like, if the player is a 32x32 with some space ready for the sword and the sword is also 32x32 with space ready for the player?

What if there is no extra space ready for each sprite? What would you recommend? Perhaps using the origin on top of the sprite or the length_dir functions?

I'd say plan it out in advanced when making the sprites... or if you have to, change the origin on one of the sprites so that it does match up.


Lets say the guy swings his arm to attack, how can I set the origin to follow the point at the end of the arm without manually setting up the sprite?
  • 0

#9 dannyjenn

dannyjenn

    GMC Member

  • GMC Member
  • 2233 posts
  • Version:Mac

Posted 28 May 2012 - 03:20 AM



Hey, what do you think is a good idea to attach the sword. Like you said just to keep the x and y the same. Is that implying that the sprites are ready for that? I mean like, if the player is a 32x32 with some space ready for the sword and the sword is also 32x32 with space ready for the player?

What if there is no extra space ready for each sprite? What would you recommend? Perhaps using the origin on top of the sprite or the length_dir functions?

I'd say plan it out in advanced when making the sprites... or if you have to, change the origin on one of the sprites so that it does match up.


Lets say the guy swings his arm to attack, how can I set the origin to follow the point at the end of the arm without manually setting up the sprite?

You could probably somehow use math to calculate its position along the edge of a circle (with the radius being the character's arm). But the easiest (and the least likely to look weird) would just be to draw the sprite how you want it to begin with.

Edited by dannyjenn, 28 May 2012 - 03:20 AM.

  • 0

#10 GMKn00b

GMKn00b

    GMC Member

  • GMC Member
  • 150 posts
  • Version:Unknown

Posted 28 May 2012 - 07:35 AM

Try this. (This would be Dnd)

In your character:
1st.)Add a key press action (whatever key), then add a change sprite action (slashing)
2nd.)Add a key release action (same key as before), then add a change sprite action (back to normal sprite) OR you can add an "other" event and set it to animation end then add the same actions (change back to normal sprite)

In your enemy:
1st.)Add a collision event with your character then add a test variable action (in control tab)
2nd.)Instead of apply to "self", change it to "object" and select your character
3rd.)Change variable to spr_index and value to the name of the slashing sprite, leave the rest to default
4th.)Then under the test variable action add a destroy self action (under main 1 tab)

That's should work..... maybe :tongue:
I forgot how I did it (I made a similar game your doing now) but I'm sure I used spr_index
If it doesn't work, message me and I'll check how I did it and tell you (i'd be glad to help) :thumbsup:

EDIT: This is similar's to PWL's post but this is in DnD format, VERY SIMILAR, I just realized :laugh:

Edited by GMKn00b, 29 May 2012 - 08:56 AM.

  • 0

#11 pikmin4000

pikmin4000

    GMC Member

  • GMC Member
  • 185 posts
  • Version:GM:Studio

Posted 28 May 2012 - 03:54 PM

Try this. (This would be Dnd)

In your character:
1st.)Add a key press action (whatever key), then add a change sprite action (slashing)
2nd.)Add a key release action (same key as before), then add a change sprite action (back to normal sprite) OR you can add an "other" event and set it to animation end then add the same actions (change back to normal sprite)

In your enemy:
1st.)Add a collision event with your character then add a test variable action (in control tab)
2nd.)Instead of apply to "self", change it to "object" and select your character
3rd.)Change variable to spr_index and value to the name of the slashing sprite, leave the rest to default
4th.)Then under the test variable action add a destroy self action (under main 1 tab)

That's should work..... maybe :tongue:
I forgot how I did it (I made a similar game your doing now) but I'm sure I used spr_index
If it doesn't work, message me and I'll check how I did it and tell you (i'd be glad to help) :thumbsup:

EDIT: This is similar's to PWL's post but this is in DnD format, VERY SIMILAR, I just realized :laugh:


This wouldn't work as it acts upon the whole sword slashing sprite. As the sword only takes a fraction of the sprite, lets say the enemy touches the back of the player and it would still get hurt even though the sword wasn't there.
  • 0

#12 dannyjenn

dannyjenn

    GMC Member

  • GMC Member
  • 2233 posts
  • Version:Mac

Posted 28 May 2012 - 04:12 PM

This wouldn't work as it acts upon the whole sword slashing sprite. As the sword only takes a fraction of the sprite, lets say the enemy touches the back of the player and it would still get hurt even though the sword wasn't there.

Well, it could work if it was a one-on-one fighting game and if it was impossible for the enemy to end up on the other side of you in the first place. Still, it's not to realistic because something could happen like he could punch you in the face (without contacting the sword) and then he'd be the one taking damage.
  • 0

#13 daro0196

daro0196

    GMC Member

  • GMC Member
  • 41 posts
  • Version:GM8

Posted 28 May 2012 - 06:18 PM

Do you know how to make combos, i tried with this code but the sprite didnt change

{
if(keyboard_check_pressed(vk_space)) and facing=1
{
alarm[1] = 90;
combo1 += 1;
if combo1 = 1{
sprite_index = spr_thanatos_atk_1_sword_right
image_index=0;
}
if combo1 = 2{
sprite_index = spr_thanatos_atk_1_sword_right_2
image_index=0;
}
if combo1 > 3{
combo1 = 0;
}
}
if(sprite_index == spr_thanatos_atk_1_sword_right && image_index == 6)
{
sprite_index = spr_thanatos_stand_right;
}
  • 0

#14 pikmin4000

pikmin4000

    GMC Member

  • GMC Member
  • 185 posts
  • Version:GM:Studio

Posted 28 May 2012 - 10:51 PM

Do you know how to make combos, i tried with this code but the sprite didnt change

{
if(keyboard_check_pressed(vk_space)) and facing=1
{
alarm[1] = 90;
combo1 += 1;
if combo1 = 1{
sprite_index = spr_thanatos_atk_1_sword_right
image_index=0;
}
if combo1 = 2{
sprite_index = spr_thanatos_atk_1_sword_right_2
image_index=0;
}
if combo1 > 3{
combo1 = 0;
}
}
if(sprite_index == spr_thanatos_atk_1_sword_right && image_index == 6)
{
sprite_index = spr_thanatos_stand_right;
}


Like nothing happened at all? What event is this in? Maybe you got the facing wrong.
  • 0

#15 daro0196

daro0196

    GMC Member

  • GMC Member
  • 41 posts
  • Version:GM8

Posted 29 May 2012 - 12:59 AM


Do you know how to make combos, i tried with this code but the sprite didnt change

{
if(keyboard_check_pressed(vk_space)) and facing=1
{
alarm[1] = 90;
combo1 += 1;
if combo1 = 1{
sprite_index = spr_thanatos_atk_1_sword_right
image_index=0;
}
if combo1 = 2{
sprite_index = spr_thanatos_atk_1_sword_right_2
image_index=0;
it is on step event, and facing is ok, the problem is that when i press space the second time it keeps doing the first animation

}
if combo1 > 3{
combo1 = 0;
}
}
if(sprite_index == spr_thanatos_atk_1_sword_right && image_index == 6)
{
sprite_index = spr_thanatos_stand_right;
}


Like nothing happened at all? What event is this in? Maybe you got the facing wrong.


  • 0

#16 GMKn00b

GMKn00b

    GMC Member

  • GMC Member
  • 150 posts
  • Version:Unknown

Posted 29 May 2012 - 08:23 AM


Try this. (This would be Dnd)

In your character:
1st.)Add a key press action (whatever key), then add a change sprite action (slashing)
2nd.)Add a key release action (same key as before), then add a change sprite action (back to normal sprite) OR you can add an "other" event and set it to animation end then add the same actions (change back to normal sprite)

In your enemy:
1st.)Add a collision event with your character then add a test variable action (in control tab)
2nd.)Instead of apply to "self", change it to "object" and select your character
3rd.)Change variable to spr_index and value to the name of the slashing sprite, leave the rest to default
4th.)Then under the test variable action add a destroy self action (under main 1 tab)

That's should work..... maybe :tongue:
I forgot how I did it (I made a similar game your doing now) but I'm sure I used spr_index
If it doesn't work, message me and I'll check how I did it and tell you (i'd be glad to help) :thumbsup:

EDIT: This is similar's to PWL's post but this is in DnD format, VERY SIMILAR, I just realized :laugh:


This wouldn't work as it acts upon the whole sword slashing sprite. As the sword only takes a fraction of the sprite, lets say the enemy touches the back of the player and it would still get hurt even though the sword wasn't there.

Didn't realise, I was just thinking if you were facing right :tongue:
Oh well

Edited by GMKn00b, 29 May 2012 - 08:55 AM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users