【GameMaker】 Create a particle trail when an object moves

Information about object: obj_player
Sprite: spr_player
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object

Step Event:
execute code:

//Update to mouse position
x=mouse_x;
y=mouse_y;
//Create a particle object
part = instance_create(x,y,obj_particle);
part.vspeed = 1;
part.gravity = 0.1;
part.delta = 0.1;

Information about object: obj_particle
Sprite: spr_par Solid: false Visible: true Depth: 0 Persistent: false Parent: Children: Mask:
No Physics Object
Step Event:
execute code:

// Fadeout:
image_alpha -= delta;
if image_alpha <= 0 instance_destroy();//destroy if invisible

【GameMaker】 Keep Player in View

Information about object: obj_player
Sprite: spr_player
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

view_wview[0]=600;//set wiew width
view_hview[0]=600;//set view height
view_enabled[0] = true;//enable view
view_visible[0] = true;//make visible
view_hborder[0]=250;//set horizontal border for object
view_vborder[0]=250;//set vertical border
view_object[0]=obj_player;//set object to follow

Step Event:
execute code:

//movement code
if (keyboard_check(ord('A')))  {x-=5;} 
if (keyboard_check(ord('D')))  {x+=5;} 
if (keyboard_check(ord('W')))  {y-=5;} 
if (keyboard_check(ord('S')))  {y+=5;}



Information about object: obj_next_room
Sprite: Solid: false Visible: true Depth: 0 Persistent: false Parent: Children: Mask:
No Physics Object
Create Event:
execute code:

room_goto(room_example);

【GameMaker】 Duck Hunt Game Remake

Information about object: obj_duck
Sprite: spr_duck
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

dir=choose("side","up");//choose a state
if dir="side"//if side
{
x=-50;//set just off of screen
y=irandom_range(100,room_height-100);//choose a ra
hspeed=1+random(3);//set random speed
}
if dir="up"//if up
{

x=irandom_range(50,room_width-50);//choose random position
y=room_height+50; //set just off of screen
dir=random(180);//set a random direction 
spd=1+random(3);//set a random speed
motion_set(dir,spd);//applydirection and speed
}

Step Event:
execute code:

//destroy if off screen
if x>room_width+100
{
instance_destroy();
}
if y<-50
{
instance_destroy();
}




Information about object: obj_gun
Sprite: spr_gun Solid: false Visible: true Depth: 0 Persistent: false Parent: Children: Mask:
No Physics Object
Create Event:
execute code:

alarm[0]=100+random(room_speed*3);//set alarm to spawn duck
score=0;
Alarm Event for alarm 0:
execute code:

instance_create(0,0,obj_duck);//spawn a duck
alarm[0]=100+random(room_speed*3);//set spawn alarm agin
Step Event:
execute code:

//update position
x=mouse_x;
y=mouse_y;

if mouse_check_button_pressed(mb_left) && position_meeting(x,y,obj_duck)//if mouse pressed
{
score+=10;
var inst=instance_position(x,y,obj_duck);
with (inst)
{
instance_destroy();
}
}
Draw Event:
execute code:

draw_self();
draw_text(20,20,"Score "+string(score));

【GameMaker】 Destructible Terrain

Information about object: obj_terrain
Sprite: spr_terrain
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

//set up

w = sprite_width;
h = sprite_height;

//create surface and add sprite
surface = surface_create(w,h); 
surface_set_target(surface); 
draw_sprite(spr_terrain,-1,0,0);
surface_reset_target();

//save surface as spr
spr=sprite_create_from_surface(surface,0,0,w,h,true,true,0,0);
sprite_index=spr;

Step Event:
execute code:

//manage suface
if !surface_exists(surface)
    {
    surface = surface_create(w,h);
    surface_set_target(surface);
    draw_sprite(spr,-1,0,0);
    surface_reset_target();
    }

//create a bomb on mouse press
if mouse_check_button_pressed(mb_left) instance_create(mouse_x,mouse_y,obj_bomb);

Collision Event with object obj_bomb:
execute code:

//set surface
surface_set_target(surface);
draw_set_color(c_white);
draw_circle(other.x-x,other.y-y,32,false);
//reset
surface_reset_target();

//delete the sprite
sprite_delete(spr);
spr=sprite_create_from_surface(surface,0,0,w,h,1,1,0,0);
sprite_index=spr;


with other instance_destroy();//destroy bomb


Other Event: Room End:
execute code:

//clear memory
surface_free(surface);




Information about object: obj_bomb
Sprite: spr_bom Solid: false Visible: true

【GameMaker 】Word Typing Game

create 

 words=ds_list_create();//create a list ds_list_add(words,"ham","eggs","potato","cheese","pizza","chocolate");//add some words size=ds_list_size(words);//get size word=words[|irandom_range(0,size-1)];//choose one word at random keyboard_string="";//set to "" timer=100;//set as 100 - to be used as a timer


 step 


 if keyboard_string==word//check if player typed correctly { score+=10;//increase score word=words[|irandom(size-1)];//choose a new word keyboard_string="";//clear string health=100;//reset timer } timer-=1; if timer==0 { score-=10; word=words[|irandom(size-1)]; keyboard_string=""; timer=100; }



 draw

 //drawing draw_text(100,100,"Word To Type: "+word); draw_text(100,150,"Word Typed: "+keyboard_string); draw_text(100,200,"Score "+string(score)); draw_text(100,250,"Time "+string(timer));

How the New York Times led to the fall of Assad

Anti-semitism by the New York Times actually made Israel safer ͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­...

Contact Form

Name

Email *

Message *