ThePlayerEden
Member
Hi All!
So I'm making this pixel RPG-styled game, anyways, I'm trying to add "vehicles".
I was able to get the vehicle moving and whatnot, the next thing I'm trying to do is have it where my player can enter/exit the said vehicle.
I figure I just make it where the player turns invisible and reposition itself to the vehicle, the problem is, I'm pretty much new to all this and I'm not quite sure how to do that, or if that's even the best way of doing this.
I've been following tutorials on Youtube and getting a better understanding as I go, so thanks in advance for helping little 'ol me!
Here's a copy of the vehicle's code:
***CREATE***
***STEP***
And the player's:
***CREATE***
***STEP***
So I'm making this pixel RPG-styled game, anyways, I'm trying to add "vehicles".
I was able to get the vehicle moving and whatnot, the next thing I'm trying to do is have it where my player can enter/exit the said vehicle.
I figure I just make it where the player turns invisible and reposition itself to the vehicle, the problem is, I'm pretty much new to all this and I'm not quite sure how to do that, or if that's even the best way of doing this.
I've been following tutorials on Youtube and getting a better understanding as I go, so thanks in advance for helping little 'ol me!
Here's a copy of the vehicle's code:
***CREATE***
GML:
//movement configs
xspd = 0;
yspd = 0;
move_spd = 2;
sprite[RIGHT] = spr_gatty_wagon_base_right;
sprite[UP] = spr_gatty_wagon_base_up;
sprite[LEFT] = spr_gatty_wagon_base_left;
sprite[DOWN] = spr_gatty_wagon_base_down;
face = RIGHT;
Code:
//direction control movements
right_key = keyboard_check(ord("D")) || keyboard_check(vk_right);
left_key = keyboard_check(ord("A")) || keyboard_check(vk_left);
up_key = keyboard_check(ord("W")) || keyboard_check(vk_up);
down_key = keyboard_check(ord("S")) || keyboard_check(vk_down);
//attack_key = keyboard_check(vk_space);
//get xspd and yspd
xspd = (right_key - left_key) * move_spd;
yspd = (down_key - up_key) * move_spd;
//collision func.
if place_meeting(x + xspd, y, obj_wall) == true
{
xspd = 0;
}
if place_meeting(x, y + yspd, obj_wall) == true
{
yspd = 0;
}
if keyboard_check(ord("E"))
{
riding = true;
//set sprite
mask_index = sprite[RIGHT];
if yspd == 0
{
if xspd > 0 {face = RIGHT};
if xspd < 0 {face = LEFT};
}
if xspd == 0
{
if yspd > 0 {face = DOWN};
if yspd < 0 {face = UP};
}
sprite_index = sprite[face];
//move the gatty wagon
x += xspd;
y += yspd;
//animate
if xspd == 0 && yspd == 0
{
image_index = 0;
}
}
//depth
depth = -bbox_bottom;
***CREATE***
Code:
//health of player
hp = 50;
hp_max = 100;
healthbar_width = 200;
healthbar_hieght = 24;
healthbar_x = 1250 - (healthbar_width/2)
healthbar_y = ystart - 50;
inventory_x = 35;
inventory_y = ystart - 70;
//status
riding = false;
//player's bacon bits
bits = 0;
//player's level
xp = 0;
lvl = 1;
//movement configs
xspd = 0;
yspd = 0;
move_spd = 1;
sprite[RIGHT] = spr_player_right;
sprite[UP] = spr_player_up;
sprite[LEFT] = spr_player_left;
sprite[DOWN] = spr_player_down;
face = DOWN;
Code:
//direction control movements
right_key = keyboard_check(ord("D")) || keyboard_check(vk_right);
left_key = keyboard_check(ord("A")) || keyboard_check(vk_left);
up_key = keyboard_check(ord("W")) || keyboard_check(vk_up);
down_key = keyboard_check(ord("S")) || keyboard_check(vk_down);
//attack_key = keyboard_check(vk_space);
//get xspd and yspd
xspd = (right_key - left_key) * move_spd;
yspd = (down_key - up_key) * move_spd;
//pause
if instance_exists(obj_pauser)
{
xspd = 0;
yspd = 0;
}
//set sprite
mask_index = sprite[DOWN];
if yspd == 0
{
if xspd > 0 {face = RIGHT};
if xspd < 0 {face = LEFT};
}
if xspd == 0
{
if yspd > 0 {face = DOWN};
if yspd < 0 {face = UP};
}
sprite_index = sprite[face];
//collision func.
if place_meeting(x + xspd, y, obj_wall) == true
{
xspd = 0;
}
if place_meeting(x, y + yspd, obj_wall) == true
{
yspd = 0;
}
//move the player
x += xspd;
y += yspd;
//animate
if xspd == 0 && yspd == 0
{
image_index = 0;
}
if riding == true
{
//object_set_visible(obj_player, false);
}
//depth
depth = -bbox_bottom;
Last edited: