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

Username:   Password: 
 RegisterRegister   
 Need Help Making Graphics Move By Themselves In Turing
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
The Lone Ranger




PostPosted: Thu Dec 10, 2009 6:05 pm   Post subject: Need Help Making Graphics Move By Themselves In Turing

I am currently making a game in Turing, and I need to know how to make graphics or pictures fall from the top of the screen by themselves. They also need to fall randomly at any point in the program.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Dec 10, 2009 8:15 pm   Post subject: RE:Need Help Making Graphics Move By Themselves In Turing

When you say "by themselves" I assume you mean "have many pictures move" and the way you do that is that you move one image, then another, then another... Use of loops is helpful.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
The Lone Ranger




PostPosted: Sat Dec 12, 2009 1:06 pm   Post subject: Re: Need Help Making Graphics Move By Themselves In Turing

no, the problem is I dont know how to make my picture move. What I want to have is a picture of an asteroid falling down from the top of the screen. I don't know how to do that. Please help me if you can.
TheGuardian001




PostPosted: Sat Dec 12, 2009 1:47 pm   Post subject: Re: Need Help Making Graphics Move By Themselves In Turing

When you draw a picture using Pic.Draw, two of the parameters you pass to it are the X and Y coordinates of the picture.

If you change these each time you draw, the picture will move.
The Lone Ranger




PostPosted: Sat Dec 12, 2009 1:49 pm   Post subject: Re: Need Help Making Graphics Move By Themselves In Turing

Could you please show me an example program, please. It would really help me out.
Tony




PostPosted: Sat Dec 12, 2009 3:01 pm   Post subject: Re: Need Help Making Graphics Move By Themselves In Turing

TheGuardian001 @ Sat Dec 12, 2009 1:47 pm wrote:
If you change [position] each time you draw, the picture will move.

The Lone Ranger @ Sat Dec 12, 2009 1:49 pm wrote:
Could you please show me an example program, please. It would really help me out.

Turing:

put "Movement is a change in position"
delay(1000)
put "You draw image here "..
delay(1000)
Draw.FillOval(100, maxy-100, 50, 50, red)
delay(500)
put "... and as the time passes ... "..
for x:1..250 by 10
    Draw.Line(150 + x, maxy-100, 150 + x+5, maxy-100, black)
    delay(100)
end for
put "you end up here"
delay(500)
Draw.FillOval(450, maxy-100, 50, 50, blue)
locate(11,1)
put "Movement!"
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
The Lone Ranger




PostPosted: Sat Dec 12, 2009 3:15 pm   Post subject: Re: Need Help Making Graphics Move By Themselves In Turing

Thanks alot for the sample program. But I feel like I should show the real program that I started just for some more help, if you don't mind. I need to get the asteroid to keep falling from the top of the screen, so that who ever is playing can dodge the asteroids. Please help.


View.Set ("graphics:640,427")

var name : string
var chars : array char of boolean
var pic : int := Pic.FileNew ("F:\\images2.jpg")
var backGround : int := Pic.FileNew ("F:\\back.jpg")
var asteroid : int := Pic.FileNew ("F:\\Asteroid.jpg")
var x, y : int
var x1, y1 : int
x := 10
y := 10


randint (x1, 0, 255)
randint (y1, 0, maxx)

for decreasing i : maxy .. 0 by 15

put "Please enter your name player one: " ..
put skip
get name

loop
Pic.Draw (backGround, 0, 0, picCopy)

if backGround = 0 then
put "Unable to load JPEG: ", Error.LastMsg
end if

Pic.Draw (asteroid, x1, y1, picCopy)
if asteroid = 0 then
put "Unable to load BMP: ", Error.LastMsg
end if

loop

Input.KeyDown (chars)

if chars (KEY_RIGHT_ARROW) then
x := x + 5
elsif chars (KEY_LEFT_ARROW) then
x := x - 5
elsif chars (KEY_UP_ARROW) then
y := y + 5
elsif chars (KEY_DOWN_ARROW) then
y := y - 5
end if

if pic = 0 then
put "Unable to load JPEG: ", Error.LastMsg
end if

Pic.Draw (pic, x, y, picCopy)

delay (10)

end loop


end loop

end for

drawfilloval (200, 400, 300, 100, green)
[/quote]
Tony




PostPosted: Sat Dec 12, 2009 3:29 pm   Post subject: RE:Need Help Making Graphics Move By Themselves In Turing

You are drawing the asteroid outside of the loop, always at the same location. You want to draw it together with the player
code:

Pic.Draw (pic, x, y, picCopy)
Pic.Draw (asteroid, x1, y1, picCopy)

And you would obviously have to change the x1/y1 in the same loop as you change x/y.

P.S. there is no need to do "Unable to load JPEG:" checks inside the loop. The check is for loading the image, not drawing it.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
The Lone Ranger




PostPosted: Sat Dec 12, 2009 3:35 pm   Post subject: Re: Need Help Making Graphics Move By Themselves In Turing

Sorry to be a bother, but could you please put the,
Pic.Draw (pic, x, y, picCopy)
Pic.Draw (asteroid, x1, y1, picCopy)

into my program, I'm not exactly sure where you want me to put. I hope you wont mind.
Tony




PostPosted: Sat Dec 12, 2009 3:43 pm   Post subject: Re: Need Help Making Graphics Move By Themselves In Turing

The Lone Ranger @ Sat Dec 12, 2009 3:35 pm wrote:
could you please put the [ code ] into my program

No. Your assignment is to figure this out.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
The Lone Ranger




PostPosted: Sat Dec 12, 2009 3:45 pm   Post subject: Re: Need Help Making Graphics Move By Themselves In Turing

Well then could you please clarify what you want me to do once more please?
Tony




PostPosted: Sat Dec 12, 2009 3:48 pm   Post subject: RE:Need Help Making Graphics Move By Themselves In Turing

You seem to know how to move and draw the player image, so apply the same knowledge to add in the asteroid as well.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
The Lone Ranger




PostPosted: Sat Dec 12, 2009 4:12 pm   Post subject: Re: Need Help Making Graphics Move By Themselves In Turing

Just so I'm clear, what is the desired outcome you want me to achieve?
Tony




PostPosted: Sat Dec 12, 2009 4:37 pm   Post subject: RE:Need Help Making Graphics Move By Themselves In Turing

I'm just giving you hints, so that you can achieve whatever goals you set for yourself. If you are finding things to be too difficult, step back and trying something less ambitious first. If you'd like to challenge yourself, we'll be here to guide you as far as you'd like to go.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
The Lone Ranger




PostPosted: Sat Dec 12, 2009 4:42 pm   Post subject: Re: Need Help Making Graphics Move By Themselves In Turing

I actually have gotten somewhere. But I did not get my desired result yet. Instead of the asteroid falling down fomr the top of the screen, I just get the picture of the asteroid appearing in different parts of the screen, like an array. But i would like to thank you for all of your help so far.
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 2  [ 29 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: