Defining player position while switching layouts\screens

For questions about using Classic.

Post » Mon Jun 21, 2010 10:49 am

Hi, hope to get an answer to a problem:
I'm doing top down adventure game, where each screen is a separate layout, surrounded by 4 collision objects that:

1. on collision with player set a global variable (1 - up,2 - right,3 - down,4 - left)
2. on collision with player depending on the side player exits screen sets global var Player_X or Player_Y
3. after setting these - it loads corresponding layout

Each layout has a "On load" event, where global variable (side) is checked depending on it's value the X and Y position of a player should be set.
And this partially true - the part that sets player position to (Player_X or Player_Y) operates normally but the part where position is defined in absolute values is ignored, instead the position of object on the layout is used (I place player on each layout).

How can i make it work? Or maybe you see whats wrong with the game logic here.
Thanks
B
2
G
2
Posts: 6
Reputation: 662

Post » Mon Jun 21, 2010 11:31 am

Is the problem that the player exits right but still appears on the right side of the screen in the next layout? I'm not sure I understand.

Just a recommendation: if the game is gonna have a lot of "screens" to play on, make one layout for each area (like, forest), and make the game scroll "per-screen" (and make the layout as big as the amount of screens you want). One way to do this could be:

Center X scroll to -> Floor(Player.X/game's resolution width)*game's resolution width + half of game's resolution width

There might be a different calculation for it (to do it with scroll Y, just replace "X" with "Y" and "width" with "height". I think that this will make working with your game file faster and easier in the long run,
B
5
S
2
G
3
Posts: 234
Reputation: 1,818

Post » Mon Jun 21, 2010 12:41 pm

The problem is that if I exit the screen in it's lower part, I expect character to appear on the next screen on the same X he exited previous and with the Y=45 (to appear in the upper part of the screen with some offset). It does occure but the Y part is taken as it is for the character on the second screen.

concerning your recomendation: it is quite helpful though what i'm trying to achieve is the connection of screens that wouldn't be linear, so in some cases walking left from screen A leads to screen B and in other cases it leads to C or Z. So it seems that i can't use the scheme you're proposing, thanks anyway.
B
2
G
2
Posts: 6
Reputation: 662

Post » Mon Jun 21, 2010 1:52 pm

The cap file in this thread might help:
viewtopic.php?f=8&t=3970&p=36700&hilit=spawn#p36700

It uses spawn points to create the player at different points.
B
77
S
49
G
25
Posts: 346
Reputation: 17,409

Post » Mon Jun 21, 2010 3:19 pm

it doesn't work in my case.
B
2
G
2
Posts: 6
Reputation: 662


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests