Issue with graphics
Author |
Message |
Geostigma
|
Posted: Fri Jan 18, 2008 10:02 am Post subject: Issue with graphics |
|
|
I have been working on a program, generally recreating the game iceblocks. I have the game running, scoring and all that fun other stuff but I want to add an animation of a falling block. The general code of making a block fall from the sky in the right position is not the problem but the getting the rest of the pyramid to display while the block is falling from the sky.
This is what my partner has done
end animate Turing: | procedure animate (getx,gety : int)
var tempx, tempy : int
tempy := gety * 70
tempx := getx * 70 + (17 * gety )
for decreasing a : 400 .. 70 * (gety - 1) by 20
Pic.Draw (white1, tempx, tempy + a, picXor)
View.Update
Pic.Draw (white1, tempx, tempy + a, picXor)
end for
|
My syntax
Turing: |
procedure blockfall (x,y: int)
for decreasing a : 700. .(70*y )
cls
Pic.Draw(backround, 0, 0, 0)
Pic.Draw (white1, (x* 70),a,PicMerge )
for i : 1.. 36
if triange (i ) = 1 then
elsif triangle (i ) = 2 then
end if
end for
View.Update
end for
|
Everything else works fine no matter what code we use but I am not sure how to display a block falling from the sky with out wiping everything else out.
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
TokenHerbz
![](http://compsci.ca/v3/uploads/user_avatars/717170395558e628d9452b.jpg)
|
Posted: Sat Jan 19, 2008 12:20 pm Post subject: RE:Issue with graphics |
|
|
what exactly is happening? Is the block wiping out the picture it was previously drawn over? Is it not refreshing correctly?
You should use View.UpdateArea(x1,y1,x2,y2) since your using graphics, it should make the program faster for the specific falling block animation. of course its a little trickier to use though.
edit: you should capture the background of the block first, before you draw your picture over it.
you can do this by:
code: |
var background: int
background := Pic.New (x1,y1,x2,y2) %%gets the back ground space.
%%then you can draw your block over it...
%%when you do your for loop to move falling block down, draw the back ground where it should been first.
%%for loop stuff
Pic.Draw(background, Xloc, Yloc, picCopy)
%now draw your falling block here
%%you can use View.Update, but try View.UpdateArea :)
%%end loop stuff
|
|
|
|
|
|
![](images/spacer.gif) |
Geostigma
|
Posted: Thu Jan 24, 2008 1:40 am Post subject: RE:Issue with graphics |
|
|
Yes the problem was the whole entire screen would fail to draw my backround, pyramid etc.. I tried different things but I can't get it to work. I would love to try the View.UpdateArea but it doesnt exsist. The screen clears, draws the backround, draws the falling block but erases the pyramid, then redraws everything. I know the cls and the view update is in the wrong place so it causes the block to replicate 700times but thats only because its in rough and not a concern
EDIT i dont have the new v of turing, just updated and I have the View update area
code: | procedure animate (getx, gety : int)
var tempx, tempy : int
tempy := gety * 70
tempx := getx * 70 + (17 * gety)
for decreasing a : 400 .. 70 * (gety - 1) by 1
Pic.Draw (white1, tempx, tempy + a, picCopy)
View.Update
Pic.Draw (white1, tempx, tempy + a, picCopy)
end for
end animate
procedure graphics
for i : 1 .. 36
if triangle (i) = 1 then
Pic.SetTransparentColor (blue1, black)
Pic.Draw (blue1, pictri (i).width1, pictri (i).height1, picMerge)
elsif triangle (i) = 2 then
Pic.SetTransparentColor (white1, black)
Pic.Draw (white1, pictri (i).width1, pictri (i).height1, picMerge)
end if
end for
end graphics
|
|
|
|
|
|
![](images/spacer.gif) |
Geostigma
|
Posted: Thu Jan 24, 2008 2:05 am Post subject: Re: Issue with graphics |
|
|
I'm just attaching my game, see whats up with it
Description: |
|
![](http://compsci.ca/v3/pafiledb/images/icons/clip.gif) Download |
Filename: |
iceblocks.rar |
Filesize: |
3.51 MB |
Downloaded: |
1020 Time(s) |
|
|
|
|
|
![](images/spacer.gif) |
|
|