GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 GML Code Help » BOX pushing probs » 2017-02-12 14:37:24

phinto
Replies: 1

okay, my issue is that I have the push code but this turns out wrong, just look at vid.

ja, this box sticks to player when I climb ladder, and pass through me.
and it didn't trigger the push animation as I tried to.

helped by benji

its for collition.

Expand///check Collision(x, y)

var xpos = argument[0];
var ypos = argument[1];

if (place_meeting(xpos, ypos, obj_platform)) // Check for collisions against normal blocks
  {
  return true;
  }
else

  
  {
  // Check for collisions against jump-through platforms
  var platform = instance_place(xpos, ypos, obj_jumpthrough_platform);
  if (platform == noone)
    return false;
  if (image_blend == c_red) // If it's in red mode, allow moving up through it, but not falling down
    return ((vsp > 0 and bbox_bottom <= platform.bbox_top) or (vsp == 0 and bbox_bottom < platform.bbox_bottom));
  else
    return (vsp <= 0 and bbox_bottom > platform.bbox_bottom); // When in cyan mode, allow falling through, but not jumping up or walking through it
   }
 // return false;
  
 return false;
    
    

//by benjamin ...............................................................................


// { // Check for collisions against jump-through platforms
//  var platform = instance_place(xpos, ypos, obj_jumpthrough_platform_2);
//  if (platform == noone)
//    return false;
//  if (image_blend == c_aqua) // If it's in red mode, allow moving up through it, but not falling down
//    return ((vsp < 0 and bbox_bottom >= platform.bbox_top) or (vsp == 0 and bbox_bottom > platform.bbox_bottom));
//  else
//    return (vsp >= 0 and bbox_bottom < platform.bbox_bottom); // When in cyan mode, allow falling through, but not jumping up or walking through it
//    }

and this is for the player

Expand///player script

// player output.................................................

if !stop
KyR = keyboard_check_direct(vk_right);
KyL = -keyboard_check_direct(vk_left); 
KyJ = keyboard_check_pressed(vk_up);
KyU = keyboard_check_direct(vk_up);
KyD = keyboard_check_direct(vk_down);
// react inputs..................................................

if !stop
move = KyL + KyR;


if !stop 
hsp = move * msp;


if !stop
if (vsp < 10) vsp += grav;


if !stop
if (checkCollision(x,y+1))
 {
   vsp = KyJ * -jsp
 }


//push animation................................................

if !stop
if (checkCollision(x+hsp,y,obj_box))
 {
   sprite_index = any_push;
}

// push............................................................ooo__________________________________________-
if !stop + !ladder
with (instance_place(x+image_xscale, y, obj_box))
{
  // x += other.hsp;   or  image_xscale = move;
   x +=other.hsp;
}

// horizontal...................................................

if !stop
if (checkCollision(x+hsp,y))
{
 while(!checkCollision(x+sign(hsp),y))
  {
    x += sign(hsp);
  }
  hsp = 0;
}
x += hsp;

// vertical...................................................

if !stop
if (checkCollision(x,y+vsp))
{
while(!checkCollision(x,y+sign(vsp)))
  {
    y += sign(vsp);
  }
  vsp = 0;
}
y += vsp;

//.....................................................................


// animate......................................................     
  
if !(ladder)
{
if !stop
if (move!=0) image_xscale = move;
image_speed = 0.5;
    if (checkCollision(x,y+1))
     {
        if (move!=0) sprite_index = any_run; else sprite_index = any_stand;
     }
    else
     {
        if (vsp < 0) sprite_index = any_jump; else sprite_index = any_fall;
     }
}

//push animation...................................................................................

// bounce spring................................................

var inst = instance_place(x, y, obj_spring);
if (inst != noone)
{
if (inst.y > y+16)
  {
 vsp = -jps;
  }
} 


//exit...........................................................
if stop = true
{
sprite_index = any_stand
vsp = 0
hsp = 0
}

//death..........................................................
if !deathless 
if (place_meeting(x,y,obj_death_par))
{
deathless = true;
alarm[0] = 80;
lives-=3;
audio_play_sound(sou_hurt,1,0);
}


//deathless........................................................
if deathless = true
{
  image_alpha = 0.5;
}
else
{
  image_alpha = 1;
}

//hit by or bounce on enemy.................................................................
if !deathless
if instance_place(x,y,obj_enemy_par)
{
    if (obj_enemy_par.y > y+16)
    {
        obj_enemy_par.HP-=1;
        vsp = -jsp;
        audio_play_sound(sou_enemyhit,1,0);
    }
    else
    {
      hsp = -image_xscale*1;
      vsp = -3;
      deathless = true
      alarm[0] = 80;
      lives-=1;
      audio_play_sound(sou_hurt,1,0);
    }
}

//hit by invincenemy.................................................................
if !deathless
if instance_place(x,y,obj_bullet_par)
{
      hsp = -image_xscale*1;
      vsp = -3;
      deathless = true
      alarm[0] = 80;
      lives-=1;
      audio_play_sound(sou_hurt,1,0);
}

// convayor.......................................................
if !stop
if (place_meeting(x,y+1,obj_convayor_platform))
{
if (other.image_blend == c_red)
{x-=1.5} 
else
{x+=1.5}
}



//Ladder.....................................................................................
if (KyU || KyD)
{
    if place_meeting(x,y,par_ladder) ladder = true;
}

if (ladder)
{
    vsp = 0;
    grav = 0;
    if (KyU) vsp = -2 ;
    if (KyD) vsp = 2 ;
    
    if !place_meeting(x,y,par_ladder)
    ladder = false;  
   
}
if !(ladder)
grav = 0.3;

//ladder animation............................................................
if (ladder)
{
    sprite_index = any_climb;
    image_speed = 0;
    if (KyU) image_speed = 0.2;
    if (KyD) image_speed = 0.2;
}
//stuck death............................................................


if place_meeting(x,y, obj_platform_red) 
 {
  deathless = true;
  alarm[0] = 80;
  lives-=3;
  audio_play_sound(sou_hurt,1,0);
 }

if place_meeting(x,y, obj_platform_cyan) 
 {
  deathless = true;
  alarm[0] = 80;
  lives-=3;
  audio_play_sound(sou_hurt,1,0);
 }


//.........................................................................................

have I miss something?

#2 Re: GML Code Help » RPG enemy » 2015-05-30 14:44:12

also I was using GM studio standard edition...

#3 Re: GML Code Help » RPG enemy » 2015-05-30 14:20:15

xot wrote:

If you want more users, post a question at The GMC. That's a better place for beginners to get help. This forum is for advanced scripting problems and has very few visitors.

didn't mean to rain on your parade but...

I came from GMC... some friend asked me to go here on this site...

#4 Re: GML Code Help » RPG enemy » 2015-05-30 14:03:02

we need more users to help us...

and i did put it here sad

#5 Re: GML Code Help » RPG enemy » 2015-05-30 13:51:34

so whare should I put it?


i put
set variable pwr to 0
                  execute code:

shoot_at_instance_id(player.id);

on enemy

and with a move towreds, there still shooting a same middle guy...

#6 Re: GML Code Help » RPG enemy » 2015-05-30 13:19:34

in object enemy, in  event stepnormalevent action number 11 at line 13 : function "shoot_at_instance_id" expects 1 arguments, 5 provided

complete fail...

whats wrong?

#7 GML Code Help » RPG enemy » 2015-05-30 10:49:32

phinto
Replies: 10

I need allot of help.
I need a easy code for the turn based enemy, or bullet, shoot at any of my players.

read this information below

ExpandInformation about object: enemy
Sprite: spr_enemy
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: 
Children: 
Mask: 

No Physics Object
Create Event:

set variable HP to 10
set variable atk to 1
set variable def to 1
set variable spd to 1
set variable pwr to random(50)
set Alarm 0 to 5
set the sprite to spr_enemy with subimage random(13) and speed 0
Alarm Event for alarm 0:

set variable pwr relative to spd
set Alarm 0 to 5
Step Event:

      if HP is less than or equal to 0
            destroy the instance
                  create a medium effect of type ellipse relative at (16,16) of  color 0 below objects
else
      if pwr is greater than or equal to 55
            set variable pwr to 0
                  create instance of object bullet at relative position (0,0)
Draw Event:

Draw the instance
set the font for drawing text to font0 and align left
at relative position (0,-18) draw the value of: HP
at relative position (-18,0) draw the value of: pwr


I just need a code for those white bullets behind those enemy's on a right.

mangle.png

i can't just make the bullets move towerds player.x player.y, tried...

Board footer

Powered by FluxBB