• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Need Help Coding Attack in Game

T

TheDracoWave

Guest
Please help me. I am a newbie programmer trying to get my feet wet and I really have no clue as to code attack in my game.
 

Toque

Member
You will have to provide more information for anyone to offer help.

Watch a tutorial in the genre of your game for help.

Is your attack shooting a bullet or kick or sword or spell or ..........???????

It’s like asking “help me get to the store”. But don’t tell us where you are or what store you are going to.
 

JackTurbo

Member
If your shooting, simplest way is to create a bullet object. If you doing melee I'd suggest using a collision rectangle.

Either way there are lots of tutorials on the subject, have a browse on YouTube and do the one that seems to match your goals best.
 

Joe Ellis

Member
Code:
if attacking = false
{
if keyboard_check_pressed(vk_control)
{
sprite_index = spr_attack
image_index = 0
attacking = true
}
}
else
{
var hit_enemy = instance_place(x, y, obj_enemy);

if hit_enemy && !hit_enemy.hurt
{
hit_enemy.hurt = true
hit_enemy.vsp = -20
hit_enemy.health -= 10
}

if image_index = 0
{
attacking = false
sprite_index = spr_idle
}

}
 
Top