/r/gamemaker

Photograph via snooOG

This subreddit is dedicated to providing programmer support for the game development platform, GameMaker Studio. GameMaker Studio is designed to make developing games fun and easy. Coders can take advantage of its built in scripting language, "GML" to design and create fully-featured, professional grade games. This subreddit is not designed for promoting your content and is instead focused on helping people make games, not promote them.

GameMaker is software designed to make developing games easy and fun. It features a unique "Drag-and-Drop" system which allows non-programmers to make simple games. Additionally, experienced coders can take advantage of its built in scripting language, "GML" to design and create fully-featured, professional grade games.

subreddit_guidelines()

Content that does not follow the subreddit guidelines is subject to deletion, so please become familiar with them.

  1. Content must be directly related to GameMaker
  2. Content must be in English
  3. Content must not be obscene, illegal, racist or offensive
  4. Content must not use "click-bait" titles, shortened links, or solicitation
  5. Content must demonstrate a previous effort and research before posting and must provide adequate detailed information
  6. Show respect to all users of the subreddit and have patience with other users when providing help
  7. Promotional content must contribute to the community
  8. Technical support requests are to be directed to YoYo Games Support
  9. Content must be appropriately flaired at the time of submission

community()

Conversation

/r/gamemaker sponsors three chat-rooms: IRC, a Discord server, and a Slack team. Join in the conversation, get help with any issues you might have and connect with your fellow developers! We also have a Steam Group for playing games. Feel free to join.

Scheduled content

Schedule Content Summary
Monday Quick Questions Ask questions, ask for assistance or ask about something else entirely.
Wednesday Game Design & Development Discuss game design and game development.
Friday Feedback Friday Play games and lend feedback
Saturday Screenshot Saturday Share the latest pictures and videos of your game
Monthly Monthly Challenge Are you in need of motivation? Then take a stab at these creative challenges.
Bi-weekly Community Spotlight Shining a light on high-quality projects and resources created by our community.

gm(48)

For more than 8 years, the tight-knit community of /r/gamemaker has run the game jam gm(48) for GameMaker developers of all ages and experience levels. The gm(48) is a casual, fun game jam that helps you to learn and grow as a developer.

The next gm(48) will take place on Oct 20, 2018.

/r/gamemaker

84,051 Subscribers

2

Looking for an additional programmer for a game jam

Hi all! I went through the rules, but regardless, hope it's alright to do team searches on this forum. If not, let me know and I'll take the post down.

Looking for...
We're looking for an additional GameMaker Studio 2 programmer for Fuck Capitalism Jam: https://itch.io/jam/fuck-capitalism-jam-2024

There are two programmers, and we're looking for a third - someone who's willing to play their part in a team and be okay with owning a single piece of the game end-to-end (eg. player, or dialogue).

We are...
You'll be joining a skilled and experienced team of indie devs - see our last game here: https://coinbirdface.itch.io/dreamweaver.

I'm the project manager (and one of the programmers). As of this post, we're a team of 5 (2 programmers, 2 artists, 1 musician). The full team will be ~8 people.
We're all in our late 20s who work and do gamedev alongside. Please note that our standards are relatively high for game jams and we do not compromise just because its a jam.

The game plan...
We're still ideating, so we'd love your contribution and ideas. Tentatively it'll be a narrative-driven top-down mystery game. So programming and design requirements will be less combat/exploration and more dialogue/puzzles/UI.

Ideally you are..
So ideally you'd be in a similar age bracket, you have some experience in GMS2, can commit some time throughout the month for the jam, and have worked on a few jams before, particularly in teams. You don't need to hate capitalism!
This game would be a good experience (I feel) for experienced solo devs who want to work with a larger team, or for people who have done minigames and are looking to add a bigger game to their portfolios.

If you're interested, please shoot me a DM here! Look forward to working with you.

2 Comments
2024/04/30
09:17 UTC

3

Gamemaker code color themes?

Hey guys I just wanted to ask, is it possible to easily change the color themes of gamemakers code editor such as you can in other. Game engines and visual studio?

If not, is there a website that has a theme of color codes that I can use to use my gamemaker theme?

Getting tired of the code colors in gamemaker, but changing it all individually on my own is alot of work and intimidatin

5 Comments
2024/04/29
22:21 UTC

1

+or-

hi, before i ask my question, i speak french so mbd if i dont spell words good.

instance_create_depth(x -+ irandom_range(1,6), y +- irandom_range(1,6), depth, obj_expr);

i want randomise + or - like add or reduce (1 to 6)

4 Comments
2024/04/29
20:28 UTC

1

I Need Help With Text That Appears And Fades!

So I am very new to the world of programing and GM. I am trying to make text appear above my player object indicating different status effects like "you are cold" or "you are warm". I want this text to appear then fade away then appear again when something changes. My problem is the text appears fine initially but after fading once the text wont reappear again. For example when I start the game it says "you are cold" then the text fades and I start a fire now new text should appear saying "you are warm" but it doesn't. Any help with this would be very helpful thank you in advance.

-The Related Code I am using currently-

Obj_Player-
//create event
fade_alpha = 1; // Initial alpha value
fade_speed = 0.02; // Speed at which the text fades

//step event
if (fade_alpha > 0) {
fade_alpha -= fade_speed; // Decrease the alpha value
}

Obj_StatusEffectTextController-
//Draw Event
draw_set_font(Ft_Title)
draw_set_halign(fa_center)
draw_set_valign(fa_bottom)
draw_set_color(c_yellow)

with (Obj_Player) if (cold == true) {
draw_set_alpha(fade_alpha); // Set the alpha value
draw_text(x, y - 45, "You Are Cold");
draw_set_alpha(1); // Reset alpha value for other drawings
} else with (Obj_Player) if (cold == false) {
draw_set_alpha(fade_alpha); // Set the alpha value
draw_text(x, y - 45, "You Are Warm");
draw_set_alpha(1); // Reset alpha value for other drawings
}

8 Comments
2024/04/29
17:31 UTC

1

Quick Questions

Quick Questions

  • Before asking, search the subreddit first, then try google.
  • Ask code questions. Ask about methodologies. Ask about tutorials.
  • Try to keep it short and sweet.
  • Share your code and format it properly please.
  • Please post what version of GMS you are using please.

You can find the past Quick Question weekly posts by clicking here.

3 Comments
2024/04/29
17:00 UTC

0

How to change the window size when playing preview of my game?

The window is tiny when i press the play button how do i change that?

I found some code online but i dont know where to actually put it.

Sorry if dumb.

14 Comments
2024/04/29
10:27 UTC

3

Vector art in Gamemaker?

Hey guys,

I just wanted to know if there's a way to import and make vector art for Gamemaker because every time I import an svg file, it looks too pixelated.

Thank you :]

10 Comments
2024/04/29
05:42 UTC

3

Not sure how to destroy textbox in sequence

I would like to destroy the textbox in my sequence at a certain point using broadcast messages. Creating the textbox works perfectly, however I have had a tough time getting it to be destroyed. The "destroy" case is what is supposed to destroy the textbox, what I have there currently is one of my attempts at doing it, however it does not work. Below is my broadcast message event.

if event_data[? "event_type"] == "sequence event"

{

switch (event_data[? "message"])

{

case "wake up whispy":

create_textbox(text_id);

break;

	case "destroy":

instance_destroy();

break;

}

}

6 Comments
2024/04/29
03:32 UTC

13

How can i make a character sprite be drawn entirely red?

I tried using draw_sprite_ext(), but the black pixels arent becoming red, how can i make ALL pixels become red?

https://preview.redd.it/34rxryd3rbxc1.png?width=1070&format=png&auto=webp&s=305d612721d5c24830acc7f15e9222e0110d627c

15 Comments
2024/04/29
01:52 UTC

2

Is there any way to move multiple layers in the sprite editor at the same time?

I’m trying to make stuff and I’ve always wanted to be able to just move the different layers all at once but it seems there’s not a way to do that.

2 Comments
2024/04/29
00:06 UTC

1

looking for help with a push block on ice

im trying to follow petyon's tutorial for this,

https://www.youtube.com/watch?v=Fpn5dBAC7Oc&list=PL14Yj-e2sgzySnBUlQLhq2VJXRLi66gFf&index=8&t=32s

and everything is going prefect until i get to this

	//ice sliding - if on ice then keep adding co-ordinates until edge of ice or wall
	if onIce == true
	{
		//reset our targetX and targetY
		targetX = startpointX;
		targetY = startpointY;
		
		//search each space ahead to make sure there IS ice, and NOT a wall
		while place_meeting( targetX + _targetXDist, targetY + _targetYDist, obj_slideground )
		&&   !place_meeting( targetX + _targetXDist, targetY + _targetYDist, obj_collision )
		{
			targetX += _targetXDist;
			targetY += _targetYDist;
		}
	}

specifically

&& !place_meeting( targetX + _targetXDist, targetY + _targetYDist, obj_collision )

when i turn this on, the blocks on the slide ground (ice) seem to no longer move by 32 pixels anymore, and if i keep moving, they stop moving.

if that part is turned off, they behave perfectly unless theres something thats a child of obj_collision (wall) to run into. as expected.

i dont understand what is breaking when i turn on the part where its also checking for a collision.

pushblock create event
moveX = 0;
moveY = 0;

movespd = 3;

faceDir = RIGHT;

//how far we need to move
gridspace = 32;

startpointX = x;
startpointY = y;
targetX = x;
targetY = y;


// the state we are in
sliding = false;

pushblockArea = false;

onIce = false;

// the entire pushblock step event

//what state are we in
    // idle / not sliding
if sliding == false
{
	//set starting co-ordinates
	startpointX = x;
	startpointY = y;
	
	//reset movement speed
	moveX = 0;
	moveY = 0;	
}

// get ground type
	//inside the pushblock area
//get ground type
if place_meeting(x, y, obj_pushblock_area)
{
	pushblockArea = true;
} else {
	pushblockArea = false;
}

//we're on ice
if place_meeting(x, y, obj_slideground)
{
	onIce = true;
} else {
	onIce = false;
}


//sliding
if sliding == true
{
	//get the actual 360 degree direction we should move in
	var _realDir = faceDir * 90;
		
	//get target co-ordinates
	var _targetXDist = lengthdir_x(gridspace, _realDir);
	var _targetYDist = lengthdir_y(gridspace, _realDir);
	targetX = startpointX + _targetXDist;
	targetY = startpointY + _targetYDist;
	
	//ice sliding - if on ice then keep adding co-ordinates until edge of ice or wall
	if onIce == true
	{
		//reset our targetX and targetY
		targetX = startpointX;
		targetY = startpointY;
		
		//search each space ahead to make sure there IS ice, and NOT a wall
		while place_meeting( targetX + _targetXDist, targetY + _targetYDist, obj_slideground )
		//&&   !place_meeting( targetX + _targetXDist, targetY + _targetYDist, obj_collision )
		{
			targetX += _targetXDist;
			targetY += _targetYDist;
		}
	}
	
	// set the speeds
	var _targetDist = point_distance( x, y, targetX, targetY );
	var _finalSpd = min( movespd, _targetDist );
	moveX = lengthdir_x( _finalSpd, _realDir );
	moveY = lengthdir_y( _finalSpd, _realDir );
	
	//cancel movement if we are in a push block area but the target co-ordinates are not	
	if pushblockArea == true && !place_meeting(targetX, targetY, obj_pushblock_area)
	{
		moveX = 0;
		moveY = 0;
	}
	// dont let the block move to a grid space with a wall in it
	if(place_meeting(targetX, targetY, obj_collision)){
		moveX = 0;
		moveY = 0;
	}
	// done with sliding

	if(moveX == 0 && moveY == 0){
		sliding = false;
	}

}


// movement
x += moveX;
y += moveY;



in my player create  event i have
face = RIGHT;

interactDist = 4;

// my entire player step event
// declare input buttons

input_right    = input_check("right");
input_left     = input_check("left");	
input_down     = input_check("down");
input_up	   = input_check("up");
input_walk	   = input_check_long("walk");
input_run	   = input_check_long("run");
input_interact = input_check_pressed("interact");

//turn off movement while talking to people
if(instance_exists(obj_textbox) || obj_inventory_menu.show_inventory_menu = true){exit;}


//interacting with pushblocks
#region pushblocks
if (input_interact){
	
	// find the direction to check for pushblocks
	var _checkDir = face * 90;
	
	// see if we find a pushblock
	var _checkX = x + lengthdir_x(interactDist, _checkDir);
	var _checkY = y + lengthdir_y(interactDist, _checkDir);
	var _pushblockInst = instance_place(_checkX, _checkY, obj_pushblock);
	
	// if there is a push block then tell it to slide and what direction to slide
	if (instance_exists(_pushblockInst) && _pushblockInst.sliding == false){
		_pushblockInst.sliding = true;
		_pushblockInst.faceDir = face;
	}
	
}



#endregion


#region movement
//  alter speed
if (input_walk || input_run){spd = abs((input_walk*w_spd) - (input_run*r_spd));}
else			            {spd = n_spd;}

//reset movement variables
moveX = 0;
moveY = 0;

//preventing diagonal movement
inputDirection = point_direction(0, 0, input_right - input_left, input_down - input_up);
inputMagnitude = (input_right - input_left != 0) ||(input_down - input_up != 0);

moveX = lengthdir_x(inputMagnitude*spd, inputDirection);
moveY = lengthdir_y(inputMagnitude*spd, inputDirection);



// get direction player is facing
if (moveX != 0){
	switch(sign(moveX)){
		case 1 : facing = dir.right; face = RIGHT; break;		
		case -1 : facing = dir.left; face = LEFT; break;		
	}
} else if (moveY != 0){
	switch(sign(moveY)){
		case 1 : facing = dir.down; face = DOWN; break;		
		case -1 : facing = dir.up; face = UP; break;		
	}
} else {
	facing = -1;
}
#endregion

//check collision
#region collision
		//horizontal
if(moveX !=0){	
	var _collisionH = instance_place(x+moveX, y, obj_collision);
	if (_collisionH != noone && _collisionH.collidable == true){
		repeat(abs(moveX)){
			if (!place_meeting(x+sign(moveX), y, obj_collision)){
				x += sign(moveX);
			} else{
				break;
			}
		}
		moveX = 0;
	}
}
    //vertical
if (moveY !=0){	
	
	var _collisionV = instance_place(x, y+moveY, obj_collision);
		if (_collisionV != noone && _collisionV.collidable == true){
		repeat(abs(moveY)){
			if (!place_meeting(x, y+sign(moveY), obj_collision)){y += sign(moveY);} 
			else{ break;}
		}
		moveY = 0;
	}
}	
#endregion


// transitions
#region transitions
var _inst = instance_place(x, y, obj_transition);
if (_inst != noone && facing == _inst.playerFacingBefore){ 
	with(obj_system_control){
		if(!doTransition){
			spawnRoom = _inst.targetRoom;
			spawnX = _inst.targetX;
			spawnY = _inst.targetY;
			spawnPlayerFacing = _inst.playerFacingAfter;
			doTransition = true;
		}
	}
}
#endregion

// textbox
#region textbox
if(input_interact){
	if(active_textbox == noone){
		var inst = collision_rectangle(x-radius, y-radius, x+radius, y+radius, par_npc, false, false);
		if(inst != noone){
			with(inst){
				var tbox = Create_Textbox(text, speakers, next_line, scripts);
				can_move = false;
				moveX = 0; moveY = 0;
			}
			active_textbox = tbox;
			
		}
		
	} else {
		if(!instance_exists(active_textbox)){
			active_textbox = noone;
		}
	}
}
#endregion


	// apply movemoent
	x += moveX;
	y += moveY;
	

0 Comments
2024/04/28
23:04 UTC

4

Gamemodes in Gamemaker?

Hey guys,

I wanted to know if there's a good and simple way to make different "gamemodes" such as the ship or ball from Geometry Dash without using something like:

if gamemode == "ship" { //code }

if gamemode == "ball" { //code }

I basically want to avoid using strings if that's possible

Thank you!!

17 Comments
2024/04/28
19:33 UTC

1

help needed to an very specific problem

I need help to a very specific problem... I need to set a value depending on a specific time as long as press a button. For example: If i press "j" for 0.25 second and the value for "j" will be set to 500 after that i press k for 0.25 seconds it will be set to 500 for "k" i need it automatically to be calculated and the max should be set to 0.5 seconds or so (1 second is ok to need to think ab it and try it out)

sorry for my bad English :)

1 Comment
2024/04/28
17:57 UTC

2

How can I check for a collision between a line and a grid?

I am working on a top down game.

I placed a lot of obj_solid everywhere the player or other entities such as enemies shouldn't go.
These are turned into an mp_grid in my obj_game during the room start event. The main purpose is to allow basic ai pathfinding for enemies which works flawlessly.

No I have two issues:

My enemies have a vision cone. They should only see the obj_player if it is in range AND visible (not behind a obj_solid. I am currently handling this via a collision_line between the enemy and the player, I would love to delete the obj_solid though since they really lag my game once I polace thousands of them. Is there a way to check if the collision_line collides with my mp_grid?

The same of course goes for the obj_player and the mp_grid collision.

I googled for hours but couldn't find anything. I would really appreciate some help! Thank you :)

10 Comments
2024/04/28
16:38 UTC

1

I know the answer to this has to be so basic, please show me what I am missing

Thisi s a frustrating question to ask, because I have Googled it and checked the subreddit... other people have figured out instances similar to mine, but I can't find an answer for my exact situation. I have checked the manual, and my methodology seems sound here so I really don't know what I'm doing wrong. I guarantee the answer is dumb and simple and I just missed something very basic. I am new to coding entirely, so thank you in advance for being patient with me.

I want an object in a room to play it's animation (the frames contained within it's image_index) when the player makes contact with it. That's it.

In the Create event for the object in question, I have :

image_speed = 0;

In the Step event for the object in question, I have:

if place_meeting (x,y,obj_player)
{
image_speed = 1
}

The object is parented to an object I use for all my collision code. The collision code for the player is as follows:

//collisions
if place_meeting( x + xspd, y, collideparent ) == true
{
xspd = 0;
}
if place_meeting( x, y + yspd, collideparent ) == true
{
yspd = 0;
}

My game starts and runs with no errors. When my player sprite makes contact with the object sprite, nothing happens. BUT, the frames in the image_index are not constantly cycling, so I at least know that the line in my Create event is written correctly.

It is frustrating because I am using a similar structure for an invisible object that I use to warp my character in between rooms, and the "if place_meeting" setup I have here works perfectly for that.

What am I doing wrong? Thanks in advance!

19 Comments
2024/04/28
15:50 UTC

1

Need help with some code for my game.

I am having issues with some code in my game. Basically I have five cards on my board. I want to be able to pick one up and then lay it face down in a specific spot on the board. I've got it to where I can move the card and lay it facedown. I even am able to flip it face up. My problem is that every time I click my mouse after that the card keeps moving. I have to be able to pick up and move other cards without that one coming to my mouse. Here is the code I am using:

// Initialize the held flag

if (!variable_global_exists("is_held")) {

global.is_held = false;

}

// Check if left mouse button is held down

if (mouse_check_button_pressed(mb_left))

{

// Set the held flag only if it's not already held

if (!global.is_held) {

global.is_held = true;

// Move the card to the mouse position

x = mouse_x;

y = mouse_y;

// Display debug message

show_debug_message("Moving to mouse");

}

}

// Move the card if it's held

if (global.is_held)

{

// Move towards mouse pointer

x = mouse_x;

y = mouse_y;

}

// Check if left mouse button released

if (mouse_check_button_released(mb_left))

{

// Snap to mouse position

x = mouse_x;

y = mouse_y;

// Face down

image_index = 1;

// Reset the held flag

global.is_held = false;

// Display debug message

show_debug_message("Snapped and faced down");

}

// Check if space is released

if (keyboard_check_released(vk_space))

{

// Turn the card face up

image_index = 0;

// Display debug message

show_debug_message("Turned face up");

}

I'd really appreciate any help I can get. TIA.

2 Comments
2024/04/28
10:45 UTC

1

Trying to check collition for a different image_scale

Hi! I'm trying to figure out how to approach this problem: I want to check if a collition with an object called ParBlockSolid is found on a 2D platformer, I'm aware of both instance_place and place_meeting functions (also the collition_rectangle and that kind of functions), but the issue is that I have a mechanic that makes the player object called ObjPlayer half both it's image_xscale and image_yscale, this result in a problem that if the player "grows" in a place where is a ParBlockSolid instance it get stuck into it, is there anyway to check a colition as how place_meeting does but using i.e. the double image_xscale and image_yscale? Thanks in advance for reading

P.D. I'm using GMS 2, the steam version.

Edit: what I'm trying to say is that the more suitable solution that I have think so far is to not let the player "grow" in the first place if a collition with the size he is going to grow is found, that's why I said before that I'm trying to figure out a place_meeting kind of solution in order to place it into an "if(!place_meeting(x,y,ParBlockSolid)){grow();}".

10 Comments
2024/04/28
09:35 UTC

2

Resource is inconsistent with the list type expected

I'm a new coder on this engine and was using a tutorial to start me off, but while making a build to playtest, it failed and I got this error message, I want to know what it means so I can fix it

3 Comments
2024/04/28
06:22 UTC

2

How can i check which side of the sprite a point direction is aiming?

Basically im making a laser that works with a for loop which then draws the laser until it collides with an object, but i want to add a reflection to that laser, but i dont know how to use point_direction to make the second laser know which side of a wall it is colliding with.

4 Comments
2024/04/27
22:51 UTC

1

Pressing enter destroys my textbox but I'm not sure why?

For my games cutscene's I have textboxes that are drawn. However, pressing the enter key will destroy it. I've been looking for a while but am not able to figure out why. I have two different textbox objects, one for interacting with objects, and one for cutscenes. The one for objects DOES make it so that you can get to the next page of dialogue/skip dialogue, while the cutscene one has all instances of the enter key removed. I can give the code for both the object interaction and cutscene one. However, I believe the cutscene textbox object would make the most sense to put here.

Create:

depth = -9999

//textbox parameters

textbox_width = 887;

textbox_height = 250;

border = 8;

line_sep = 55;

line_width = textbox_width - 11 - border*2;

textb_spr[0] = Spr_textbox;

textb_img = 0;

textb_img_spd = 0;

setup = 0;

textbox_x = true;

textbox_y = true;

//the text

page = 0;

page_number = 0;

text[0] = ""

text_length[0] = string_length(text[0]);

char[0, 0] = "";

char_x[0, 0] = 0;

char_y[0, 0] = 0;

draw_char = 0;

text_spd = 1;

//options

option[0] = "";

option_link_id[0] = -1;

option_pos = 0;

option_number = 0;

setup = false;

//sound

snd_delay = 3;

snd_count = snd_delay;

//effects

scr_set_deafaults_for_text();

last_free_space = 0;

text_pause_timer = 0;

text_pause_time = 16;

Draw GUI:

//down or normal textbox

if down_textbox == true

{

textbox_x = display_get_gui_width()*-0.2;

textbox_y = display_get_gui_height()*0.65;

}

if down_textbox == false

{

textbox_x = display_get_gui_width()*-0.2;

textbox_y = display_get_gui_height()*0.0;

}

//setup

if setup == false

{

setup = true;

draw\_set\_font(global.font\_main);

draw\_set\_valign(fa\_top);

draw\_set\_halign(fa\_left);





//loop through the pages

for(var p = 0; p < page\_number; p++)

{

	//find how many characters are on each page and store that number in the "text\_length" array

	text\_length\[p\] = string\_length(text\[p\]);

	

	//find the x position for the textbox

	//character on left

	text\_x\_offset\[p\] = 662;

	portrait\_x\_offset\[p\] = 282;

	//character on the right

	if speaker\_side\[p\] == -1 {

		text\_x\_offset\[p\] = 95;

		portrait\_x\_offset\[p\] = 864;

	}

	

	//no character (center the textbox)

	if speaker\_sprite\[p\] == noone {

		text\_x\_offset\[p\] = 44;

	}

	

	//setting individual characters and finding where the lines of text should break

	for (var c = 0; c < text\_length\[p\]; c++)

	{

		var \_char\_pos = c+1;

		

		//store individual characters in the "char" array

		char\[c, p\] = string\_char\_at(text\[p\], \_char\_pos);

		

		//get current width of the line

		var \_txt\_up\_to\_char = string\_copy (text\[p\], 1, \_char\_pos);

		var \_current\_txt\_w = string\_width(\_txt\_up\_to\_char) - string\_width(char\[c, p\]);

		

		//Get the last free space

		if char\[c, p\] == " "{last\_free\_space = \_char\_pos+1};

		

		//Get the line breaks

		if \_current\_txt\_w = line\_break\_offset\[p\] > line\_width

		{

line_break_pos[ line_break_num[p], p ] = last_free_space;

line_break_num [p]++;

var _txt_up_to_last_place = string_copy( text[p], 1, last_free_space);

var _last_free_space_string = string_char_at(text[p], last_free_space);

line_break_offset[p] = string_width (_txt_up_to_last_place) - string_width(_last_free_space_string);

		}

		

		

	}

	

	//Getting each characters cordinates

	for (var c = 0; c < text\_length\[p\]; c++;)

	{

		var \_char\_pos = c+1;

		var \_txt\_x = textbox\_x + text\_x\_offset\[p\] + border;

		var \_txt\_y = textbox\_y + border;

		//get current width of the line

		var \_txt\_up\_to\_char = string\_copy (text\[p\], 1, \_char\_pos);

		var \_current\_txt\_w = string\_width(\_txt\_up\_to\_char) - string\_width(char\[c, p\]);

		var \_txt\_line = 0;

		

		//compensate for string breaks

		for (var lb = 0; lb < line\_break\_num\[p\]; lb++)

		{

//if the current looping character is after a line break

if _char_pos >= line_break_pos[lb, p]

{

var _str_copy = string_copy( text[p], line_break_pos[lb, p], _char_pos-line_break_pos[lb, p]);

_current_txt_w = string_width(_str_copy);

//Record the "line" this character should be on

_txt_line = lb+1;// +1 since lb starts at 0

}

		}

		

		//add to the x and y cordinares base on the new info

		char\_x\[c, p\] = \_txt\_x + \_current\_txt\_w;

		char\_y\[c, p\] = \_txt\_y + \_txt\_line\*line\_sep;

		

	}

	

}

}

//typing the text

if text_pause_timer <= 0

{

if draw_char < text_length[page]

{

draw\_char += text\_spd;

draw\_char = clamp(draw\_char, 0, text\_length\[page\]);

var \_check\_char = string\_char\_at(text\[page\], draw\_char);

if \_check\_char == "." ||  \_check\_char == "?" ||  \_check\_char == "!"



{

text_pause_timer = text_pause_time;

if !audio\_is\_playing(snd\[page\]) {

	audio\_play\_sound(snd\[page\], 8, false);

} 

}



else

{

	//typing sound

	if snd\_count < snd\_delay {

		snd\_count++;

	} else {

		snd\_count = 0;

		audio\_play\_sound(snd\[page\], 8, false);

	}

}

}

}

else {

text\_pause\_timer--;

}

//if the typing is done

if draw\_char == text\_length\[page\]

{

	//next page

	if page < page\_number-1

	{

		page++

		draw\_char = 0;

	}

	//destroy textbox

	else

	{

		//link text for options

		if option\_number > 0 {

create_textbox(option_link_id[option_pos]);

		}

		instance\_destroy();

	}

}

//if not done typing

else

{

	draw\_char = text\_length\[page\];

}

//draw the textbox

var _textb_x = textbox_x + text_x_offset[page];

var _textb_y = textbox_y;

textb_img += textb_img_spd;

textb_spr_w = sprite_get_width(textb_spr[page]);

textb_spr_h = sprite_get_height(textb_spr[page]);

//draw the speaker

if speaker_sprite[page] != noone

{

sprite\_index = speaker\_sprite\[page\];

if draw\_char == text\_length\[page\] {image\_index = 0};

var \_speaker\_x = textbox\_x + portrait\_x\_offset\[page\];

if speaker\_side\[page\] == -1 {\_speaker\_x += sprite\_width}

//draw the speaker

draw\_sprite\_ext(textb\_spr\[page\], textb\_img, textbox\_x + portrait\_x\_offset\[page\], textbox\_y, sprite\_width/textb\_spr\_w, sprite\_height/textb\_spr\_h, 0, c\_white, 1);

draw\_sprite\_ext(sprite\_index, image\_index, \_speaker\_x, textbox\_y, speaker\_side\[page\], 1, 0, c\_white, 1);

}

//back of the textbox

draw_sprite_ext(textb_spr[page], textb_img, _textb_x,_textb_y, textbox_width/textb_spr_w, textbox_height/textb_spr_h, 0, c_white ,1);

//options

if draw_char == text_length[page] && page == page_number -1

{

 //option selection

 option\_pos += keyboard\_check\_pressed(vk\_down) - keyboard\_check\_pressed(vk\_up);

 option\_pos = clamp(option\_pos, 0, option\_number-1);

 

//draw the options

var \_op\_space = 15;

var \_op\_bord = 4;

for (var op = 0; op < option\_number; op++)

{

	//the option box

	var \_o\_w = string\_width(option\[op\]) + \_op\_bord\*2;

	draw\_sprite\_ext(textb\_spr\[page\], textb\_img, \_textb\_x + 16, \_textb\_y - \_op\_space\*option\_number + \_op\_space\*op, \_o\_w/textb\_spr\_w, (\_op\_space-1)/textb\_spr\_h, 0, c\_white, 1);

//the arrow

if option_pos == op

{

draw\_sprite(Spr\_WIP\_arrow, 0, \_textb\_x,\_textb\_y - \_op\_space\*option\_number + \_op\_space\*op);

}

//the option text

	draw\_text(\_textb\_x + 16 + \_op\_bord, \_textb\_y - \_op\_space\*option\_number + \_op\_space\*op + 2, option\[op\]);

}

}

//draw the text

for(var c = 0; c < draw_char; c++)

{

//the text

draw\_text(char\_x\[c, page\], char\_y\[c, page\], char\[c, page\]);

}
7 Comments
2024/04/27
20:35 UTC

0

When making a account does your projects save when you use another devicd?

What I am trying to say is that when you use one device and you want to you another, when you are log in does your stuff from the other device to into the device you want to use? Or do I have to use a flash drive to transfer my data?

6 Comments
2024/04/27
19:52 UTC

2

How to draw a sprite in a perfect curve from a start point to an end?

Hello. I'm looking for a way to simply draw a sprite with a curve via a y offset from its start coordinate that increases until it peaks at the half way point and then decreases down to 0 when it reaches its end coordinate.

Very simply I'm trying to achieve this effect here: https://i.imgur.com/xuvpZXR.png

I'm using Game Maker 1.4 by the way, but that shouldn't matter too much.

2 Comments
2024/04/27
18:19 UTC

1

How to stop Slopes from crushing my Player?

Been following Peyton Burnham's tutorials on 2d Platformers, and have run into an issue where "Only when I walk up a Slope, my player is getting crushed and I do not know why". I can't identify exactly where in my code I've gone wrong.

The code in question:

//X collision

var _subPixel = .5;

if place_meeting( x + xspd, y, TileTerrain )

{

//check if there is a slope to go up

if !place_meeting( x + xspd, y - abs(xspd)-7.5, TileTerrain )

{

while place_meeting( x + xspd, y, TileTerrain ) { y -= _subPixel; };

}

else

//Check for ceiling slope, otherwise, regular collision

{

//Ceiling Slopes

if !place_meeting( x + xspd, y + abs(xspd)+7.5, TileTerrain)

{

while place_meeting( x + xspd, y, TileTerrain) { y += _subPixel; };

}

//Normal collision

else

{

//stop at wall

var _pixelCheck = _subPixel * sign(xspd);

while !place_meeting( x + _pixelCheck, y, TileTerrain ){ x += _pixelCheck; }

//Set xspd to zero to collide

xspd = 0;

}

}

}

//Go Down Slopes

downSlopeSemiSolid = noone;

if yspd >= 0 && !place_meeting( x = xspd, y + 1, TileTerrain ) && place_meeting( x + xspd, y + abs(xspd)+1, TileTerrain )

{

//Check for a semisolid in the way

downSlopeSemiSolid = checkForSemiSolidPlatform( x + xspd, y + abs(xspd)+1, TileTerrain );

//precisely move down slope if there isn't a semisolid in the way

if !instance_exists(downSlopeSemiSolid)

{

while !place_meeting( x + xspd, y + _subPixel, TileTerrain ) {y += _subPixel; };

}

}

//Y collision and movement

//cap falling speed

if yspd > termVel { yspd = termVel };

// Upwards collison (with Ceiling Slopes)

if yspd < 0 && place_meeting( x, y + yspd, TileTerrain )

{

//jump into Sloped ceilings

var _slopeSlide = false;

//slide up left slope

if moveDir == 0 && !place_meeting( x - abs(yspd)-1, y + yspd, TileTerrain )

{

while place_meeting( x, y+yspd, TileTerrain ) { x -= 1; };

_slopeSlide = true;

}

//slide up right slope

if moveDir == 0 && !place_meeting( x - abs(yspd)-1, y + yspd, TileTerrain )

{

while place_meeting( x, y + yspd, TileTerrain ) { x += 1; };

_slopeSlide = true;

}

//Normal Y collision

if !_slopeSlide

{

//stop at wall

var _pixelCheck = _subPixel * sign(yspd);

while !place_meeting( x, y + _pixelCheck, TileTerrain )

{

y += _pixelCheck;

}

//Bonk code

//if yspd < 0 { jumpHoldTimer = 0; };

//Set yspd to 0 to collide

yspd = 0;

}

}

//Downwards collision

//Check for solid and semisolid platforms under me

var _clampYspd = max( 0, yspd );

var _list = ds_list_create(); //Create a DS list to store all of the objects we run into

var _array = array_create(0);

array_push( _array, TileTerrain, TileSemiSolidTerrain );

//do the actual check and add objects to list

var _listSize = instance_place_list( x, y+1 + _clampYspd + moveplatMaxYspd, _array, _list, false );

//loop through the colliding instances and only return one if it's top is below the player

for( var i = 0; i < _listSize; i++ )

{

// Get an instance of TileTerrain or TileSemiSolidTerrain from the list

var _listInst = _list[| i];

//Avoid magnetism

//if //(_listInst != forgetSemiSolid

if ( _listInst.yspd <= yspd || instance_exists(myFloorPlat)

&& ( _listInst.yspd > 0 || place_meeting( x, y+1 + _clampYspd, _listInst) ) )

//|| ( _listInst == _semiSolid )

{

//Return a Solid wall or any Semisolid Walls below the player

if _listInst.object_index == TileTerrain

|| object_is_ancestor( _listInst.object_index, TileTerrain )

|| floor ( bbox_bottom ) <= ceil( _listInst.bbox_top - _listInst.yspd )

{

//Return the "highest" wall object

if !instance_exists(myFloorPlat)

|| _listInst.bbox_top + _listInst.yspd <= myFloorPlat.bbox_top + myFloorPlat.yspd

|| _listInst.bbox_top + _listInst.yspd <= bbox_bottom

{

myFloorPlat = _listInst;

}

}

}

}

//Destroy the DS list to avoid a memory leak

ds_list_destroy(_list);

//Downslope semisolid for making sure we don't miss semisolids while going down slopes

if instance_exists(downSlopeSemiSolid) { myFloorPlat = downSlopeSemiSolid };

//one last check to make sure the platform is actually below us

if instance_exists(myFloorPlat) && !place_meeting( x, y + moveplatMaxYspd, myFloorPlat)

{

myFloorPlat = noone;

}

//Land on the ground platform if there is one

if instance_exists(myFloorPlat)

{

//stop at wall

while !place_meeting( x, y + _subPixel, myFloorPlat ) && !place_meeting( x, y, TileTerrain ) { y += _subPixel; };

//make sure we don't end up below the top of a semisolid

{

while place_meeting( x, y, myFloorPlat ) { y -= _subPixel; };

}

//Floor the Y variable

y = floor(y);

//Set yspd to 0 to collide

yspd = 0;

setOnGround(true);

}

//Final moving platform collisions and movement

//X - moveplatxspd and collison

//Get the moveplatxspd

moveplatXspd = 0;

if instance_exists(myFloorPlat) { moveplatXspd =myFloorPlat.xspd; };

//Move with moveplatxspd

if !earlyMovePlatXspd

{

if place_meeting( x + moveplatXspd, y, TileTerrain )

{

//stop at wall

var _subPixel = .5;

var _pixelCheck = _subPixel * sign(moveplatXspd);

while !place_meeting( x + _pixelCheck, y, TileTerrain )

{

x += _pixelCheck;

}

}

}

// Y - Snap myself to myFloorPlat if it's moving vertically (un floor y variable)

if instance_exists(myFloorPlat)

&& (myFloorPlat.yspd != 0

||myFloorPlat.object_index == TileMovingTerrain

||object_is_ancestor(myFloorPlat.object_index, TileMovingTerrain)

|| myFloorPlat.object_index == TileSemiSolidMoveTerrain

|| object_is_ancestor(myFloorPlat.object_index, TileSemiSolidMoveTerrain) )

{

//Snap to the top of the floor platform

if !place_meeting( x, myFloorPlat.bbox_top, TileTerrain )

&& myFloorPlat.bbox_top >= bbox_bottom-moveplatMaxYspd

{

y = myFloorPlat.bbox_top;

}

/*/going up into a wall while on a semisolid platform

if myFloorPlat.yspd < 0 && place_meeting(x, y + myFloorPlat.yspd, TileTerrain)

{

//get pushed down through the semisolid floor platform

if myFloorPlat.object_index == TileSemiSolidTerrain || object_is_ancestor( myFloorPlat.object_index, TileSemiSolidTerrain )

{

//get pushed down throughh the semisolid

while place_meeting( x, y+myFloorPlat.yspd, TileTerrain ) { y += _subPixel; };

//If we got pushed into a solid wall while going downwards, push ourselves back out

while place_meeting( x, y, TileTerrain ) { y -= _subPixel; };

y = round(y);

}

//Cancel the myFloorPlat variable

setOnGround(false);

}/*/

}

//Get pushed down through a semisolid by a moving Solid platform

if instance_exists(myFloorPlat)

&& ( myFloorPlat.object_index == TileSemiSolidTerrain || object_is_ancestor(myFloorPlat.object_index, TileSemiSolidTerrain) )

&& place_meeting( x, y, TileTerrain )

{

//If I'm already stuck in a wall at this point, try and move me down to get below a semisolid

//If I'm still stuck afterwards, that just means I've been properly "crushed"

//Also, don't check too far, we don't want to warp below walls

var _maxPushDist = 10; //fastest move downwards

var _pushedDist = 0;

var _startY = y;

while place_meeting( x, y, TileTerrain) && _pushedDist <= _maxPushDist

{

y++;

_pushedDist++;

}

//forget my floorplat

myFloorPlat = false;

//if I'm still in a wall at this point, take me back to start

if _pushedDist > _maxPushDist { y = _startY; };

}

So as a complete novice, what can I do to fix this?

7 Comments
2024/04/27
14:19 UTC

8

Where do you use Sequences?

It's been a while since the sequence functionality was released in GameMaker and as far as I can remember I have only used it once for animating the the game title's entrance.

As far as my imagination goes, I think it is best used for cutscenes and user interfaces, maybe? but I was wondering how and where you guys use this feature.

13 Comments
2024/04/27
13:13 UTC

2

problems with draw clear alpha

hey everyone.

for some reason draw clear alpha always gives me problems, i read its page on the documentation probably over 20 times at this point but i guess the more technical side of rendering isn't my strong suit as I haven't really sat down to learn it properly from scratch.

this time I have a character that is drawn onto a surface that is initialized like so:

var _cutoff_sur = surface_create(GUI_W,GUI_H);
surface_set_target(_cutoff_sur)
draw_clear_alpha(c_white,0)

the character is then drawn to the surface normally:

//draw main sprite
draw_sprite_ext(sprite_index,image_index, _x-_xoff*.3, _y-_yoff*.3, _xs,_ys, image_angle,_sprite_color,trans_prec);

while trans_prec being a value that is equal to 1 at this moment, i made sure.
i then redraw the character on top using a silhouette shader and a variable alpha:

//draw flashes
if(flash_a > 0)
{
shader_set(sh_silhouette);
var _col_arr = [color_get_red(color)/255,color_get_green(color)/255,color_get_blue(color)/255]
shader_set_uniform_f_array(flash_uni,_col_arr);
shader_set_uniform_f(flash_alpha_uni,min(trans_prec,flash_a,flash_max_opcaity));

draw_sprite_ext(sprite_index,image_index,_x-_xoff*.3, _y-_yoff*.3,
_xs,_ys,image_angle,c_white,1);

shader_reset();
}

but unfortunately when the flash alpha is low, it drops the alpha of the entire sprite, as if the original sprite draw underneath is ignored. it worked fine until i added the big surface that is created at the start, and i know that its happening because the draw clear alpha somehow sets a different kind of blending mode i think, anyway it takes a alpha of the flashed draw and uses it as the final alpha of the pixel.

what can i do to avoid it and make these draws act like they do normally when using the application surface? ive gone through some gpu functions and read some documentation but i cant find what i need.

here is the shader:

varying vec2 v_vTexcoord;
varying vec4 v_vColour;

uniform vec3 new_col;
uniform float alpha;

void main()
{
    gl_FragColor = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord );
gl_FragColor.rgb = new_col;
gl_FragColor.a = min(gl_FragColor.a,alpha);
}
9 Comments
2024/04/27
13:01 UTC

0

Games

How do I import a pre made game into game maker need it for a project

7 Comments
2024/04/27
06:49 UTC

1

cant make a object center in the camera

im making a rpg game where there is fights, when you touch a enemy it brings you to a blank room and stops player movement and shows a gui. i was making this box that needs to be in the direct center of the screen but i just cant figure it out. ive tried all the things that make it center ( camera_get_view_x(view_camera[0]) ), doing that divided by 2, camera_get_view_width, that divided by 2. nothing.

the only way i could make it kind of close was was doing "boxx = camera_get_view_width(view_camera[0])/2 + (scalex/4);" and "boxy = 203;" but it seems to be slightly off everytime and ive tried adjusting it by screenshotting and then looking in paint.net but it just wont work.

if it helps, this is what im using to draw the box "draw_sprite_ext(sMenubox,0,boxx,boxy,scalex/sprite_get_width(sMenubox),scaley/sprite_get_height(sMenubox), 0, c_white, 1);", the scales are 100, the camera width height is 320 x 240 and the screen width height is 640 x 480.

3 Comments
2024/04/26
23:34 UTC

Back To Top