2D array... I need help! (kinda urgent...).
Author |
Message |
Ernest3.14
Professor
Joined: Sat May 18, 2013 1:24 pm Posts: 271 Location: Olympia, WA
|
 Re: 2D array... I need help! (kinda urgent...).
Thought I'd jump in and save Xander *some* writing  In RobotC, there's functions for displaying graphics and sounds. The standard set of provided sounds is different, although there is overlap. You can find the original NXT-G sounds/images in a directory somewhere, I'm sure. But back to the question: "PlaySoundFile(const string &FileName)" will play the sound file you specify. You will have to upload the sound file to the brick first though (I think the file extension is ".rso"). For displaying graphics, check out this link (note that you can choose to display plain text as well; that takes up less memory on the brick): http://www.robotc.net/wiki/NXT_Function ... layRICFile
_________________FTC Team 6424, the 'Oly Cow - Chief programmer. FRC Team 4450, Olympia Robotics Federation (ORF). and also quadrotors. Quadrotors!
|
Thu Jun 06, 2013 11:56 pm |
|
 |
newspaper
Rookie
Joined: Sun May 12, 2013 3:17 pm Posts: 21
|
 Re: 2D array... I need help! (kinda urgent...).
Thank you! About the graphics: there's an Error about the file extension ".ric"... I don't know why. I'll check it later again but try it by yourself. Maybe I'm doing something wrong... Maybe I'm not writing the names of the files as they are. For example - I have not seen any image named "faceclosed"... So I changed the name to Smile01. I think the same problem about the sounds.
|
Fri Jun 07, 2013 12:10 am |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: 2D array... I need help! (kinda urgent...).
I have a terrible memory, I'm worse than one of those, ehh, orange things in a bowl of water. I thought about that: That could work, but you may want to use i instead of x. You need to use nxtDisplayRICFile(nleft, nBottom, sFileName); where filename is the name of the .ric (picture) file. To play a sound, you must use PlaySoundFile(sFileName);One thing you'll have to do before you do that, is set the folder where ROBOTC can find these files. Normally it's set to the folder that is present if you have the LEGO Education version of NXT-G. There is a bug in ROBOTC it seems that stops this from working as it should. What I did as a work-around for this was to create a folder called "Resources" in the folder where I keep all my .c files. From C:\Program Files (x86)\LEGO Software\LEGO MINDSTORMS NXT\engine\Sounds and C:\Program Files (x86)\LEGO Software\LEGO MINDSTORMS NXT\engine\Pictures I copied the sounds and images into this new Resource folder that I created. Next I configured that folder in the preferences, here: I set both the bottom folders to the same folder name, the one I just created. Now when I hit F5, they're automatically uploaded with the program! This is a quick test program to see if it all works: = Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Fri Jun 07, 2013 1:00 am |
|
 |
newspaper
Rookie
Joined: Sun May 12, 2013 3:17 pm Posts: 21
|
 Re: 2D array... I need help! (kinda urgent...).
 |  |  |  | mightor wrote: I have a terrible memory, I'm worse than one of those, ehh, orange things in a bowl of water. Sorry, I didn't quite understand the last part... "orange things in a bowl of water"? What? I thought about that: Actually that's not working... That could work, but you may want to use i instead of x. You need to use nxtDisplayRICFile(nleft, nBottom, sFileName); where filename is the name of the .ric (picture) file. To play a sound, you must use PlaySoundFile(sFileName);One thing you'll have to do before you do that, is set the folder where ROBOTC can find these files. Normally it's set to the folder that is present if you have the LEGO Education version of NXT-G. There is a bug in ROBOTC it seems that stops this from working as it should. What I did as a work-around for this was to create a folder called "Resources" in the folder where I keep all my .c files. From C:\Program Files (x86)\LEGO Software\LEGO MINDSTORMS NXT\engine\Sounds and C:\Program Files (x86)\LEGO Software\LEGO MINDSTORMS NXT\engine\Pictures I copied the sounds and images into this new Resource folder that I created. Next I configured that folder in the preferences, here: I set both the bottom folders to the same folder name, the one I just created. Now when I hit F5, they're automatically uploaded with the program! This is a quick test program to see if it all works: = Xander |  |  |  |  |
OK, thanks. I'll try it in a few days and I'll update if I'll have any problem. I sent you privately the full code. 
|
Fri Jun 07, 2013 3:10 pm |
|
 |
Ernest3.14
Professor
Joined: Sat May 18, 2013 1:24 pm Posts: 271 Location: Olympia, WA
|
 Re: 2D array... I need help! (kinda urgent...).
Ahhh... That's why our cow wouldn't moo last year. I uninstalled NXT-G. 
_________________FTC Team 6424, the 'Oly Cow - Chief programmer. FRC Team 4450, Olympia Robotics Federation (ORF). and also quadrotors. Quadrotors!
|
Fri Jun 07, 2013 9:32 pm |
|
 |
newspaper
Rookie
Joined: Sun May 12, 2013 3:17 pm Posts: 21
|
 Re: 2D array... I need help! (kinda urgent...).
OK guys, I wanna know if there is an option for the code to know when it comes to the last number in every grop. I mean, here is 2d array: image[i][j] = {{1,1,1,1,1,1,1,1,}, {1,1,0,1,0,1,1,0,}} Now, I want when it comes to the 8th to do something but without write it like "when(j == 7)" but more in generally 'cause the I'm gonna change every time the amount of numbers in each group and I don't want every time to change also the number in the condition of the while loop...
|
Sun Jun 09, 2013 12:14 pm |
|
 |
Ernest3.14
Professor
Joined: Sat May 18, 2013 1:24 pm Posts: 271 Location: Olympia, WA
|
 Re: 2D array... I need help! (kinda urgent...).
How are you going to determine the amount of numbers in each group? Because when you declare your array, you'll be using that number. You can just use "if(j==var)", and "image[i][var]" instead. There's no rule forbidding the use of variables other than "i" and "j" 
_________________FTC Team 6424, the 'Oly Cow - Chief programmer. FRC Team 4450, Olympia Robotics Federation (ORF). and also quadrotors. Quadrotors!
|
Sun Jun 09, 2013 12:18 pm |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: 2D array... I need help! (kinda urgent...).
You might want to check that with the Programmers Guild, they're sticklers for this kind of thing. = Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Sun Jun 09, 2013 12:33 pm |
|
 |
newspaper
Rookie
Joined: Sun May 12, 2013 3:17 pm Posts: 21
|
 Re: 2D array... I need help! (kinda urgent...).
I'm gonna change the amount of numbers in each grop by myself... So there's no way just to change the condition also by myself, right?
|
Sun Jun 09, 2013 12:49 pm |
|
|
Who is online |
Users browsing this forum: No registered users and 2 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|