Help Adding a background for loop
Author |
Message |
yumrum
|
Posted: Fri May 29, 2009 7:05 pm Post subject: Help Adding a background for loop |
|
|
What is it you are trying to achieve?
I need to add a background to the loop but i don't know how to do it with out the background flashing when i clear screen in the loop
What is the problem you are having?
i don't know how to do it with out the background flashing when i clear screen in the loop
Describe what you have tried to solve this problem
I have tried putting a Draw.Pic, Draw.FillBox either is good if it dosn't flash like what has happend
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing: |
%TAG GAME
%TWO PERSON must try to touch another person
%First turing game
%FONTS
var font1, font2, font3, font4 : int
font1 := Font.New ("sans serif:18:bold")
font2 := Font.New ("sans serif:36:bold")
font3 := Font.New ("mono:20")
font4 := Font.New ("Palatino:40:Bold,Italic")
var page2 : int := Pic.FileNew ("tag-your-it.bmp")
%pic
var background : int := Pic.FileNew ("My Map 1.bmp")
% Opening Screen
%Music.PlayFileLoop ("Canon.mp3")
setscreen ("graphics:600;600")
Draw.FillBox (1000, 1000, 0, 0, black)
Draw.Text ("TAG UR IT", 190, 500, font2, brightred)
Draw.Text ("The goal is to touch the other player", 120, 450, font1, yellow)
Draw.Text ("A,W,S,D controls the green dot", 140, 400, font1, yellow)
Draw.Text ("Arrow Keys control the red dot", 140, 350, font1, yellow)
Draw.Text ("The Game will begin shortly", 155, 300, font1, yellow)
%Pic.Draw (page2, 200, 0, picMerge)
delay (5000)
cls
%second screen
Draw.FillBox (1000, 1000, 0, 0, black)
Draw.Text ("O resets the screen", 80, 500, font3, yellow)
Draw.Text (" L and K are for invisiblity for red", 10, 450, font3, yellow)
Draw.Text (" E and Q are for invisiblity for Blue", 5, 400, font3, yellow)
Draw.Text (" Red means your it", 80, 350, font3, brightgreen)
delay (2000)
% Setting Screen size
setscreen ("graphics:1200;600")
% Variables
var x, y, x1, y1 : int % positions
% SKILLS
var p1sk : int := 0
var p2sk : int := 0
% Time
var runingtime : int
% People and whose it
var colours, colours2 : int % Colour / if it
var p1 : int := 12 % player 1
var p2 : int := 9 % player 2
var r : int := 1
var z : int := 1
% Score
var p1s, p2s : int := 0
% what things equal
x := 10
y := 10
x1 := 1190
y1 := 590
colours := p1
colours2 := p2
% Movement
var chars : array char of boolean
%runingtime := Time.Elapsed
loop
cls
Input.KeyDown (chars )
%Player 1
if chars (KEY_UP_ARROW) then
y := y + 5
end if
if chars (KEY_RIGHT_ARROW) then
x := x + 5
end if
if chars (KEY_LEFT_ARROW) then
x := x - 5
end if
if chars (KEY_DOWN_ARROW) then
y := y - 5
end if
% Player 2
if chars ('w') then
y1 := y1 + 5
end if
if chars ('d') then
x1 := x1 + 5
end if
if chars ('a') then
x1 := x1 - 5
end if
if chars ('s') then
y1 := y1 - 5
end if
%Glitch fix
if chars ('o') then
x := 10
y := 10
x1 := 1190
y1 := 590
colours := p1
colours2 := p2
p1s := 0
p2s := 0
end if
% Teleport Secret player 1 top right cornor
if chars ('/') then
x := 10
y := 590
end if
% Teleport Secret Player 2 bottom left cornor
if chars ('x') then
x1 := 1190
y1 := 10
end if
% IT p1 % Player 1 going from red to blue
if x < x1 + 15 and x > x1 - 15 and colours = p1 and y < y1 + 15 and y > y1 - 15 then
%Fixing whos it
p1s := p1s + 1
colours := p2
colours2 := p1
r := 0
z := 0
p1sk := 0
p2sk := 0
% Screen set up
setscreen ("graphics:600;600")
Draw.FillBox (1200, 600, 0, 0, black)
Draw.Text ("Player 1 Score", 50, 450, font3, yellow)
%Player 1 score
colorback (7)
color (12)
locatexy (180, 400)
put p1s
%Player 2 score
locatexy (480, 400)
colorback (7)
color (12)
put p2s
Draw.Text ("Player 2 Score", 350, 450, font3, yellow)
% Screen set up
delay (2000)
setscreen ("graphics:1200;600")
%Resetting start spot
x := 10
y := 10
x1 := 1190
y1 := 590
end if
% IT p2 % Player 2 going from red to blue
if x1 < x + 15 and x1 > x - 15 and colours2 = p1 and y1 < y + 15 and y1 > y - 15 then
%Fixing who's it
p2s := p2s + 1
colours := p1
colours2 := p2
z := 1
r := 1
p1sk := 0
p2sk := 0
% Screen Set up
setscreen ("graphics:600;600")
Draw.FillBox (1200, 600, 0, 0, black)
% Player 1 score
Draw.Text ("Player 1 Score", 50, 450, font3, yellow)
colorback (7)
color (12)
locatexy (180, 400)
put p1s
% Player 2 score
locatexy (480, 400)
colorback (7)
color (12)
put p2s
Draw.Text ("Player 2 Score", 350, 450, font3, yellow)
% Screen Set up
delay (2000)
setscreen ("graphics:1200;600")
% reseting start spot
x := 10
y := 10
x1 := 1190
y1 := 590
end if
%Invisiblity
%player 1 invisibility
if chars ('l') and p1sk < 3 then
colours := 0
p1sk := p1sk + 1
end if
if chars ('k') then
if r = 1 then
colours := 12
elsif r = 0 then
colours := 9
end if
end if
%Player 2 invisibitlty
if chars ('e') and p2sk < 3 then
colours2 := 0
p2sk := p2sk + 1
end if
if chars ('q') and z = 1 then
colours2 := 9
end if
if chars ('q') and z = 0 then
colours2 := 12
end if
% SIDES
% pLAYER 1
if x = 1200 then
x := 5
end if
if x = 0 then
x := 1195
end if
if y = 600 then
y := 5
end if
if y = 0 then
y := 595
end if
% Player 2
if x1 = 1200 then
x1 := 5
end if
if x1 = 0 then
x1 := 1195
end if
if y1 = 600 then
y1 := 5
end if
if y1 = 0 then
y1 := 595
end if
% Drawing People
drawfilloval (x1, y1, 10, 10, colours2 )
drawfilloval (x, y, 10, 10, colours )
View.Update
delay (15)
exit when p1s + p2s = 10
end loop
%Music.PlayFileStop
%put "This program has been going for " ,runingtime
|
Please specify what version of Turing you are using
4.1 |
|
|
|
|
|
Sponsor Sponsor
|
|
|
tjmoore1993
|
Posted: Fri May 29, 2009 9:17 pm Post subject: RE:Help Adding a background for loop |
|
|
An easy fix to this is to simply add
The View.Update procedure updates a Run window from an offscreen bitmap. It is used with the command View.Set ("offscreenonly") which prevents the Run window from being updated until the View.Update command is given.
Meaning nothing will flicker if done properly. Apply the View.Update command after you've outputed what you need.
*Example*
Turing: | View.Set ("graphics:600;400,offscreenonly")
for lag : 1 .. maxint
locate (1, 1)
put lag, " : NO LAG"
View.Update % BAM View.Update right there observe it in action as it does not flicker. =D
end for
|
*Edit*
Your code did not contain "offscreenonly" make sure you have added that inorder to use the command View.Update. |
|
|
|
|
|
yumrum
|
Posted: Sat May 30, 2009 9:57 am Post subject: RE:Help Adding a background for loop |
|
|
Thanks |
|
|
|
|
|
|
|