
-----------------------------------
Lekegolo killer
Mon May 11, 2009 11:18 am

Game won't run.
-----------------------------------
What is it you are trying to achieve?
I am trying to get my game to run properly.


What is the problem you are having?
My game stops halfway through and just displays the white background with the green scoreboard.


Describe what you have tried to solve this problem
I thought it might be the location of the View.UpdateArea, or the exit command in the second loop, but i have no idea how i would correct this.

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)



View.Set ("title:CLICKER EXTREME!,graphics:800;600,nobuttonbar,position:center;middle,offscreenonly")
Mouse.ButtonChoose ("multibutton")
Text.Colour(white)
Text.ColourBack (blue)
%Clicker EXTREME%
var score:int
var x:int
var y:int
var x1:int
var x2:int 
var y1:int
var y2:int
var button:int
%===============================================%
put "v1.0"
put "Created by Lekegolo"
View.UpdateArea(0,0,800,600)
Text.ColourBack (green)
score:=0
delay(3000)
%
locatexy(maxx div 2-1,maxy div 2)
Draw.FillBox(0,0,800,600,white)
Draw.FillBox(0,0,50,50,green)
put "3"..
locatexy(15,25)
put score,""..
View.UpdateArea(0,0,800,600)
delay(1000)
cls
%
locatexy(maxx div 2-1,maxy div 2)
Draw.FillBox(0,0,800,600,white)
Draw.FillBox(0,0,50,50,green)
put "2"..
locatexy(15,25)
put score,""..
View.UpdateArea(0,0,800,600)
delay(1000)
cls
%
locatexy(maxx div 2-1,maxy div 2)
Draw.FillBox(0,0,800,600,white)
Draw.FillBox(0,0,50,50,green)
put "1"..
locatexy(15,25)
put score,""..
View.UpdateArea(0,0,800,600)
delay(1000)
cls
%
locatexy(maxx div 2-10,maxy div 2)
Draw.FillBox(0,0,800,600,white)
Draw.FillBox(0,0,50,50,green)
put "GO!"..
locatexy(15,25)
put score,""..
View.UpdateArea(0,0,800,600)
delay(300)
cls

%===============================================%
loop
    
    Draw.FillBox(0,0,800,600,white)
    Draw.FillBox(0,0,50,50,green)
    locatexy(15,25)
    put score,"".. 
    View.UpdateArea(0,0,800,600)
    randint(x1,0,800)
    randint(x2,0,800)
    randint(y1,0,600)
    randint(y2,0,600)
    loop
    if      x2-x15
        and x1>50 
        and x2>50 
        and y1>50 
        and y2>50 
        and x1 50
3. The differences x2-x1 and y2-y1 are at least 5 and at most 150.
4. x1 and x2 are both less than 800 while y1 and y2 are both less than 600.

So if we want to find x1, we know that the only valid values are 50 to 795. Why? Because rule 2 says "at least 50" and rule 3 combines rule 4 to show that if x2 is its maximum (800) then x1 must be at most 795. Similarly for y1, only the upper limit is 595.

Once we have x1 and y1, we can find x2 and y2 from their values. We know that x2 is at least x1+5 and at most 800, while y2 is at least y1+5 and at most 600.

So we can replace that whole randomisation / if mess with this:


x1 := Rand.Int ( 50, 795 )
y1 := Rand.Int ( 50, 595 )
x2 := Rand.Int ( x1+5, 800 )
x2 := Rand.Int ( y1+5, 600 )


Of course, you can do even better if you keep around variables for the size of the screen and use those instead of the "magical" numbers 795 and 595.

The actual problem with your existing code is that you're not re-randomising at each iteration of the loop. You generate x1,x2,y1,y2 once, then check, check, check, check ... you get the point.

-----------------------------------
Lekegolo killer
Tue May 12, 2009 10:12 am

Re: Game won't run.
-----------------------------------
Wow I feel stupid. Thank you very much, I will be sure to put you in the credits.

-----------------------------------
DemonWasp
Tue May 12, 2009 10:41 am

RE:Game won\'t run.
-----------------------------------
Don't feel stupid. Everyone is going through the learning process, everyone has felt kind of stupid when someone further along pointed out a better way of doing things. Eventually you'll be the one making people feel stupid.

Instead, feel glad that you're not alone ;).
