A game created to mimic the original game Tron.
Here is some code of the player object. It's very simple and straight forward. I've used actual values rather than variables to display on this page. This code checks the keys pressed to turn the player, if the player hits a wall and draws the players trail. The player will also create an instance
of the trail behind the player depending where they're currently facing.
p = obj_player1
t = obj_player1_trail
if keyboard_check(vk_down){speed = 2;}else{speed = 4;}
if keyboard_check(vk_left){direction += 8}
if keyboard_check(vk_right){direction -= 8}
if(instance_exists(p) == true || instance_place(x,y,t)){
instance_create(p.x+lengthdir_x(4,direction+180),p.y+lengthdir_y(4,direction+180),t)
}
if instance_place(p.x,p.y,obj_outer_walls) or instance_place(p.x+lengthdir_x(speed,direction),p.y+lengthdir_y(speed,direction),t) {
effect_create_above(ef_explosion, x, y, 2, c_blue);
instance_destroy();
//room_restart();
}