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

Username:   Password: 
 RegisterRegister   
 Help : Drawing balls using arrays
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
MrBleeple




PostPosted: Thu Apr 24, 2014 7:18 pm   Post subject: Help : Drawing balls using arrays

What is it you are trying to achieve?
I am trying to ask the user for how many balls they would like to draw. The ball colours and starting positions will be randomized, and I want the x and y co-ordinates to increase using an array. When it hits the border, they will be bounce off.


What is the problem you are having?
I have no idea how to array, so I am having troubles trying to draw a specific amount of balls.

Describe what you have tried to solve this problem
Tried to learn arrays, read multiple tutorials, didn't help.


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


code:

var col, x, y, BallNumber : int

put "Please enter how many balls would you like"
get BallNumber
delay (200)
cls

var Balls : array 1 .. BallNumber of int
randint (col, 1, 255)
randint (x, 1, 200)
randint (y, 1, 200)

for i : 1 .. BallNumber
    drawfilloval (x, y, 5, 5, col)
    delay (5)
    drawfilloval (x, y, 5, 5, white)
    x := x + 1
    y := y + 1
end for



Please specify what version of Turing you are using
4.1.1

I haven't added the collision system etc. I will do that after, just need to focus on getting the balls to work.
Sponsor
Sponsor
Sponsor
sponsor
Raknarg




PostPosted: Thu Apr 24, 2014 8:00 pm   Post subject: RE:Help : Drawing balls using arrays

Do you know how to do this using only one ball? Each ball has its own x and y coordinates.

An array is just a collection of variables. If you have an array of length 5, think about it in the same way you would 5 different variables.
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  [ 2 Posts ]
Jump to:   


Style:  
Search: