skofrant
Member
hi all,
I have a simple system for changing weapons, for now there are two basic weapons and a more powerful one, but there will be about 5 more of them.
And now this is how I start the game with a basic weapon ;-) to have this more powerful weapon I have to find it on the board ..
The player finds this weapon and it is automatically added to him together with the amount of ammunition, in this case 20 rounds, and on the hud bar the icon of this weapon is displayed immediately and the number of rounds under it.
I assigned the change of weapon to buttons 1 and 2 ... where 1 corresponds to the standard unlimited weapon, and 2 corresponds to a more powerful weapon with limited ammunition up to 20
The problem is that when I have this more powerful weapon and I go to the next board (room), I don't have it ... I still have an ordinary weapon, even though I still had ammunition in the previous board (room) ... and in order to have the additional one, I have to find the object again, hover over it and then the icon will also appear again with the additional weapon and the amount of ammunition ...
the second problem, when I start the game, I have a value of 20 assigned to the draw gui event. This should not be the case with the primary weapon, because it has unlimited ammunition, it should only appear with the second weapon, which has a limited number of bullets
Maybe someone will be able to change my attack code in the hero's steppe, because if there are a few more types of weapons, I will have a lot of it in the hero's code
Ok
Here below is my code
obj_player
create
obj_player
step
obj_weapon_chest
here a collision with the player (when he touch over the crates, he gets this weapon and ammunition)
obj_player
pressing the button 1
obj_player
pressing the button 2
Now this is obj_game_controler perssistent who always accompanies the game ..
obj_game_controler
create
obj_game_controler
Step
obj_game_controler
Draw GUI
I have a simple system for changing weapons, for now there are two basic weapons and a more powerful one, but there will be about 5 more of them.
And now this is how I start the game with a basic weapon ;-) to have this more powerful weapon I have to find it on the board ..
The player finds this weapon and it is automatically added to him together with the amount of ammunition, in this case 20 rounds, and on the hud bar the icon of this weapon is displayed immediately and the number of rounds under it.
I assigned the change of weapon to buttons 1 and 2 ... where 1 corresponds to the standard unlimited weapon, and 2 corresponds to a more powerful weapon with limited ammunition up to 20
The problem is that when I have this more powerful weapon and I go to the next board (room), I don't have it ... I still have an ordinary weapon, even though I still had ammunition in the previous board (room) ... and in order to have the additional one, I have to find the object again, hover over it and then the icon will also appear again with the additional weapon and the amount of ammunition ...
the second problem, when I start the game, I have a value of 20 assigned to the draw gui event. This should not be the case with the primary weapon, because it has unlimited ammunition, it should only appear with the second weapon, which has a limited number of bullets
Maybe someone will be able to change my attack code in the hero's steppe, because if there are a few more types of weapons, I will have a lot of it in the hero's code
Ok
Here below is my code
obj_player
create
GML:
global.primaryweapon=1
global.shotgun=0
global.shotgunammo=0
obj_player
step
GML:
if keyboard_check(kAction) && attClock == false
{
if global.primaryweapon=1 or global.shotgun=0
{
attClock = 6;
curAttack = 1;
with instance_create( x+(image_xscale*12), y-26, obj_primaryweapon)
{
hspd = other.image_xscale*15;
vspd = 0;
g = .0;
owner = par_player;
strength = 0;
explode = true;
explosionRadius = 20;
explosionStrength = 2+(sign(other.pwrupStr)*8);
}
}
}
if keyboard_check(kAction) && attClock == false
{
if global.shotgun=1 and global.shotgunammo>0
{
attClock = 6;
curAttack = 1;
with instance_create( x+(image_xscale*12), y-26, obj_shotgun)
{
global.shotgunammo-=1
hspd = other.image_xscale*15;
vspd = 0;
g = .0;
speed=4;
owner = par_player;
strength = 0;
explode = true;
explosionRadius = 20;
explosionStrength = 2+(sign(other.pwrupStr)*8);
}
}
}
here a collision with the player (when he touch over the crates, he gets this weapon and ammunition)
GML:
global.shotgun=1
global.shotgunammo=1
global.primaryweapon=0
obj_player
pressing the button 1
GML:
global.primaryweapon=1
if global.shotgun=1
global.shotgun=0
obj_player
pressing the button 2
GML:
global.primaryweapon=0
if global.shotgun=0 and global.shotgunammo=1
global.shotgun=1
Now this is obj_game_controler perssistent who always accompanies the game ..
obj_game_controler
create
GML:
global.shotgunammo=20
obj_game_controler
Step
GML:
if global.shotgunammo>20
global.shotgunammo=20
obj_game_controler
Draw GUI
GML:
draw_text(x+76, 46,string(" " + string(global.shotgunammo)))
if global.shotgun=1
draw_sprite(spr_shotgun,0,x,y)
if global.shotgun=0
draw_sprite(spr_primaryweapon,0,x,y)