Computer Science Canada

cls and then what?

Author:  sniper437 [ Tue Nov 22, 2005 11:57 pm ]
Post subject:  cls and then what?

okay im trying to make a text rpg and i gotta problem see i have this code:

code:


var picID : int
var picID1 : int
var mg1x : int := 100
var mg1y : int := 100
var x, y : int := 100
x := 120
y := 125
var chars : array char of boolean
picID := Pic.FileNew ("ch2.jpg")
picID1 := Pic.FileNew ("mg1.jpg")

loop

    Pic.Draw (picID, x, y, picMerge)
    Pic.Draw (picID1, mg1x, mg1y, picMerge)

    Input.KeyDown (chars)

    if chars (KEY_UP_ARROW) then
        y := y + 3
    end if
    if chars (KEY_RIGHT_ARROW) then
        x := x + 3
    end if
    if chars (KEY_LEFT_ARROW) then
        x := x - 3
    end if
    if chars (KEY_DOWN_ARROW) then
        y := y - 3
    end if
    delay (10)

   
    if (y <= mg1y +5) & (y >= mg1y -5) & (x <= mg1x +5) & (x >= mg1x -5) then
    cls
   y := 0
   x := 0
   Pic.Free (picID1)
   
   end if
   
    cls
end loop

   
    Pic.Free (picID)

so what i want to do now is that if my charater hits that mage i dont want to reset position i want it to clear the screen and bring up a brand new screen with like battle options, so how do i do it? Embarassed [/code]

Author:  sniper437 [ Wed Nov 23, 2005 1:26 am ]
Post subject: 

woops forgot the pics Embarassed

[/list]

Author:  sniper437 [ Wed Nov 23, 2005 1:27 am ]
Post subject: 

wtf? my other one didnt come up?

Confused

Author:  Albrecd [ Wed Nov 23, 2005 1:34 pm ]
Post subject: 

The reason that the window closes when you hit the other character is because it frees the picture but then continues the loop. Part of the loop is drawing the picture that you just freed, which it can no longer do. This causes an error. You need it to exit the loop as well as free the picture when they collide.

Author:  do_pete [ Wed Nov 23, 2005 1:38 pm ]
Post subject: 

you would have to clear the screen and exit the loop and then have another loop with all the stuff you want. And use View.Update to get rid of the flicker.

Author:  Albrecd [ Wed Nov 23, 2005 1:43 pm ]
Post subject: 

Or, within your loop, you could put:

code:

if %collision dection here% then
%Process with battle stuff here%
end if


and then continue the loop

(I would have edited my post but for some reason there was no edit button)


: