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

Username:   Password: 
 RegisterRegister   
 How do I enter data into an array quickly?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
undergroundmonorail




PostPosted: Thu May 10, 2012 12:51 pm   Post subject: How do I enter data into an array quickly?

What is it you are trying to achieve?
I'm writing a simple Guitar Hero clone. I decided to store the notes in an array, to make my program cleaner. I looked up a tutorial and implemented a 2D array, with one axis separating the five rows of the note track, and the other being the length of the track. A zero is no note, a one is a note and a two indicates the tail of a long note.


What is the problem you are having?
Yeah, storing the notes in an array to make it cleaner... The majority of my code is setting each of the sections of the array to the correct digit.


Describe what you have tried to solve this problem
I tried setting them all on one line, but Turing complains about the parenthesis, saying "'notes' is not a procedure and cannot be called".


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

Turing:

var notes : array 1 .. 5, 1 .. 427 of int % stores the notes

for i : 1 .. 5 % Sets everything in the array to 0
    for j : 1 .. 427
        notes(i,j) := 0
    end for
end for

notes(1,1) := 1
notes(1,2) := 1
notes(2,2) := 1
notes(3,2) := 1
notes(3,3) := 1
notes(3,4) := 1
notes(4,4) := 1
notes(3,5) := 2
notes(4,5) := 2
notes(3,6) := 1
notes(4,6) := 1
notes(3,7) := 1
notes(4,7) := 1
notes(3,8) := 1
notes(4,8) := 1
notes(4,9) := 1
notes(4,10) := 1
notes(3,11) := 1
notes(4,11) := 1
notes(3,12) := 1
notes(4,12) := 1
notes(4,13) := 1
notes(4,14) := 1
notes(4,15) := 1
notes(3,16) := 1
notes(4,16) := 1
notes(3,17) := 2
notes(4,17) := 2
notes(4,18) := 1
notes(4,19) := 1
notes(4,20) := 1
notes(5,21) := 1
notes(5,22) := 1
notes(4,23) := 1
notes(4,24) := 1
notes(2,25) := 1
notes(3,25) := 1
% ...etc.


Please specify what version of Turing you are using
OpenTuring 1.0.1 (based on Turing 4.1)
Sponsor
Sponsor
Sponsor
sponsor
Raknarg




PostPosted: Thu May 10, 2012 12:55 pm   Post subject: RE:How do I enter data into an array quickly?

So this seems to work. What did you do before?
undergroundmonorail




PostPosted: Thu May 10, 2012 12:59 pm   Post subject: Re: RE:How do I enter data into an array quickly?

Raknarg @ Thu May 10, 2012 1:55 pm wrote:
So this seems to work. What did you do before?


It does work, but doing it this way seems really... wrong. If it's the way it's supposed to be done, I'll keep it like that, but I was hoping there was a better way.
Amarylis




PostPosted: Thu May 10, 2012 1:25 pm   Post subject: RE:How do I enter data into an array quickly?

Try init
Dreadnought




PostPosted: Thu May 10, 2012 1:39 pm   Post subject: Re: How do I enter data into an array quickly?

Either use init as amarylis said or store the notes in a file and read them into an array.
jr5000pwp




PostPosted: Thu May 10, 2012 1:43 pm   Post subject: Re: How do I enter data into an array quickly?

I would recommend saving your songs to text files for easy editing and neater code. You can format your song so its easy to read, and easy to edit. Then you can read this in automatically using a simple loop structure. Alternatively, you can put your assignments into a separate ".t" file and just include it.

See: http://compsci.ca/v3/viewtopic.php?t=12972 and http://compsci.ca/holtsoft/doc/include.html
copthesaint




PostPosted: Thu May 10, 2012 6:55 pm   Post subject: RE:How do I enter data into an array quickly?

Since turing sucks at colors, and I doubt you will use my program: Download Wink

You should make it so the notes are randomly generated and that after a level (song) is completed this like the speed of the notes and length and distance is decreased per level. you wouldnt have to use text documents.
jr5000pwp




PostPosted: Thu May 10, 2012 8:32 pm   Post subject: Re: How do I enter data into an array quickly?

@copthesaint Very nice, upon attempting to play every song in an album simultaneously I noticed that it only supported 10 audio files, is there a way to support more? When I was making my 2d minecraft clone game I ran into the audio issues and this seems very promising(I assume you can use the audio without a separate window opening?)
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: