Posted: Wed Dec 07, 2011 6:41 pm Post subject: I Need Help Please!!!!
What is it you are trying to achieve?
<Replace all the <> with your answers/code and remove the <>>
I really need help creating a mini-game with basic things we just learned basic turing codes
of how to make a game, where you have a paddle, and balls fall down the screen
and when it hits the paddles, it bounces back, can someone please help me, or if you have
a previous code can you message it to me, i really need help
What is the problem you are having?
<Answer Here>
Describe what you have tried to solve this problem
<Answer Here>
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing:
<Add your code here>
Please specify what version of Turing you are using
<Answer Here>
Sponsor Sponsor
ProgrammingFun
Posted: Wed Dec 07, 2011 6:48 pm Post subject: Re: I Need Help Please!!!!
Mark0213 @ Wed Dec 07, 2011 6:41 pm wrote:
What is the problem you are having?
<Answer Here>
Describe what you have tried to solve this problem
<Answer Here>
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing:
<Add your code here>
Please specify what version of Turing you are using
<Answer Here>
You need to answer these questions, we are not here to do the work for you, we are here to help you do it yourself.
If you have any specific questions, ask away, and we can help you get started.
programmer1337
Posted: Wed Dec 07, 2011 6:54 pm Post subject: Re: I Need Help Please!!!!
this is rough code for a wall not a paddle i think you could customize for yourself
code:
View.Set ("graphics:1000;800,offscreenonly")
var x, y : int % coordiantes for ball
var px,py,px1,py1:int % coordinates for paddle
x := 300
y := 200
px := 550
py := 100
px1 := 600
py1 := 300
loop
cls()
x := x + 1
if x > 550 then
x := x - 1
end if
Draw.FillOval(x, y, 10, 10, black)
Draw.FillBox(px, py, px1, py1, black)
View.Update()
end loop
programmer1337
Posted: Wed Dec 07, 2011 7:01 pm Post subject: Re: I Need Help Please!!!!
actually scratch that you can use it for animation but it wont work for moving it back
Dreadnought
Posted: Wed Dec 07, 2011 7:17 pm Post subject: Re: I Need Help Please!!!!
programmer1337 wrote:
but it wont work for moving it back
Turing:
x := x + 1 if x > 550then
x := x - 1 endif
Think very carefully about what your program is doing here.
Mark0213
Posted: Wed Dec 07, 2011 7:25 pm Post subject: RE:I Need Help Please!!!!
Thank you for your help , but i was wondering, how would you make balls move at different speeds and locations from the left of the screen to the right, i got the whole background, and the pad at the screen. Basically the user controls a pad on the right side, they navigate up and down, and then balls come from the left side and with the pad the user is supposed to come in contact with the balls (moving at different speeds and locations which i need help with) then it returns to the left and dissapears
Mark0213
Posted: Wed Dec 07, 2011 7:28 pm Post subject: RE:I Need Help Please!!!!
I just need help with a simple code for moving the balls from the left side of the screen to the right side of the screen at a pretty slow speed where the pad moves up and down and tries to hit the balls back,
so that it returns to the other side of the screen again, i got the pad and the background covered its just the moving balls i have problems with-Thanks everyone for your support it means alot, and im horrible at turing!
Insectoid
Posted: Wed Dec 07, 2011 7:43 pm Post subject: RE:I Need Help Please!!!!
If you understand the most basic movement fundamentals of moving something across the screen, this should be trivial.
Sponsor Sponsor
Mark0213
Posted: Wed Dec 07, 2011 7:51 pm Post subject: RE:I Need Help Please!!!!
Insectoid to me its not
mirhagk
Posted: Wed Dec 07, 2011 7:58 pm Post subject: RE:I Need Help Please!!!!
So mark, you are trying things too advanced if you don't. That's fine, but you need to spend some time on earlier topics.
Tony
Posted: Wed Dec 07, 2011 8:00 pm Post subject: RE:I Need Help Please!!!!
ok, lets start with the very basics then. To "move" something across the screen, you take that something, and draw it at different locations, as the time passes by. (speed is displacement over time)
code:
for x : 1 .. 100
Draw.Oval(x,100,5,5,red)
delay(10)
end for
This is the simplest way -- draw a circle a bunch of times, as it "moves" in a straight line. Different velocities (speed, direction) would dictate where to draw that circle next.
Posted: Wed Dec 07, 2011 8:02 pm Post subject: Re: I Need Help Please!!!!
Think about what is happening physically to the ball (Tony beat me to this)
If the speed was zero, then its position would not change. If it's speed is not zero then its position is changing (hmm... I smell variables) by some amount every frame (you could think in seconds too). So lets say you want the ball to go across the screen (500 pixels wide in this example) in 100 frames (normally animations run at 24, 30 or 60 frames per second). How many pixels do you want your ball to move each frame? The answer is a number of pixels per frame, which is a speed. (I'm sorry if this is obvious).
So now we got a ball moving at a speed. How can we make many balls move at different speeds? Well you gotta keep track of all of their positions and speeds. Arrays are nice for this (records too if you know them).
The general layout is
code:
loop
< clear screen >
< change positions of objects >
< draw objects at their new positions >
< time delay to regulate framerate >
end loop
Also, if you don't already, using offscreenonly, View.Update and Time.DelaySinceLast is very good for making animations look nice.
Mark0213
Posted: Wed Dec 07, 2011 8:05 pm Post subject: RE:I Need Help Please!!!!
Thanks guys, but for making it a ball, i must put a delay, and then draw tonys circle code, except with the colour of 0 at the end of the program?
Mark0213
Posted: Wed Dec 07, 2011 8:07 pm Post subject: RE:I Need Help Please!!!!
but with tonys program when i try to make more then one ball move at the same time it wont even let me? im trying my best to understand sorry guys
and tony, how did you have x, when you didnt even declare it? or did you.. man i suck
mirhagk
Posted: Wed Dec 07, 2011 8:10 pm Post subject: RE:I Need Help Please!!!!
That was a for loop, just so we know, what concepts have you covered?
And you need to make sure you draw both balls in the same loop, otherwise it will draw one, and then the other.