Computer Science Canada

Need help with Flawless background w/ animated bmp's over

Author:  Protosstic [ Wed Jun 04, 2003 3:49 pm ]
Post subject:  Need help with Flawless background w/ animated bmp's over

Hello All. I am using Turing 4.0.1 [p], which is used commonly around our school for the course I am taking. Now for mine and my partner's end of the year project, we are making Frogger: Reloaded Smile Anyways right now We got a moving frog image, over top of a black background, with gridlines (to show us which areas will need to be filled and such). Now the problem is, when we have drawfillbox's set as the background, whenver the frog move's, the drawfillboxes flash off and on. Aswell when we tried using a picture we made and had set it as the background, during the animation the colours were inverted. Since Sprites are not supported in 4, we need a way to do this, so we can have trucks, cars, and logs hopefully moving over the background aswell, while the game is going. We noticed some slow downs/problems aswell when setting the background image to picCopy and picXor. So we decided to stick with drawfillbox's and such, but really need to get it working right. So basically we need to have the drawfillboxes and the rest of the drawfill commands we will be using, under neither the frog/truck/cars/logs at all times. Any help here would be greatly appreciated. Code is included below:

code:


setscreen ("graphics:640;480,offscreenonly,nobuttonbar, nocursor, noecho")
colourback (black)
cls
var picID : int
var x, y : int
var c, ci : string
var spo : int
var chars : array char of boolean
randint (spo, 1, 12)
x := 0 + (spo * 40)
y := 1
c := "1"
process bg
    drawfillbox (1, 1, 120, 80, red)
end bg

process bgmusic
    Music.PlayFile ("bgtest.mp3")
end bgmusic
process gridline
    loop
        for count : 1 .. 15
            drawline (40 * count, 1, 40 * count, 480, white)
        end for
        for count : 1 .. 11
            drawline (1, 40 * count, 640, 40 * count, white)
        end for
    end loop
end gridline
proc jump
    for count : 1 .. 8
        if c = "1j" then
            y := y + 5
            delay (25)
        elsif c = "2j" then
            y := y - 5
            delay (25)
        elsif c = "3j" then
            x := x - 5
            delay (25)
        elsif c = "4j" then
            x := x + 5
            delay (25)
        end if
        View.Update
        cls
        delay (25)
        Pic.ScreenLoad ("frog" + c + ".bmp", x, y, picMerge)
    end for
    View.Update
    cls
    delay (25)
    fork bg
    Pic.ScreenLoad ("frog" + ci + ".bmp", x, y, picMerge)
    View.Update
end jump

fork gridline
Pic.ScreenLoad ("frog1.bmp", x, y, picMerge)
delay (1000)
fork bgmusic
loop
    fork bg
    Input.KeyDown (chars)
    if chars (KEY_UP_ARROW) then
        c := "1j"
        ci := "1"
        jump
    elsif chars (KEY_DOWN_ARROW) then
        c := "2j"
        ci := "2"
        jump
    elsif chars (KEY_LEFT_ARROW) then
        c := "3j"
        ci := "3"
        jump
    elsif chars (KEY_RIGHT_ARROW) then
        c := "4j"
        ci := "4"
        jump
    end if
end loop




I really appreciate any help, we really are hoping to do good on this game!

Author:  Tony [ Wed Jun 04, 2003 4:01 pm ]
Post subject: 

well turing is naturally slow, and the only way to speed up the exectuion is ether

a) calculating less values or
b) move graphics over a larger distance per turn (if applicable)

If you're using a picture as your background, you can cut it up in pieces and redraw only those that are need to be restored.

Author:  Protosstic [ Wed Jun 04, 2003 4:24 pm ]
Post subject: 

Alright, well Should I then be having each background piece being assigned to a section, and if the frog is in that section ,it redraws it?

Author:  Tony [ Wed Jun 04, 2003 4:30 pm ]
Post subject: 

yeah, basically... such as you mentioned before that there was a grid... so have each grid cell as a separate picture... this way as the frog moves from 1 cell to the next, you just have to redraw that single cell instead of the whole background, speeding up the process.

Author:  Protosstic [ Wed Jun 04, 2003 4:40 pm ]
Post subject: 

Alright, Yeah the grid will be gone soon, it's just there for testing purposes. Now One other thing is, in the code i posted earlier, it seems to be using all my CPU when i run it and the frog is not moving (idle). Got any idea why it's doing that?

Btw, Thanks alot for all of this!

Author:  Tony [ Wed Jun 04, 2003 4:59 pm ]
Post subject: 

turing is naturally slow and very bad at using resourses properly... processes might affect this as well (in a bad way)...

though I dont really know

Author:  Protosstic [ Wed Jun 04, 2003 5:38 pm ]
Post subject: 

Well thanks alot for all your Help Tony, Very much appreciated, hope to get this game done soon. I am right now working to assign each box a number in an array, so thanks to you my project is not on pause!!!

Author:  Protosstic [ Wed Jun 04, 2003 6:02 pm ]
Post subject: 

Hopefully this is okay to ask in the same thread as my other post, because it is for the same game.

I am trying to make an array variable equal to something, in my 2d array. This is going to be used to give each grid spot a specific id, so i can update each one after a move. However i am having some problem with getting it going. Not sure how to make the second dimension of the variable equal to something. Here is my code.

code:

var bgsqr : array 1 .. 192, 1 .. 2 of int

for count : 0 .. 192 by 12

    county := county + 1
    for count2 : 1 .. 16
        bgsqr (count + count2, 1) := (count2 * 40)
        bgsqr (count + count2, 2) := (county * 40)
    end for
end for


I tried to follow the tutorial, but was having some problems understanding with 2d arrays. Thanks!

Author:  Tony [ Wed Jun 04, 2003 8:00 pm ]
Post subject: 

hmmm... you're doing this all wrong...

code:

var picID:array 1..10, 1..10 of int

for row:1..10
     for column:1..10
          picID(row,column) := Pic.New(row*100-100, column*100-100,row*100,column*100)
     end for
end for


This creates an array of 10x10 grid and saves 100x100 squares, where first number is the row and second is the column of there the box is located.


: