Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AbrahamR), 717 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
reset player position & press any key #412438
11/27/12 14:07
11/27/12 14:07
Joined: Nov 2012
Posts: 18
Germany
E
elevationmind Offline OP
Newbie
elevationmind  Offline OP
Newbie
E

Joined: Nov 2012
Posts: 18
Germany
Hello,

I am trying to build a game so that the player moves trough a maze and gets "teleported" back to the begining, after reaching the end.

I have built a "restart ()" function, and tryed
// vec_set(player.x, vector(0,608,100);
// player.x=0; player.pan=90;

and similar things, but it just caused a script crash at the end of the maze.

What can I use to reset players position? Do I just level_load the level again?

I also would like to show a screen saying "press any key to return to the begining" bevore I move the player there. I was thinking about doing sth like:

while (!any_key) {set levelpanel=visible; restart()}

but I am not sure how I say "any key". Can someone tell me the right command line?

Re: reset player position & press any key [Re: elevationmind] #412441
11/27/12 14:12
11/27/12 14:12
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline
Senior Member
3dgs_snake  Offline
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
Hi,

1 - Normaly you can teleport an entity using vec_set on its position. But that depends on the logic used in your game and without some more code, that's difficult for me to tell you how or why.

2 - It's key_any wink

Re: reset player position & press any key [Re: 3dgs_snake] #412443
11/27/12 14:17
11/27/12 14:17
Joined: Nov 2012
Posts: 18
Germany
E
elevationmind Offline OP
Newbie
elevationmind  Offline OP
Newbie
E

Joined: Nov 2012
Posts: 18
Germany
Thx for the Quick reply:)!

When I use:

vec_set(player.x, vector(0,608,100);

I get a syntax error. How Do I tell the programme to set that location?

Re: reset player position & press any key [Re: elevationmind] #412444
11/27/12 14:24
11/27/12 14:24
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline
Senior Member
3dgs_snake  Offline
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
Code:
vec_set( player.x, vector( 0, 608, 100 ) );


wink (You forgot a parenthesis)

Re: reset player position & press any key [Re: elevationmind] #412445
11/27/12 14:25
11/27/12 14:25
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
vec_set(player.x, vector(0,608,100)); tongue


POTATO-MAN saves the day! - Random
Re: reset player position & press any key [Re: Kartoffel] #412457
11/27/12 16:09
11/27/12 16:09
Joined: Nov 2012
Posts: 18
Germany
E
elevationmind Offline OP
Newbie
elevationmind  Offline OP
Newbie
E

Joined: Nov 2012
Posts: 18
Germany
grin Thx. I see I was blind:)! But it still doesn't work for me, when I set the vector, and player gets to the point, where he should be "teleported" the game crashes.

Is there an other way to tell the game "put the player where he was at the beginning"?

Last edited by elevationmind; 11/27/12 16:10.
Re: reset player position & press any key [Re: elevationmind] #412460
11/27/12 16:13
11/27/12 16:13
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Then it might be advantageous to post the whole code so we can have a look at it...


Always learn from history, to be sure you make the same mistakes again...
Re: reset player position & press any key [Re: Uhrwerk] #412461
11/27/12 16:22
11/27/12 16:22
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Are you actually even using the pre-definied playerpointer? ^^
Writing to a not-initialized pointer isnt a good idea grin

Last edited by Ch40zzC0d3r; 11/27/12 16:23.
Re: reset player position & press any key [Re: Ch40zzC0d3r] #412462
11/27/12 16:33
11/27/12 16:33
Joined: Nov 2012
Posts: 18
Germany
E
elevationmind Offline OP
Newbie
elevationmind  Offline OP
Newbie
E

Joined: Nov 2012
Posts: 18
Germany
Ok here are the relevant parts of the code:


while (ZL<6) // part of the main level function
if ((camera.x > 5200) && (camera.y > 2160) && Zielerreicht == 0)
{
ZL +=1; // Levelzähler geht hoch

speichern();
Zielerreicht = 1;

} // Am Ende des Levels angekommen
if (Zielerreicht == 1)
{

restart();}
}

function restart()
{
vec_set(player.x, vector(0,608,100));
var S1=0, S2=0, S3=0, S4=0, S5=0, S6=0, S7=0, S8=0, SL=0;
var Z1=0, Z2=0, Z3=0, Z4=0, Z5=0, Z6=0, Z7=0, Z8=0, Zielerreicht = 0;
}

And I took the action for the Player "walk" from the tutorial;) :

action wizard_walk()
{
camera_follow(me);




while (1)
{
// state 1: walking ////////////////////////////////////////////

// rotate the entity with the arrow keys
my.pan += (key_cul-key_cur)*5*time_step;

//

// move the entity forward/backward with the arrow keys
var distance = (key_cuu-key_cud)*25*time_step; // auf 5 zurückstellen, wenn programmierung fertig
c_move(me, vector(distance,0,0), NULL, GLIDE);


// adjust entity to the ground height, using a downwards trace
c_trace(my.x,vector(my.x,my.y,my.z-1000),IGNORE_ME | IGNORE_PASSABLE);
my.z = 100; // always place player's feet on the ground
wait (1);

}
}

So yes - I guess I didn't initialise the players position - he just starts there, where I set him on the map...

I would be really greatful for any help, as I am a total beginner...

Re: reset player position & press any key [Re: elevationmind] #412468
11/27/12 18:12
11/27/12 18:12
Joined: Nov 2011
Posts: 274
de
lemming Offline
Member
lemming  Offline
Member

Joined: Nov 2011
Posts: 274
de
add before the while loop in wizard_walk a
player = me;

This should do the trick as the player pointer seems never set.

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1