Jump to content


Photo

how to...


  • Please log in to reply
10 replies to this topic

#1 slojanko

slojanko

    HARD GAMER

  • GMC Member
  • 410 posts
  • Version:GM8

Posted 27 April 2012 - 03:32 PM

I'm making a game, and until the player presses an object the room shoudnt start.
I used D&D for checking if obj_check is equal to 1, and if it is, the speed of room is 0. But then i get error saying room speed cant be <=0

So like how to make until the player presses an object in same room, the room will be paused?

Edit: How to make score text above sprites? I have a small cave in my game, and when the player enters it, the score goes under the sprites.

Edited by original games, 27 April 2012 - 03:39 PM.

  • 0

#2 Fihrilkamal

Fihrilkamal

    GMC Member

  • GMC Member
  • 348 posts

Posted 27 April 2012 - 04:24 PM

To pause your game you can use "do, until" and sleep function.
do
{
    sleep(1);
}
until (//YOUR CONDITION in this case some object pressed);
Be careful though! Using do-until s can easily lead your game to crash.
If you want texts appears above the player just set the depth of the drawing object to smaller, like -100000.
PS: This topic should belongs to Novice and intermediate Q&A
  • 0

#3 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9260 posts
  • Version:Unknown

Posted 27 April 2012 - 05:01 PM

You could use a loop, but as mentioned, that can be dangerous. One mistake could lead to a full crash of your game.

The better method is to program the pause yourself. In other words, have some global variable (like global.paused or something) that is set to TRUE initially. In all your objects' codes, if global.paused==true, don't execute the code. When you click the object, set global.paused=false and voila! You're done :) .

-IMP
  • 0

#4 slojanko

slojanko

    HARD GAMER

  • GMC Member
  • 410 posts
  • Version:GM8

Posted 27 April 2012 - 08:16 PM

Example please
  • 1

#5 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9260 posts
  • Version:Unknown

Posted 27 April 2012 - 09:59 PM

Um...I told you exactly how to do it. If you tried and couldn't get it working, then please post what you've tried and I can help you debug your code. The Q&A forums here are to help people learn to use GM so they can become better programmers; it's not here for people to do everything for you.

-IMP
  • 0

#6 slojanko

slojanko

    HARD GAMER

  • GMC Member
  • 410 posts
  • Version:GM8

Posted 28 April 2012 - 09:15 AM

The problem is I would have to add pause infront of all movement codes, animations, gravity...

edit:

create event:

pause = true

Infront of all codes that are for movement, animations,...

if pause = false

Create event for left button

pause = false

Edited by original games, 28 April 2012 - 09:19 AM.

  • 0

#7 Fihrilkamal

Fihrilkamal

    GMC Member

  • GMC Member
  • 348 posts

Posted 28 April 2012 - 07:19 PM

The problem is I would have to add pause infront of all movement codes, animations, gravity...

edit:

create event:

pause = true

Infront of all codes that are for movement, animations,...

if pause = false

Create event for left button

pause = false

Read this.

Edited by Fihrilkamal, 28 April 2012 - 07:20 PM.

  • 0

#8 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9260 posts
  • Version:Unknown

Posted 29 April 2012 - 01:26 AM

The problem is I would have to add pause infront of all movement codes, animations, gravity...

edit:

create event:

pause = true

Infront of all codes that are for movement, animations,...

if pause = false

Create event for left button

pause = false

Yes, and? You have only a few options when it comes to pausing:

1) Use a loop to halt the game. This will work, but it means that you can't have anything happening during the pause unless you code it yourself within the loop, and a small mistake could lead to your game crashing.

2) Use mouse_wait() or keyboard_wait(), but those unpause automatically with no flexibility over the unpause trigger (i.e. any mouse or keyboard input will unpause your game).

3) Code it yourself. Like I said. Yes, you'll need to check for the pause state in front of all STEP and DRAW events, but that's kind of how it needs to be. Besides, you can copy/paste the if (global.pause == false) { exit; } line so it's not like you need to re-type it over and again.

The other option would be to create a background from the screen, set the room to persistent, move to a pause room, set the background to the created one, then move back when you unpause, set the room to non-persistent, and finally delete the background. That's the best option, but since you're using D&D and seem to be a bit new to GM, I thought that might be a bit overwhelming for you.

-IMP
  • 0

#9 slojanko

slojanko

    HARD GAMER

  • GMC Member
  • 410 posts
  • Version:GM8

Posted 29 April 2012 - 06:56 AM

So will the codes i typed work or not work?
  • 0

#10 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9260 posts
  • Version:Unknown

Posted 29 April 2012 - 07:20 AM

If you make "paused" a global variable, they will. I assume by "create event for left button" you just meant the Left Pressed event for the button? Since that's when you want to pause, of course.

And then whenever you want to unpause, just set global.paused=false again.

-IMP
  • 0

#11 slojanko

slojanko

    HARD GAMER

  • GMC Member
  • 410 posts
  • Version:GM8

Posted 29 April 2012 - 09:37 AM

I AM TEH BEST I FIGURE THE SOLUTION MYSELF!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users