Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: ncw911 on Mon 10/09/2012 01:29:26

Title: Crashing Game on Startup, Extreme Lag
Post by: ncw911 on Mon 10/09/2012 01:29:26
WELL, it doesnt really crash, just is unplayable... my game glitches out when room 1 loads, it starts and is very choppy and rarely responds,it seems like no characters respond and the mouse doesnt follow either and at random times the game loads to where it should be but then repeats and is unplayable, and characters warp around as if they are walking but without animating or walking to location, its a mess. my last game i was working on had the same problem so i started a new one and a good ways into it this happens and i cant identify which line of code caused it. my room 1 script is

// room script file

function room_Load()
{
  SetGlobalInt(3, 100);
  SetGlobalInt(4, 100);

if (GetGlobalInt(3)==100) {
      Asteroid1.Walk(Asteroid1.x, 350, eNoBlock, eAnywhere);

   
   

}}

function room_RepExec()
{

   if (AreThingsOverlapping(Asteroid1.ID, STAR.ID)) {
      SetGlobalInt(3, GetGlobalInt(3) - 50);
    }
    if (GetGlobalInt(3)<=0) {
              Asteroid1.LockView(6);
              Asteroid1.Animate(0, 1, eOnce);
              Asteroid1.UnlockView();
              Asteroid1.StopMoving();
              Asteroid1.x = Random(200);
              Asteroid1.y = (0);
              SetGlobalInt(4, 99);
              SetGlobalInt(3, 100);
    }
   
            if (GetGlobalInt(4)==99) {
            if (Asteroid1.y == 0) {
              Asteroid1.Walk(Asteroid1.x, 350, eNoBlock, eAnywhere);
            }
             
             
                 
           
           
}}



Asteroid1 starts at the top and falls down
STAR is a character that is used as a weapon that cEGO throws directly upward
cEgo walks only left and right
i used the default template which might have something to do with it
Title: Re: Crashing Game on Startup, Extreme Lag
Post by: Gilbert on Mon 10/09/2012 03:12:13
Haven't really read the codes thoroughly yet, but my guess is that it's caused by the blocking animation of the asteroid (Asteroid1.Animate(0, 1, eOnce); ). I don't know where exactly the entities are on the screen, but it's possible that the asteroid crashes with the star quite frequently (making AreThingsOverlapping(Asteroid1.ID, STAR.ID) true from time to time, note also that the delay used here is only 3 frames as you subtract 50 from globalint 3 every frame) and occasionally they don't crash giving you a bit time to response (as there're some randomness in the placement of the asteroid).