[ 11 posts ]  Reply to topicPost new topic 
Author Message
 [us]
 Post subject: NEED HELP WITH SOME CODING HERE!
PostPosted: Mon Jun 12, 2017 4:14 am 
User avatar
This is official artwork
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
OK, so I'm working on this game that is like space invaders but with two players. They way someone wins the game is by destroying all of the aliens on screen and and the person with the most points wins. My problem is that I don't know how to transition to a different room after all the aliens are gone and determine who the winner is. I appreciate any help I can get. Thanks! (By the way, I'm using Game Maker 8.1.)

_________________
Image      Image
 
Top
Offline 
 User page at mfgg.net
 
 [zz]
 Post subject: Re: NEED HELP WITH SOME CODING HERE!
PostPosted: Mon Jun 12, 2017 4:19 am 
User avatar
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
I'm not a real coder, but I'd say global variables and room_goto should solve your issue.

 
Top
Offline 
 User page at mfgg.net
 
 [ca]
 Post subject: Re: NEED HELP WITH SOME CODING HERE!
PostPosted: Mon Jun 12, 2017 2:27 pm 
User avatar
Watashi Wa
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
Auction Lemon wrote:
OK, so I'm working on this game that is like space invaders but with two players. They way someone wins the game is by destroying all of the aliens on screen and and the person with the most points wins. My problem is that I don't know how to transition to a different room after all the aliens are gone and determine who the winner is. I appreciate any help I can get. Thanks! (By the way, I'm using Game Maker 8.1.)


It sounds like you need the variables for player points to be global.

By appending "global." to a variable, you are creating a global variable. Global variables will retain their values for the entire life of the game, regardless of room.

so basically what you want is something like this:

Code:
global.playerOneScore = 0;
global.playerTwoScore = 0;


do this when your gameplay starts and then when you move to another room, you can still reference them. Just add to the values as P1 and P2 gather points.

Let me know if you need any clarification on anything.

_________________
My games | My twitter | My stream | Sprites Unlimited

Image
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: NEED HELP WITH SOME CODING HERE!
PostPosted: Mon Jun 12, 2017 3:36 pm 
User avatar
This is official artwork
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
Syaxamaphone wrote:
Auction Lemon wrote:
OK, so I'm working on this game that is like space invaders but with two players. They way someone wins the game is by destroying all of the aliens on screen and and the person with the most points wins. My problem is that I don't know how to transition to a different room after all the aliens are gone and determine who the winner is. I appreciate any help I can get. Thanks! (By the way, I'm using Game Maker 8.1.)


It sounds like you need the variables for player points to be global.

By appending "global." to a variable, you are creating a global variable. Global variables will retain their values for the entire life of the game, regardless of room.

so basically what you want is something like this:

Code:
global.playerOneScore = 0;
global.playerTwoScore = 0;


do this when your gameplay starts and then when you move to another room, you can still reference them. Just add to the values as P1 and P2 gather points.

Let me know if you need any clarification on anything.


I got that part down, but I can't figure out how to move to a different room after all the enemies on the screen are gone.

_________________
Image      Image
 
Top
Offline 
 User page at mfgg.net
 
 [at]
 Post subject: Re: NEED HELP WITH SOME CODING HERE!
PostPosted: Mon Jun 12, 2017 3:58 pm 
Cliax Codec X Splatoon
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
Auction Lemon wrote:
I got that part down, but I can't figure out how to move to a different room after all the enemies on the screen are gone.
Syntax: [ Download ] [ Hide ]
Using gml Syntax Highlighting
if (!instance_exists(par_enemy)) { room_goto(your_room); }


Every enemy needs to inherit from an object called par_enemy. Replace your_room with the name of the room you want to go to.

_________________
Image

Cliax Codec is a combination of top-down and third-person shooter. The gameplay will blend platforming, puzzle and shmup elements together to create a unique gameplay experience. You will take control of four playable characters which rise against a team that seemingly wants to take over the world - but are their motives really that cliché, or are there deeper motives behind their actions?

Currently designing Chapter 1-6, 5%

GOTM titles
Spoiler:
Fan Art
Spoiler:
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: NEED HELP WITH SOME CODING HERE!
PostPosted: Mon Jun 12, 2017 4:09 pm 
User avatar
This is official artwork
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
DJ Coco wrote:
Auction Lemon wrote:
I got that part down, but I can't figure out how to move to a different room after all the enemies on the screen are gone.
Syntax: [ Download ] [ Hide ]
Using gml Syntax Highlighting
if (!instance_exists(par_enemy)) { room_goto(your_room); }


Every enemy needs to inherit from an object called par_enemy. Replace your_room with the name of the room you want to go to.

I have tried your code, but it doesn't seem to work for some reason.

_________________
Image      Image
 
Top
Offline 
 User page at mfgg.net
 
 [at]
 Post subject: Re: NEED HELP WITH SOME CODING HERE!
PostPosted: Mon Jun 12, 2017 5:43 pm 
Cliax Codec X Splatoon
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
What's the problem? Are you getting any error messages?
Please post them here so we can help you further.

_________________
Image

Cliax Codec is a combination of top-down and third-person shooter. The gameplay will blend platforming, puzzle and shmup elements together to create a unique gameplay experience. You will take control of four playable characters which rise against a team that seemingly wants to take over the world - but are their motives really that cliché, or are there deeper motives behind their actions?

Currently designing Chapter 1-6, 5%

GOTM titles
Spoiler:
Fan Art
Spoiler:
 
Top
Offline 
 User page at mfgg.net
 
 [tr]
 Post subject: Re: NEED HELP WITH SOME CODING HERE!
PostPosted: Mon Jun 12, 2017 5:53 pm 
User avatar
Thanks DonnieTheGuy!
Administrator
[A]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
You have to create a par_enemy object that's used as a parent for all enemy objects. To compare the scores you need a code like "if global.playerOneScore > global.playerTwoScore"

_________________
Image
 
Top
Offline 
 
 
 [us]
 Post subject: Re: NEED HELP WITH SOME CODING HERE!
PostPosted: Mon Jun 12, 2017 6:06 pm 
User avatar
This is official artwork
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
DJ Coco wrote:
What's the problem? Are you getting any error messages?
Please post them here so we can help you further.

After getting rid of all the enemies, it won't transition to the next room and just leaves me hanging in the same room without anymore enemies to shoot or determining who the winner is.

_________________
Image      Image
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: NEED HELP WITH SOME CODING HERE!
PostPosted: Mon Jun 12, 2017 11:13 pm 
User avatar
Kootie Patootie
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
Then you're misunderstanding the solution DJ Coco provided.

Are the player team objects and the enemy team objects under the same parent? If so, then you'll have to iterate through every instance of them with a for loop and check if all of them attributed to one team are nonexistent before executing room_goto().

If you want to be told precisely the code you need to use and exactly where it needs to be implemented, then you're gonna have to send the source so somebody can fix it for you.

_________________
Image
My mains
 
Top
Offline 
 User page at mfgg.net
 
 [at]
 Post subject: Re: NEED HELP WITH SOME CODING HERE!
PostPosted: Tue Jun 13, 2017 10:01 am 
Cliax Codec X Splatoon
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
Auction Lemon wrote:
DJ Coco wrote:
What's the problem? Are you getting any error messages?
Please post them here so we can help you further.

After getting rid of all the enemies, it won't transition to the next room and just leaves me hanging in the same room without anymore enemies to shoot or determining who the winner is.
Are you sure there is no instance of par_enemy left? As long as any object inheriting from par_enemy (or par_enemy itself) still exists within the room, the code will not trigger.

You could debug it like this:
Syntax: [ Download ] [ Hide ]
Using gml Syntax Highlighting
if (keyboard_check_pressed(vk_space)) {
    with (par_enemy) { show_message(object_get_name(object_index)); }
}


Whenever you press space each instance will show a message a name of its name (like obj_goomba, for instance) so you can check which instances are still left in the room.
If you accidentally might have wrong enemies inheriting from par_enemy you can check so by opening par_enemy and looking at its children in the object editor.

_________________
Image

Cliax Codec is a combination of top-down and third-person shooter. The gameplay will blend platforming, puzzle and shmup elements together to create a unique gameplay experience. You will take control of four playable characters which rise against a team that seemingly wants to take over the world - but are their motives really that cliché, or are there deeper motives behind their actions?

Currently designing Chapter 1-6, 5%

GOTM titles
Spoiler:
Fan Art
Spoiler:
 
Top
Offline 
 User page at mfgg.net
 
« Previous topic | Next topic »
Display posts from previous:  Sort by  
 [ 11 posts ]  Reply to topicPost new topic 


Who is online

Users browsing this topic: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group