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
changing the level once my character reaches a certain posiiton #234379
11/02/08 17:12
11/02/08 17:12
Joined: Apr 2004
Posts: 77
USA
Cactus Offline OP
Junior Member
Cactus  Offline OP
Junior Member

Joined: Apr 2004
Posts: 77
USA
K I want my level to change once my character reaches a certain position, or when my player touches a certain object. How should I go about this. I am using the A5 templates.
Sorry for being a noob, but help would be great.


HI
Re: changing the level once my character reaches a certain posiiton [Re: Cactus] #234410
11/02/08 20:18
11/02/08 20:18
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Code:

action LevelChanger_act
{
  while(!player) { wait(1); }

  my.passable = on;

  while(me)
  {
    if(vec_dist(my.x,player.x) < 50)
    {
      level_load("level02.wmb");
    }
    wait(1);
  }
}


Other approach using a touch event:
Code:
function LevelChanger_event()
{
  if(event_type == event_entity || event_type == event_impact)
  {
    if(you == player)
    {
      level_load("level2.wmb");
    }
  }
}

action LevelChanger_act
{
  my.enable_entity = on;
  my.enable_impact = on;
  my.event = LevelChanger_event;
}


Of course you can alter it for using it with multiple levels.
Like, define a skill which works as id for the level that is loaded, have a string array (text object) holding all level name strings, and load it using the id as index:
Code:
text level_files
{
  string = "level1.wmb","level2.wmb"....
}
...
define level_id, skill2;
...
level_load(level_files.string[my.level_id]);
...


hope this helps you a bit

Re: changing the level once my character reaches a certain posiiton [Re: Xarthor] #234416
11/02/08 20:56
11/02/08 20:56
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Xarthor's 2nd approach is good imo, but you should remove the levelchanger entity right after the impact event called because if you dont remove it, impact event wil get called everyframe, means it will call level_load in everyframe of impact which causes engine to freeze.


3333333333
Re: changing the level once my character reaches a certain posiiton [Re: Quad] #234419
11/02/08 21:17
11/02/08 21:17
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Removing is not necessary, just add the following lines in the event function:
my.enable_entity = off;
my.enable_impact = off;

Thanks for the hint Quadraxas!

Re: changing the level once my character reaches a certain posiiton [Re: Xarthor] #234432
11/02/08 22:29
11/02/08 22:29
Joined: Apr 2004
Posts: 77
USA
Cactus Offline OP
Junior Member
Cactus  Offline OP
Junior Member

Joined: Apr 2004
Posts: 77
USA
Thank You so much, but now when I load the next level all of the panels I made in my main script for for level 2 dont show up. Is it still using the same main script from the last level?
if so how do I load the main script for level two?


HI
Re: changing the level once my character reaches a certain posiiton [Re: Cactus] #234433
11/02/08 22:33
11/02/08 22:33
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
you can't use 2 different scripts for 2 different levels. You have to use one master script throughout the game.

Re: changing the level once my character reaches a certain posiiton [Re: Cactus] #234441
11/02/08 23:20
11/02/08 23:20
Joined: Apr 2004
Posts: 77
USA
Cactus Offline OP
Junior Member
Cactus  Offline OP
Junior Member

Joined: Apr 2004
Posts: 77
USA
k figured somthing out.


HI
Re: changing the level once my character reaches a certain posiiton [Re: Xarthor] #234591
11/03/08 19:38
11/03/08 19:38
Joined: Apr 2004
Posts: 77
USA
Cactus Offline OP
Junior Member
Cactus  Offline OP
Junior Member

Joined: Apr 2004
Posts: 77
USA
Ok I used the seconed aproach and it worked, but now when the player shoots at the level change object the level changer turns off. Still using A5 templates.


HI
Re: changing the level once my character reaches a certain posiiton [Re: Cactus] #234620
11/03/08 21:26
11/03/08 21:26
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Code:
function LevelChanger_event()
{
  if(event_type == event_entity || event_type == event_impact)
  {
    if(you == player)
    {
      my.enable_entity = null;
      my.enable_impact = null;
      level_load("level2.wmb");
    }
  }
}

This makes sure that events are only turned off if the player hits the entity.
Hope this works.

Re: changing the level once my character reaches a certain posiiton [Re: Xarthor] #234653
11/04/08 00:09
11/04/08 00:09
Joined: Apr 2004
Posts: 77
USA
Cactus Offline OP
Junior Member
Cactus  Offline OP
Junior Member

Joined: Apr 2004
Posts: 77
USA
no that did'nt work, but thanks anyway. I guess I'll just figure it out.


HI
Page 1 of 2 1 2

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