I would think something like this... I still don't like the idea of using proc_kill this way.
PANEL* looptxt_pan =
{
bmap = "nextstage.tga";
pos_x = 0;
pos_y = 350;
layer = 50;
}
function initialize_panel_startup()
{
looptxt_pan->pos_x -=bmap_width(looptxt_pan.bmap);
// any other data
}
function looptxt()
{
wait(3);
proc_kill(4);
var my_start_x = looptxt_pan->pos_x;
var my_start_y = looptxt_pan->pos_y;
set(looptxt_pan,SHOW | OVERLAY);
while(looptxt_pan->pos_x < screen_size->x - bmap_width(looptxt_pan->bmap))
{
looptxt_pan->pos_x +=30* time_step;
wait(1);
}
looptxt_pan->pos_x = my_start_x;
looptxt_pan->pos_y = my_start_y;
reset(looptxt_pan,SHOW );
}
function players_event()
{
if (event_type == EVENT_PUSH)
{
looptxt();
}
// for more then a few event_type(s) use a 'switch'
}
action player_code()
{
.......
my.emask = ENABLE_PUSH;
my.event = players_event;
c_move(my,reldist,absdist,ACTIVATE_PUSH);
.......
}
You don't have to use ACTIVATE_PUSH is you set up the push values or see below for moving to event to the object and not the player.
Using a few global vars for tracking and comparing the running state of events is what I like but I don't know if it's faster.
var iEvent_pushRunning =0 ;
function looptxt()
{
iEvent_pushRunning =1; // new code for something like a keylock
var my_start_x = looptxt_pan->pos_x;
var my_start_y = looptxt_pan->pos_y;
set(looptxt_pan,SHOW | OVERLAY);
while(looptxt_pan->pos_x < screen_size->x - bmap_width(looptxt_pan->bmap))
{
looptxt_pan->pos_x +=30* time_step;
wait(1);
}
looptxt_pan->pos_x = my_start_x;
looptxt_pan->pos_y = my_start_y;
reset(looptxt_pan,SHOW );
iEvent_pushRunning =0; // release the lock
}
function players_event()
{
if (event_type == EVENT_PUSH && !iEvent_pushRunning) // only run if lock is open
{
looptxt();
}
// for more then a few event_type(s) use a 'switch'
}
Event impact... Event run on object side, since the object is less likely to impact anything the event comparisons are run less often and save resources..
PANEL* looptxt_pan =
{
bmap = "nextstage.tga";
pos_x = 0;
pos_y = 350;
layer = 50;
}
function initialize_panel_startup()
{
looptxt_pan->pos_x -=bmap_width(looptxt_pan.bmap);
// any other data
}
#define MAX_LEVEL_ENTS 200
#define EVENT_IMPACT_RUNNING skill20
#define LOCKED 1
#define UNLOCKED 0
function looptxt()
{
my.EVENT_IMPACT_RUNNING = LOCKED;
var my_start_x = looptxt_pan->pos_x;
var my_start_y = looptxt_pan->pos_y;
set(looptxt_pan,SHOW | OVERLAY);
while(looptxt_pan->pos_x < screen_size->x - bmap_width(looptxt_pan->bmap))
{
looptxt_pan->pos_x +=30* time_step;
wait(1);
}
looptxt_pan->pos_x = my_start_x;
looptxt_pan->pos_y = my_start_y;
reset(looptxt_pan,SHOW );
my.EVENT_IMPACT_RUNNING = UNLOCKED;
}
function hit_object_event()
{
if (event_type == EVENT_IMPACT && !my.EVENT_IMPACT_RUNNING && you == player)
{
looptxt();
}
// for more then a few event_type(s) use a 'switch'
}
action hit_object_code()
{
.......
my.emask = ENABLE_IMPACT;
my.event = hit_object_event;
my.EVENT_IMPACT_RUNNING =0;
.......
}