RPG Basics Flashcards

1
Q

Adjusting Camera and Viewport

A

Within room properties:

  • enable viewports
  • set viewport[#] to visible
  • set camera properties:
    • 288 x 216 is 4:3 ratio (ex. Undertale), 1920 x 1080 is 16:9 (modern; ex. Hollow Knight)
  • set viewport properties:
    • multiply camera ratio by some whole number
  • -input object for Object Following
  • –set horizontal and vertical borders to half the camera ratio to have the camera stay centered on the followed object when it moves
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Setting Player Speed

A

(create event)

xspd = 0;
yspd = 0;

mv_spd = #;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a create event

A

Used for initializing variables

Runs once when an object is loaded

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a step event

A

Runs every single frame of the game

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Binding Arrow Keys

A

(step event)

//set movement keys
right_key = keyboard_check(vk_right);
left_key = keyboard_check(vk_left);
up_key = keyboard_check(vk_up);
down_key = keyboard_check(vk_down);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Binding WASD Keys

A

(step event)

//set movement keys
d_key = keyboard_check(ord("D"));
w_key = keyboard_check(ord("W"));
a_key = keyboard_check(ord("A"));
s_key = keyboard_check(ord("S"));
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Get X & Y Speed

A

(step event)

//get xspd and yspd
xspd = (right_key - left_key) * mv_spd;
yspd = (down_key - up_key) * mv_spd;

OR

//get xspd and yspd
xspd = (a_key - d_key) * mv_spd;
yspd = (s_key - w_key) * mv_spd;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Moving the Player

A

(step event)

BELOW COLLISIONS

//move the player
x += xspd;
y += yspd;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Setting Collisions

A

(step event)

BELOW SETTING SPRITE

//collisions
if place_meeting( x + xspd, y, obj_wall ) == true
	{
	xspd = 0;
	}
if place_meeting( x, y + yspd, obj_wall ) == true
	{
	yspd = 0;
	}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Setting Sprite

A

(step event)

ABOVE COLLISIONS (else xspd & yspd gets set to 0 and it interferes with changing directional faces properly)

//set sprite
mask_index = sprite[DOWN];
if yspd == 0
	{
	if xspd > 0 {face = RIGHT};
	if xspd < 0 {face = LEFT};
	}
if xspd > 0 && face == LEFT {face = RIGHT};
if xspd < 0 && face == RIGHT {face = LEFT};
if xspd == 0
	{
	if yspd > 0 {face = DOWN};
	if yspd < 0 {face = UP};
	}
if yspd > 0 && face == UP {face = DOWN};
if yspd < 0 && face == DOWN {face = UP};

sprite_index = sprite[face];

  • Lines such as “if xspd > 0 && face == LEFT {face = RIGHT};” fix the issue of sprite faces not adjusting properly if the object goes from not moving to moving at a diagonal
  • “mask_index = sprite[DOWN];” sets all sprite collision masks to the same as the indicated sprite
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Setting Animations

A

(step event)

BELOW COLLISIONS

//animate
if xspd == 0 && yspd == 0
	{
	image_index = 0;
	}

(SET ALL FACE SPRITES TO THE SAME ORIGIN POINT)

Makes an unmoving object stay at indicated image index frame instead of animating

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Setting up Macros (constants)

A

(script)

#macro RIGHT 0
#macro UP 1
#macro LEFT 2
#macro DOWN 3
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Assigning Directional Sprites

A

(create event)

REQUIRES MACRO (else use 0-3)

sprite[RIGHT] = spr_player_right;
sprite[UP] = spr_player_up;
sprite[LEFT] = spr_player_left;
sprite[DOWN] = spr_player_down;

face = DOWN;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Wall Layer

A
  • Place obj_wall in a separate layer from Instances
  • When finished placing walls, turn layer visibility off
  • Adjust obj_wall opacity to not visually obscure parts of rooms
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Parent and Child Objects (& Expanding Collision)

A
  • When setting a parent object for any object, this means anytime the game references/checks the parent object, the game will also reference/check any object that is a child of it
  • Making obj_wall a parent object will then reference the collision coding, allowing collision with child objects without writing them all into the code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Depth Sorting

A

(step event for PLAYER)
(create event for OTHER OBJECTS)

//depth
depth=-bbox_bottom;

bbox is the collision box. this makes the bottom of the collision box a negative number. THE LOWER THE NUMBER, THE HIGHER THE OBJECT DEPTH PRIORITY
Ex. an object at -10 will have their sprite show up on top of an object at -5

17
Q

Objects with the Same Collision Masks (Reducing Clutter)

A
  • If you know multiple objects will have the same collision mask, you can make multiple sprites in the frames of a single sprite and set the fps to 0
  • you can then place the object and change the frame to achieve the sprite you want
18
Q

Room Order

A

Room at the top of the list is where the game will start

19
Q

obj_warp_block (general)

A

(create event)

target_x = 0;
target_y = 0;
target_rm = 0;
target_face = 0;

(step event)

//warp blocks
if place_meeting( x, y, obj_player) && !instance_exists(obj_warp)
	{
	var inst = instance_create_depth( 0, 0, 
        -9999, obj_warp );
	inst.target_x = target_x;
	inst.target_y = target_y;
	inst.target_rm = target_rm;
	inst.target_face = target_face;
	}

Ensure the warp block object is actually touchable by the player when placing it

“var inst” is a local variable (a variable only needed in the one event it’s put into; it won’t be referenced by code outside this event)

“&& !instance_exists(obj_warp)” is to ensure an obj_warp is not created every frame the player is touching the warp block [ “!” means “not” ]. it will only run the code if the warp object does not currently exist.

20
Q

obj_warp_block (placed)

A

Set obj_player to “persistent” by checking box in object options

After placing obj_warp_block, click on it and select “Creation Code”

Add and change the 0s in the following code to desired coordinates, room, and face after warping:

target_x = 0;
target_y = 0;
target_rm = 0;
target_face = 0;

remember to uncheck “visible” when done editing the warp block

21
Q

Creation Code

A

Adds code to every individual instance of the selected object and will run immediately after the create event

22
Q

Warping Between Rooms (obj_warp)

A

Create obj_warp using your room transition animation as the sprite and set it as “persistent”

(create event)

target_x = 0;
target_y = 0;
target_rm = 0;

(step_event)

if room == target_rm && image_index < 1
{
instance_destroy();
}

(draw event)

var _camx = camera_get_view_x(view_camera[0]);
var _camy = camera_get_view_y(view_camera[0]);

draw_sprite_tiled(sprite_index, image_index, _camx, _camy);

(animation end event)

room_goto(target_rm);
obj_player.x = target_x;
obj_player.y = target_y;
obj_player.face = target_face;

image_speed = -1;

setting image_speed to -1 will make the animation play in reverse once the animation has ended

draw_sprite_tiled (rather than draw_sprite) will tile the sprite across the entire room

don’t use if image_index = 0 in the step event because the image index usually has a decimal point to ensure the animation is running at the correct speed

23
Q

obj_pauser (pausing the player during room transitions)

A

in obj_player

(step event)
(between “//get xspd and yspd” and “//set sprite”)

//pause
if instance_exists(obj_pauser)
	{
	xspd = 0;
	yspd = 0;
	}

make obj_pauser the parent object of obj_warp

forces the player’s speed to 0 while obj_pauser exists

24
Q

Parallax Backgrounds

A

Visually disable the “Background” layer

Make a background that is the same size as the camera

Make obj_parallax_background

(create event)

depth = 10000;

(draw event)

var _camx = camera_get_view_x(view_camera[0]);
var _camy = camera_get_view_y(view_camera[0]);

var _p = 1;

draw_sprite_tiled(bg_name, 0, _camx_p, _camy_p);

IF YOU WANT A SUB-IMAGE: draw_sprite_tiled(bg_name, 1, _camx.25, _camy.25);

the lower the number value of var _p, the closer the background will appear

.25 is an example number for the sub image code, it just needs to be >_p

the second variable in draw_sprite_tiled is the sprite frame

25
Q

Parallax Tips & Tricks

A

-Make parts of the background in seperate layers so you can visually enable/disable parts of it as needed per room
–in the draw event code, give each layer it’s own code line and assign each layer it’s own parallax value
(var _p0 =, var _p1 =, etc.)

-To help alleviate tiling issues when the start and end y-axis pixels don’t allign:

  • > cut (ctrl+x) left half of the background
  • > perfectly move the right half over to the left side
  • > paste and place the cut left half on the right side
  • you can now see in the center of the background if there would be any visual tiling issues*
  • > do your best to smoothly connect the halves at the center
  • you can also do this for the top and bottom halves if vertical tiling is the issue*
26
Q

Begin Step & End Step

A

Begin Step will occur before any other object’s step events

End Step will occur after every other object’s step events