
-----------------------------------
nefer
Mon Jan 13, 2014 5:41 pm

please help on my grade 10 Computer studies final project.  (?&amp;#9633;?&amp;#65307;)
-----------------------------------
What is it you are trying to achieve?

let my screen stop flashing

What is the problem you are having?


It was ok before i added the menu and instruction. But after I combined my menu and the function parts, the screen  is keep on flashing while it is running the game. :( 
Describe what you have tried to solve this problem

I checked my code and everything, I don't know what to do 

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
%The creature program
%my name
%December 8th 2013

setscreen ("graphics:max;max")
setscreen ("nobuttonbar")
var word, start, instruction : string
var font1, font2 : int
var font, xb, yb, notused1, notused2 : int
var background, background2, instructionpage : int

var y, yChange, yMag, width, stickX, stickY, height, jumpheight : int
width := maxx
var yValues : array 1 .. width of int
var chars : array char of boolean
var picship, sprites, obstaclepic : int


%----------------------------------------------------------cover page
background := Pic.FileNew ("358_max.jpg")
background := Pic.Scale (background, maxx, maxy)
font1 := Font.New ("Trajan Pro:100")
word := "Escape"
loop
%-----------------------------------------------------------menu
Pic.Draw (background, 0, 0, picMerge)
Font.Draw (word, 150, maxy div 2, font1, 164)
start := "Pess any key to Begin"
instruction := "Instruction"
font2 := Font.New ("Trajan Pro:30:underline")
Font.Draw (instruction, 900, 200, font2, 164)
buttonwait ("down", xb, yb, notused1, notused2)
%-------------------------------------------------------------instruction
if xb > 900 and xb < 1200 and yb > 200 and yb < 230 then
    instructionpage := Pic.FileNew ("instruction copy.jpg")
    instructionpage := Pic.Scale (instructionpage, maxx, maxy)
    Pic.Draw (instructionpage, 0, 0, picMerge)
    Font.Draw (start, 700, 100, font2, 164)
    end if

    Input.Pause
%------------------------------------------------------------game
%SET THE INITIAL VARIABLES
for lines : 1 .. width
    yValues (lines) := 80
end for
stickX := width div 2
stickY := 120
picship := Pic.FileNew ("ship.bmp")
sprites := Sprite.New (picship)
y := 80


background2 := Pic.FileNew ("334_max.jpg")
background2 := Pic.Scale (background2, maxx, maxy)
var obstacleY : array 1 .. 40 of int
var obstacle := Pic.FileNew ("images.jpeg")
obstacle := Pic.Scale (obstacle, 100, 100)
var obstacleX : int := maxx div 50
randint (obstacleX, 0, maxx)




for i : 1 .. 40
    randint (height, maxy, 2 * maxy)
    obstacleY (i) := height
end for


obstacle := Pic.Scale (obstacle, 100, 100)

% main loop
loop
    %%%%%SECTION FOR DRAWING THE GROUND
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % sets all of the lines back
    for lines : 1 .. width - 1
	yValues (lines) := yValues (lines + 1)
    end for

    % determine height change for next line
    randint (yChange, -1, 1)
    % determines if the change will be magnified, (only 1% of the time)
    randint (yMag, 1, 100)
    if yMag = 1 then % if the change will be magnified, magnify it by a factor of maxy
	yChange *= maxy div 6
    end if

    %checks to make sure the change does not go off the screen, or to the bottom
    if y + yChange > maxy - maxy div 6 or y + yChange < 0 then
	yChange *= -1 % if it does, make the change in the opposite direction
    end if
    % sets the y value of the new line to the value of the previous plus the change
    y += yChange
    yValues (width) := y
    % draw all the lines that make up the ground
    for line : 1 .. width
	drawline (line, 0, line, yValues (line), black)
    end for

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%beans


    for i : 1 .. 40
	% make each arrow fall 1/200th of the screen per round
	obstacleY (i) := obstacleY (i) - maxy div 200
	% if an arrow falls below the screen then...
	if obstacleY (i) < - (maxy div 15) then
	    % set arrow to above the screen, by some random margin
	    % (effects when arrow will come into screen view again)
	    randint (height, maxy, 2 * maxy)
	    obstacleY (i) := height
	end if
	% draw an arror
	Pic.Draw (obstacle, i * maxx div 40, obstacleY (i), picMerge)
    end for % phew, the whole arrow section is over



    Input.KeyDown (chars)

    if chars (KEY_UP_ARROW) then
	stickY := stickY + 8
    end if
    if chars (KEY_RIGHT_ARROW) then
	stickX := stickX + 8
    end if
    if chars (KEY_LEFT_ARROW) then
	stickX := stickX - 8
    end if
    if chars (KEY_DOWN_ARROW) then
	stickY := stickY - 8
    end if

    Sprite.SetPosition (sprites, stickX, stickY, true)
    delay (10)
    if whatdotcolour (stickX, stickY) = black then
	exit
    end if

	% draw the spries
	Sprite.Show (sprites)
	% delay (allows for the computer to process)
	delay (4)
	% update the monitor
	View.Update

	% clear everything
	Pic.Draw (background2, 0, 0, picMerge)  
end loop
Sprite.Hide( sprites )
Pic.Draw (background, 0, 0, picMerge)
end loop








Please specify what version of Turing you are using
4.1

-----------------------------------
Raknarg
Mon Jan 13, 2014 5:47 pm

RE:please help on my grade 10 Computer studies final project.  (?&amp;#9633;?&amp;#65307;)
-----------------------------------
There are so many tutorials on this here. Look up anything that has to do with View.Update and setscreen("offscreenonly")

-----------------------------------
nefer
Tue Jan 14, 2014 9:57 am

RE:please help on my grade 10 Computer studies final project.  (?&amp;#9633;?&amp;#65307;)
-----------------------------------
ok it's fixed, thank you
