Posted: 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
Tony
Posted: 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.
Posted: 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
Posted: 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
Posted: 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
Posted: 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..250by10 Draw.Line(150 + x, maxy-100, 150 + x+5, maxy-100, black) delay(100) endfor put"you end up here" delay(500) Draw.FillOval(450, maxy-100, 50, 50, blue) locate(11,1) put"Movement!"
Posted: 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
Posted: 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.
Posted: 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
Posted: 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.
Posted: 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.