Type | Desc | |
---|---|---|
viewport | property | allows us to set up our 'camera' to focus or view a segmented portion of the room in the game window. great for large maps or areas etc. |
image_angle | variable | current angle at which the image will be drawn. |
race track | gml
Type | Desc | |
---|---|---|
viewport | property | allows us to set up our 'camera' to focus or view a segmented portion of the room in the game window. great for large maps or areas etc. |
image_angle | variable | current angle at which the image will be drawn. |
Sprite | Images |
---|---|
sprCar | ![]() |
sprTrack3072x2304 | ![]() |
The following image shows the origin set between the back wheels - it is recommended however you place your origin between the front wheels instead for quality steering and handling:
Finally, set race track collision mask to precise (slow). This is not an ideal long-term solution, but will do while we are learning GML:
Object | Sprite | Properties |
---|---|---|
objCar | sprCar | Visible |
objTrack | sprTrack3072x2304 | Visible |
objCar Step event:
//check if on or off-road: if (place_meeting(x, y, objTrack)){ //on-road: max_speed = 20; } else { //off-road: max_speed = 5; //if we go on ro off-road, speed will be too high... if (speed > max_speed){ //... so decay speed gradually each step: speed = speed * 0.95; } } //steering: if (keyboard_check(vk_left)){ image_angle = image_angle + 3; direction = direction + 3; } if (keyboard_check(vk_right)){ image_angle = image_angle - 3; direction = direction - 3; } //accelerate: if (keyboard_check(vk_up)){ if (speed < max_speed){ speed = speed + 0.5; } }