External Exam Download Resources Web Applications Games Recycle Bin

planes | gml

 TypeDesc
instance_create_layer(x, y, layer_to_create_in, object)functionspawns an object at an x and y position in a given layer. Layers can appear above or below eachother, and can be adjusted in the room properties. This function can also return the instance id of the object being spawned.
SpriteImages
sprPlayerShip
sprEnemyShip
sprPanorama
sprLazer

If you want lazers to appear middle-centre when spawned, centre the origins of the planes and lazer.

ObjectSpriteProperties
objPlayerShipsprPlayerShipVisible
objEnemyShipsprEnemyShipVisible
objLazersprLazerVisible

objEnemyShip Create

//face left:
image_angle = 180;
direction = 180;
speed = 10;

objEnemyShip Step

if (x < 0){
  x = room_width;
  y = random(room_height);
}

if place_meeting(x,y,objLazer){
  instance_destroy();	
}

objPlayerShip Step

left = keyboard_check(vk_left);
right = keyboard_check(vk_right);
up = keyboard_check(vk_up);
down = keyboard_check(vk_down);
if (left) { x += -5; }
if (right) { x += 5; }
if (up) { y += -5; }
if (down) { y += 5; }

//lazer:
if keyboard_check_pressed(vk_space){
  lazer = instance_create_layer(x,y,"Instances",objLazer);
  with(lazer){
    hspeed = 20;  
  }
}
Challenges
  1. Add more enemies
  2. score etc