Windows Confused about collisions

D

DistressedGhost

Guest
Hello!

I'm very new to game maker. I am trying my best to learn via videos and experimenting, but I'm afraid I'm just not sure what exactly the terms are for what I'm trying to find out.

I created these backgrounds and the character sprite in them. (The sprite is just there as an example, it is not actually a part of the background in Game maker).



From what I've gathered, one would usually create (make/add?? I am not entirely sure how it's referred to) collision detection is by editing the physics of the tiles, but I didn't create my background with tiles in game maker. I drew it all as one, and then imported them as backgrounds.

What I want to do is make it so that the character can't wander right out of the walls or past the edges of the room.

If this question is too basic, or you know a good resource for information please let me know. I am learning from scratch and anything more experienced programmers can offer is extremely helpful.
 
D

DistressedGhost

Guest
Thanks so much for the response Jake!! I've been learning more today and happy to say I have collisions working and have even managed to get a door transition going. Now to figure out interactable objects.
 
D

DistressedGhost

Guest
@Roderick
Aw thank you! I don't usually do pixel art but it's turning out to be very enjoyable to make~ :p
 

Yal

🐧 *penguin noises*
GMC Elder
Interactible objects is a pretty broad category, but the gist of it is something along these lines:

Object's collision event with player:
if the interact button is pressed: do something.

If you want to do something over time, you don't want the interaction thing to be re-trigger-able. To solve this, you could either change the object's mask to a sprite with only transparent pixels (so it can't collide), or have the interactive object have two states (interactible or busy) using a variable - when you interact with it, you change the value of this variable, and you only handle the interaction if the state is right.
 
D

DistressedGhost

Guest
@Yal

Hi! Thanks for the response- I'm having a little difficulty understanding what you mean(still a complete newbie haha...). Could you use an example? :)
 

Yal

🐧 *penguin noises*
GMC Elder
For the basic case: add a collision event, and then add a code branch inside it checking if the interact button is pressed. Something like this:
Code:
if(keyboard_check_pressed(ord('C'))){
  show_message("This is an example thing that could happen.")
}
Now pressing the C key on top of something you can interact with triggers a message.


Also note that there's a bunch of vk_ constants for non-letter keys (e.g. vk_space is the keycode for pressing space, vk_down for the down arrow key, and so on), ord() is used to get the keycode for printable keys like digits and letters.

And the state approach would be like this:
Code:
if(state == 0){
  if(keyboard_check_pressed(ord('C'))){
    state = 1
    show_message("This is an example thing that could happen.")
  }
}
 

Ting_Thing

Member
Hi Yal,

I totally remember being where you are at! Hang in there! Perhaps if you gave a specific question about interacting objects, we could supply an answer that is a little more specific. From there you can catch onto the main ideas and apply them toward other things that you try doing with Game Maker (GMS).

By the way, if you have created working collisions, that means you have already accomplished one kind of "interaction" - that between your character and solid objects.
 
Top