Computer Science Canada

I Need Help Please!!!!

Author:  Mark0213 [ 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>

Author:  ProgrammingFun [ 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.

Author:  programmer1337 [ 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

Author:  programmer1337 [ 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 Wink

Author:  Dreadnought [ 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 > 550 then
x := x - 1
end if

Think very carefully about what your program is doing here.

Author:  Mark0213 [ Wed Dec 07, 2011 7:25 pm ]
Post subject:  RE:I Need Help Please!!!!

Thank you for your help Smile, 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

Author:  Mark0213 [ 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!

Author:  Insectoid [ 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.

Author:  Mark0213 [ Wed Dec 07, 2011 7:51 pm ]
Post subject:  RE:I Need Help Please!!!!

Insectoid to me its not

Author:  mirhagk [ 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.

Author:  Tony [ 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.

Author:  Dreadnought [ 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.

Author:  Mark0213 [ 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?

Author:  Mark0213 [ 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 Crying or Very sad

Author:  mirhagk [ 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.

Author:  programmer1337 [ Wed Dec 07, 2011 8:10 pm ]
Post subject:  Re: I Need Help Please!!!!

it isnt rocketscience, and if you think we arent helping you enough go to the submissions or tutorials look for a simple pong game, it should get you to what you need to do

Author:  Tony [ Wed Dec 07, 2011 8:12 pm ]
Post subject:  RE:I Need Help Please!!!!

Dreadnought has a good layout for the game loop. Start filling it out
code:

<variables and stuff here>

loop
  < clear screen > - cls
  < change positions of objects > - need to keep track of current position (x,y) and properties (velocity; you can work with it as velocity_x, velocity_y [b]or[/b] speed + angle; whatever math is easier is up to you)
  < draw objects at their new positions > - Draw.Oval(...
  < time delay to regulate framerate > - delay(some_value) is an easy start, Time.DelaySinceLast makes it smoother, but you can figure that one out later, when you have time
end loop

Author:  Mark0213 [ Wed Dec 07, 2011 8:15 pm ]
Post subject:  RE:I Need Help Please!!!!

Thanks,
loops
string
integers
delays
cls
setscreen graphics
drawfilloval
drawfillbox
moving a single ball going in one path
alternate colours

Author:  Mark0213 [ Wed Dec 07, 2011 8:16 pm ]
Post subject:  RE:I Need Help Please!!!!

Tony, i would do it, but whats velocity x,y, and speed and angle?

Author:  Mark0213 [ Wed Dec 07, 2011 8:18 pm ]
Post subject:  RE:I Need Help Please!!!!

Where would i find submissions again, sorry

Author:  mirhagk [ Wed Dec 07, 2011 8:19 pm ]
Post subject:  RE:I Need Help Please!!!!

well what do those words mean?

EDIT: also mark, note that you can edit your last post. This is preferable to posting several replies in a row

Author:  Mark0213 [ Wed Dec 07, 2011 8:30 pm ]
Post subject:  RE:I Need Help Please!!!!

OMG this is soo hardd, im trying my best! i just need to understand how ... forget this, i give up i cant make a whole bunch of balls move at the same time, i have to face that im garbage at turing and i'll never figure it out

Author:  Tony [ Wed Dec 07, 2011 8:31 pm ]
Post subject:  Re: RE:I Need Help Please!!!!

Mark0213 @ Wed Dec 07, 2011 8:16 pm wrote:
Tony, i would do it, but whats velocity x,y, and speed and angle?

as in, definitions?
Velocity -- speed and direction of motion.
Speed -- change in position, over time.
Angle -- direction in which an object is moving, typically measured in degrees or radians.

Edit: start with getting one ball to move. Second one would be similar. If you do it right (arrays), then you get the Third (and all other) ball for free.

Author:  Mark0213 [ Wed Dec 07, 2011 8:40 pm ]
Post subject:  RE:I Need Help Please!!!!

No as in codes. Tony i was working on your program right? but when i used the first "ball" thing, and made several other copies it only made one of them move, what am i supposed to do with this?

Author:  Tony [ Wed Dec 07, 2011 8:53 pm ]
Post subject:  RE:I Need Help Please!!!!

ops, I made a mistake (edited my previous post now). Velocity is speed + direction. "change in speed or direction, over time." describes acceleration.

e.g.
code:

var velocity_x : int := 5

here we describe velocity just along the x axis.

If the ball is at position X, then the next X position would be X + velocity_x. 0 -> 5 -> 10 -> 15 -> ...

Don't worry about other balls for now. It will just confuse you. Focus on just one.


: