skofrant
Member
Hi all,
I have a request, can someone help me in preparing such a template of the weapon change system?
already describes what I mean ..
I have such a hero code below ... my hero after pressing the action button in this case X. shoots a bullet.
And that's ok. this ball has an unlimited number of bullet.
I would like to be able to choose 4 more weapons besides the primary weapon.
the only condition is that I need to find a given weapon on the board ... suppose there is a weapon on the board, I pick it up and automatically add that weapon to the hero with any amount of ammo which is limited. This weapon icon will automatically be added to the game HUD with the ammo sprites of whatever weapon it has.
The choice of weapons, for example, would be under the button of one of the keys 1,2,3,4 and 5
code below my hero step
My hero's attack collision sprite is the hand from which the hero shoots, so I don't need to change the hero's sprite but create a new one corresponding to the weapon that will be displayed on the palm as in the code above.
In the picture below I described it in the form of a drawing in more detail.
Thank you
I have a request, can someone help me in preparing such a template of the weapon change system?
already describes what I mean ..
I have such a hero code below ... my hero after pressing the action button in this case X. shoots a bullet.
And that's ok. this ball has an unlimited number of bullet.
I would like to be able to choose 4 more weapons besides the primary weapon.
the only condition is that I need to find a given weapon on the board ... suppose there is a weapon on the board, I pick it up and automatically add that weapon to the hero with any amount of ammo which is limited. This weapon icon will automatically be added to the game HUD with the ammo sprites of whatever weapon it has.
The choice of weapons, for example, would be under the button of one of the keys 1,2,3,4 and 5
code below my hero step
GML:
//Normal movement
if ladder == false
{
if key_check_pressed(key.jump) && inAir == false
{
vspd = -10-sign;
jumpStr = 5;
if key_check(key.down) && place_meeting(x,y+1,par_solid_ghost)
{
y += 4;
vspd = 0;
jumpStr = 0;
jumpTimes = 0;
}
}
else if key_check(key.jump) && jumpStr> 0
{
audio_play_sound(music_jump, 1, false); //jump music
vspd -= 2+sign;
jumpStr--;
}
else
{
if key_check_released(key.jump) && jumpStr > 2
{
vspd += 2+sign;
}
jumpStr = 0;
}
///the code responsible for the hero's shot
if keyboard_check_pressed(ord('X')) && attClock == false && instance_number(obj_bullet)< 3 {
attClock = 30;
curAttack= 1;
with instance_create(x,y,par_attack) {
sprite_index = mask_player_attack;
image_xscale = other.image_xscale;
{
var box, ID;
if image_xscale == -1
box = bbox_left;
else
box = bbox_right;
ID = instance_create(box+image_xscale*49, y-17, obj_bullet);
ID.hspeed = image_xscale * 15;
owner = par_player;
audio_play_sound(shot_sounds, 1, false); //shot sounds
}
}
}
//ladder
if place_meeting(x,y,par_climbable) && place_meeting(x,y-32,par_climbable) && place_meeting(x,y+5,par_climbable) && (key_check(key.up) || key_check(key.down))
{
ladder = true;
vspd = 0;
hspd = 0;
}
}
//climbing
if ladder == true
{
var __hsign = key_check(key.right)-key_check(key.left);
var __vsign = key_check(key.down)-key_check(key.up);
hspd = min(max(hspd+__hsign,-2),2);
vspd = min(max(vspd+__vsign*2,-4),4);
if __vsign == -1 && !place_meeting(x,y-32,par_climbable)
{
ladder = false;
vspd = -10;
}
if __hsign != 0
{
image_xscale = __hsign;
}
if !place_meeting(x,y,par_climbable) || !place_meeting(x,y+32,par_climbable)
{
ladder = false;
}
}
////Ghost platform the ladder inherits from
////Normal movement
if ladder == false {
if key_check(key.down) && inAir == false{
////Step down
if key_check(key.down) && place_meeting(x,y+1,obj_par_ladder_solid_ghost){
y += 4; // Changing this value causes the hero to grab the top edge of the ladder after pressing the down button, but the screen will jump for a split second
vspd = 0;
jumpStr = 0;
jumpTimes = 0;
}
}
////Hero can shoot from the ladder
if keyboard_check_pressed(ord('X')) && ladder==true && attClock == false && place_meeting(x,y,par_climbable) && instance_number(obj_bullet) < 3
{
attClock = 30;
curAttack = 1;
with instance_create(x,y,par_attack) {
sprite_index = spr_player_shoot_ladder;
image_xscale = other.image_xscale;
{
var box, ID;
if image_xscale == -1
box = bbox_left;
else
box = bbox_right;
ID = instance_create(box+image_xscale*-10, y-17, obj_bullet);
ID.hspeed = image_xscale * 15;
owner = par_player;
audio_play_sound(shot_sounds, 1, false); //shot sounds
}
}
}
}
My hero's attack collision sprite is the hand from which the hero shoots, so I don't need to change the hero's sprite but create a new one corresponding to the weapon that will be displayed on the palm as in the code above.
In the picture below I described it in the form of a drawing in more detail.
Thank you
weapon and ammo and sprites.png
drive.google.com