Computer Science Canada The Flickering Mystery |
Author: | ziggy2shoes [ Sun Nov 05, 2006 11:26 pm ] |
Post subject: | The Flickering Mystery |
Hello! Note: I am an inexperienced programmer. Thank you for taking the time to read this post good sir/ma'am. I am making a game for school. (Aren't we all?) Everything was going fine until somewhere during the throes of coding I seem to have done something to cause the avatar (a .bmp of a zoid) in the game to flicker oddly. Now, not wanting to trouble for help immediately I looked for a case such as mine. I soon discovered an apparantly useful command called View.Update! Great, however, I am not sure where to put this command to stop the flickering, I have tried many positions but to no avail. Alas, I turn to you great heroes of compsci.ca in hope that you might be able to help me, as time permits naturally. Thank you once again and enjoy the rest of your exsistence. Yours enigmatically, Pepito, Supreme Commander of the 18th Homing Pigeon Surveillance Unit THE CODE: Quote: %***********************************
%* * %* Z O I D S : N E M E S I S * %* * %*********************************** %[ Our greatest enemy is often, ] %[ ourselves. ] /* Purpose: An entertaining game based around the fictional world of ZOIDS, a popular line of toys in Japan as well as an animated series. The game is a 2D battle game in which one player fights another play with a ZOID. If you are unfamiliar with ZOIDS and the ZOIDS universe I suggest you search it @ www.wikipedia.org. Thank you. */ /* Created by Joshua Williams (c) 2006 Thank you www.compsci.ca for all your helpful tutorials and info.......... */ %******************************* %* * %* SCREEN SETTINGS * %* * %******************************* % graphic setting and background setscreen ("graphics:max;max,nocursor,title:-= Z O I D S : N E M E S I S =-") %******************************* %* * %* MENU / INTERFACE * %* * %******************************* % font variables var font1 : int var font2 : int var font3 : int var font4 : int var font5 : int % black background colorback (black) cls % ZiggyGames title screen font2 := Font.New ("arial:36") Font.Draw ("ZiggyGames", 350, 325, font2, brightred) delay (500) cls % Enigmatically Presents... title screen delay (500) font1 := Font.New ("arial:36") Font.Draw ("Enigmatically Presents...", 250, 325, font1, brightred) delay (500) cls delay (500) % title logo variables var title1 := Pic.FileNew ("logo1.bmp") var title2 := Pic.FileNew ("logo2.bmp") var title3 := Pic.FileNew ("logo3.bmp") var title4 := Pic.FileNew ("logo4.bmp") % title logo 1 colorback (black) cls delay (1000) for pan1 : -400..375 Pic.Draw (title1, pan1, 250, picMerge) delay (1) end for % title logo 2 for decreasing pan2 : 1000..375 Pic.Draw (title2, pan2, 250, picMerge) delay (1) end for % title logo 3 for pan3 : -400..250 Pic.Draw (title3, 375, pan3, picMerge) delay (1) end for % title logo 4 for decreasing pan4 : 700..250 Pic.Draw (title4, 375, pan4, picMerge) delay (1) end for % top title box line for bar1 : 350..675 drawline (bar1, 420, bar1, 420, brightred) delay (5) end for % right title box line for decreasing bar2 : 420..230 drawline (675, bar2, 675, bar2, brightred) delay (5) end for % bottom title box line for decreasing bar3 : 675..350 drawline (bar3, 230, bar3, 230, brightred) delay (5) end for % left title box line for bar4 : 230..420 drawline (350, bar4, 350, bar4, brightred) delay (5) end for delay (5000) cls % loading screen font4 := Font.New ("arial:16") Font.Draw ("Loading...", 460, 450, font4, yellow) drawbox (359, 399, 651, 426, yellow) for horz : 360 .. 650 drawfillbox (horz, 400, horz, 425, brightred) delay (10) end for delay (500) cls % menu color (white) % button text locatexy (500, 350) put "PLAY" locatexy (300, 200) put "HELP" locatexy (700, 200) put "EXIT" drawbox (maxx - 75, maxy - 75, 0 + 75, 0 + 75, brightred) drawbox (maxx - 125, maxy - 125, 0 + 125, 0 + 125, brightred) drawfill (maxx - 110, maxy - 110, red, brightred) % play button box drawbox (480, 340, 545, 370, brightred) % help button box drawbox (280, 180, 345, 220, yellow) % exit button box drawbox (680, 180, 745, 220, yellow) % menu title var titlefont := Font.New ("system:44") Font.Draw ("Z O I D S : N E M E S I S", 200, maxy - 200, titlefont, yellow) delay (1000) cls %******************************* %* * %* GAMEPLAY * %* * %******************************* % liger variables var rght := Pic.FileNew ("ligerleft.bmp") var lft := Pic.FileNew ("ligerright.bmp") var x, y, spd, check : int % var for input.keydown (key) var key : array char of boolean %sets variables x and y x := 10 y := 50 % boolean movement variables var right : boolean := false var left : boolean := false %zoid procedure draw % zoid left and right movement pics Pic.Draw (rght, x, y - 40, 2) % if's for pic.draw if right = true then Pic.Draw (rght, x, y - 40, 2) end if if left = true then Pic.Draw (lft, x, y - 40, 2) end if %bottom of screen line drawfillbox (0, 0, maxx, 18, grey) end draw %draw procedure (zoid + bottom line) draw View.Update %var check = how high the zoid can go (0) check := 0 %var spd = gravity force (0) spd := 0 loop View.Update %sets key as var for key pressed Input.KeyDown (key) %check is preset to 0 if check = 0 then %if w is pressed (Input.KeyDown), spd = 32 and check = 0 if key (' ') then %var spd = 32 spd := 32 %var check = 0 check := 0 end if end if %Moves Horizontally %d is pressed if key ('d') then left := true right := false %moves figure 5 to the right x := x + 5 %a is pressed elsif key ('a') then right := true left := false %moves figure 5 to the left x := x - 5 end if %height of jump %once y= more then 51 check = 1 if y >= 51 then check := 1 % if y = 50 then check = 0 elsif y = 50 then check := 0 end if %controls the rate of fall (gravity) %divides spd by 2 if greater than 0 if spd > 0 then spd := spd div 2 elsif spd < 0 then spd := spd * 2 end if % if spd = 1 then it is = to -1 if spd = 1 then spd := -1 end if % adds gravity to var y y := y + spd %sets gravity (spd) to 0 when y = less than 50. %if y is more than 50, then y always increases (keeping the figure afloat) if y <= 50 then spd := 0 y := 50 end if %delay delay (50) %clear screen cls %procedure draw draw end loop If necessary I can attach to you a .zip of the whole schidoodle, pictures and all. |
Author: | richcash [ Sun Nov 05, 2006 11:57 pm ] | ||
Post subject: | |||
In order to use View.Update you need to use this :
View.Set is the same command as setscreen, so you could just add the "offscreenonly" part into your existing setscreen statement. |
Author: | DemonZ [ Mon Nov 06, 2006 1:14 am ] | ||
Post subject: | |||
yes u must use the offscreenonly when using View.Set or setscreen, but that will only make a blank page, because everything that was drawn to the screen was copied off the screen and is waiting to paste what was drawn. This is known as animation buffering, so when you call the setscreen or View.Set and are using offscreenonly, make sure you add a View.Update or View.UpdateArea in your main loop followed by a cls to stop all the flickering, like so:
This way it will copy what was drawn to the screen and buffer the animation, making it not flicker. Hope this helps |
Author: | ziggy2shoes [ Mon Nov 06, 2006 9:45 am ] |
Post subject: | |
Excellent show chaps, it worked! Thank you very much. I'd give you some bits but alas, I don't have many. Oh well. Thank you! |