Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 running 2 different loops at the same time
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
324998301




PostPosted: Thu Nov 23, 2017 8:11 pm   Post subject: running 2 different loops at the same time

What is it you are trying to achieve?
I am trying to have the user move the ball while the squares in the background constantly move randomly


What is the problem you are having?
the squares only move when user clicks- you have to constantly click in order to have the squares move


Describe what you have tried to solve this problem
<Answer Here>
I tried incorporating the squares loop in the ball procedure but it did not work

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)

setscreen ("graphics:1650,900")
Draw.FillBox (0, 0, maxx, maxy, 1)


var picWidth, picHeight : int
var newPic : int
var sheen := Pic.FileNew ("C:\\Users\\Family\\Downloads\\Turing 4.1.2\\Turing 4.1.2\\sheen.bmp")


var a : int := maxx div 2
var b : int := maxy div 2
var i : int
var font1 : int
var count : int := 0
var g, h, button : int
var f : int

%Pic.Draw (gorilla, 150, 70, picMerge)

font1 := Font.New ("comicsans:20")

drawfilloval (a, b, 200, 200, 55)
var x : string (1)
Font.Draw ("Use The W,A,S,D Keys ", 700, 500, font1, 23)
Font.Draw (" To Move The Ball", 700, 400, font1, 23)

var r : int
var t : int


procedure other
randint (i, 0, 245)
randint (r, 1, maxx)
randint (t, 1, maxy)

/* picWidth := Pic.Width (sheen)
picHeight := Pic.Height (sheen)

newPic := Pic.Scale (sheen, picWidth div 2,
picHeight div 2)
Pic.Draw (newPic, r, t, picMerge)
Pic.Free (newPic)
*/
drawfillbox (r, t, r + 40, t + 40, i)
end other

procedure alpha
loop
drawbox (maxx - 1572, maxy - 848, 1572, 848, black)
mousewhere (g, h, button)
locate (1, 10)
put "x is: ", g, " y is: ", h
randint (f, 0, 245)

other
other
other
other
other
other
other
other
other
other
other
other
other
other
other
other
other
other
other
other

getch (x)
cls
randint (i, 0, 240)
count := count + 1
%exit when count =100
if x = ("w") then
if b > 848 then
b := b
else
b := b + 50
end if
randint (f, 0, 245)
Draw.FillBox (0, 0, maxx, maxy, f)
drawfilloval (a, b, 40, 40, i)
%Pic.Draw (newPic, a, b, picMerge)
elsif x = "s" then
if b < maxy - 848 then
b := b
else
b := b - 50
end if
Draw.FillBox (0, 0, maxx, maxy, f)
drawfilloval (a, b, 40, 40, i)
%Pic.Draw (newPic, a, b, picMerge)
elsif x = "d" then
if a > 1572 then
a := a
else
a := a + 50
end if
Draw.FillBox (0, 0, maxx, maxy, f)
drawfilloval (a, b, 40, 40, i)
%Pic.Draw (newPic, a, b, picMerge)
elsif x = "a" then
if a < maxx - 1572 then
a := a
else
a := a - 50
end if
Draw.FillBox (0, 0, maxx, maxy, f)
drawfilloval (a, b, 40, 40, i)
%Pic.Draw (newPic, a, b, picMerge)
else
a := maxx div 2
b := maxy div 2
Draw.FillBox (0, 0, maxx, maxy, f)
drawfilloval (a, b, 40, 40, i)
%Pic.Draw (newPic, a, b, picMerge)
end if
randint (i, 0, 240)

end loop
end alpha
alpha


Please specify what version of Turing you are using
<Answer Here>
Turing 4.1.2
Sponsor
Sponsor
Sponsor
sponsor
324998301




PostPosted: Thu Nov 23, 2017 8:16 pm   Post subject: RE:running 2 different loops at the same time

Also does any one have any idea of how to make the ball run more smoothly-
TokenHerbz




PostPosted: Mon Dec 04, 2017 3:17 am   Post subject: RE:running 2 different loops at the same time

look in here for your answers,

http://compsci.ca/v3/viewtopic.php?t=12533

alot of turing info is avialable :

http://compsci.ca/v3/viewtopic.php?t=8808
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: