javelin | gml
a gml implmentation of the javelin game (see the games link)
objJavelin Create
x = 50; y = 500; rspeed = -2; //rotation speed aim_direction = -90; thrown = false;
objJavelin Step
//*** KEYBOARD PRESS ONCE TO THROW: ***
if keyboard_check(vk_space) and not thrown {
thrown = true;
gravity = 0.3;
speed = irandom_range(5,15);
direction = irandom_range(25,65);
aim_direction = image_angle + 90;
}
//*** IF JAVELIN IS IN AIR, ROTATE: ***
if (thrown == true)
{
image_angle += sin(degtorad(aim_direction - image_angle))*rspeed;
}
//*** IF LANDED, RESET: ***
if (y > room_height) {
thrown = false;
gravity = 0;
speed = 0;
x = 50;
y = 500;
image_angle = 0;
}
put an objJavelin anywhere in room and attach sprJavelin sprite