
-----------------------------------
MOUSECORD
Thu Jun 10, 2004 7:20 pm

Help with For loop that gets stuck in my game
-----------------------------------
Hey i'm making missile command and this part of my game... the anti missile part -----

[code]

 procedure mouse

   var mousex, mousey, button : int
    mousewhere (mousex, mousey, button)
    if button = 1 then
    
    for rad: 1..25
    cls
        drawfilloval (mousex, mousey, rad, rad, 66)
    delay(25)    
    end for    
    
    
    for decreasing rad: 25..1
    cls  
            drawfilloval (mousex, mousey, rad, rad, 66)
    delay(25) 
    end for
    end if
end mouse


loop
cls
mouse
delay(25)
View.Update
end loop




[code]

if i put something else in the loop say one of my misiles for the game (missile command) the missile lags until the mouse procedure is finished.... is there any way to get around this and still have the same Mouse Procedure affect ... i really need this anyone knows??[/code]

-----------------------------------
Paul
Thu Jun 10, 2004 7:30 pm


-----------------------------------
put the whole expanding/shrinking circles thingy in the main loop, that is not in its own for loop, and have a the radius decrease / increase using if statements in the loop, while ur other parts run at the same time.
Ur other option is to use a process, but some ppl here do not like processes, and for me they make View.Update harder to use.

-----------------------------------
MOUSECORD
Thu Jun 10, 2004 8:35 pm


-----------------------------------
okay but i'm not sure how to use if statements to make something add smoothly like that only jump to it...?

-----------------------------------
Paul
Thu Jun 10, 2004 8:55 pm


-----------------------------------
Well, I'll give u an example:
instead of this, which lags the ball falling:

setscreen ("offscreenonly")
var x, y : int := maxy
procedure mouse

    var mousex, mousey, button : int
    mousewhere (mousex, mousey, button)
    if button = 1 then

        for rad : 1 .. 25
            View.Update
            drawfilloval (mousex, mousey, rad - 1, rad - 1, white)
            drawfilloval (mousex, mousey, rad, rad, 66)
            delay (10)
        end for


        for decreasing rad : 25 .. 1
            View.Update

            drawfilloval (mousex, mousey, rad + 1, rad + 1, white)
            drawfilloval (mousex, mousey, rad, rad, 66)
            delay (10)
        end for
    end if
end mouse

x := 200
loop

    y -= 3
    if y = 25 then
dir:= "in"
end if
end if
if dir= "in" then
radius-=1
drawfilloval (drawx, drawy, radius, radius, 66)
if radius = 50 then 
        cha := -5 
    
        end if 
       end if 
if rad= 30 then
            cha := -2
            delay (25)

        end if
        if rad 