planes | gml
| Type | Desc |
instance_create_layer(x, y, layer_to_create_in, object) | function | spawns 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. |
Sprite | Images |
sprPlayerShip | |
sprEnemyShip | |
sprPanorama | |
sprLazer | |
If you want lazers to appear middle-centre when spawned, centre the origins of the planes and lazer.
Object | Sprite | Properties |
objPlayerShip | sprPlayerShip | Visible |
objEnemyShip | sprEnemyShip | Visible |
objLazer | sprLazer | Visible |
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
- Add more enemies
- score etc