Simple game

Hey guys, I haven’t given up on gadgeteer yet. I made a little video here of a game that took me 30 minutes to make. I haven’t programed in pressing it too soon or late will end it but its pretty cool I think. I think I might just make it one button and throw in a tunes module. I haven’t programmed the credits in yet either :stuck_out_tongue:

One idea I had also was to take an .wav and convert the waveforms of it to chip tune noise, but I couldn’t find out how to do it in c# for the desktop, so I gave up, if anyone has any insights, like a way to get to the “sound” of a file, please do tell me

When I buy the next bunch of things, ill get the proper mounting kit that goes with this guys, you wont need to deal with my impromptu things for much longer. A practical thing id like to make is a thing that can control your tv, using 2 buttons somehow(one for on off/mute and one for up a channel). An infrared led is 1$ so why not.

Also: is it possible to burn an iso with netmf? is the ram large enough? I could have one usb with the file and another with the usb flash drive I want iso’d
Mass produce flashdrive OS, cause cheap flashdrives

whats the difference between these:
http://www.robotshop.com/ca/en/net-gadgeteer-g248-accelerometer.html
http://www.robotshop.com/ca/en/ghi-accelerometer-module.html

And lastly: Why does roboshop have lots of stuff out of stock there? I cant even get a LCD
http://www.robotshop.com/ca/en/net-gadgeteer-16x2-lcd-display-blue-back-light.html

Sorry for the text wall, I hate waiting 40 minutes for Vimeo:

    Debug.Print("Program Started");
            button.ButtonPressed += button_ButtonPressed;
            button2.ButtonPressed += button2_ButtonPressed;
            cycleLED(true, timy);
            
        }
        int timy = 250;//sleep between led
        void button2_ButtonPressed(Button sender, Button.ButtonState state)
        {
                cycleLED(false, timy);//trial and error
                timy -= 10;   
        }

        void button_ButtonPressed(Button sender, Button.ButtonState state)
        {
                cycleLED(true, timy);
                timy -= 10;
        }

        void cycleLED(bool left, int wait)
        {//sorry if its actually right moving, its hard to find the direction, and it dosent mater much
            if (left)
            {
                for (int i = 0; i < ledStrip.LedCount ; i++)
                {
                    try
                    {
                        ledStrip.SetLed(i - 1, false);
                    }
                    catch { }
                    ledStrip.SetLed(i, true);
                    Thread.Sleep(wait);
                }
            }
            else
            {
                for (int i = ledStrip.LedCount -1; i >= 0; i--)
                {
                    try
                    {
                        ledStrip.SetLed(i + 1, false);
                    }
                    catch { }
                    ledStrip.SetLed(i, true);
                    Thread.Sleep(wait);
                }
            }
3 Likes

@ MRTFEREN - Good to see you having fun. You should post the code and video in the code share section with a small write-up on connecting the components etc.

@ MRTFEREN - Cool game! I think you also set a new NETMF standoff altitude record!

2 Likes

I enjoy seeing creativity. :slight_smile: Great work. If you’ll accept some feedback and/or advice I have a few points for you:

  • Button identifier names. ‘button’ and ‘button2’ might not be very obvious if you were to come back to the code and read it at a later date. Just looking at the code, you might not know which one is the left button or which one is the right button.
  • Hardcoding values, changing the ‘timy’ value by 10 could be done with a const member variable (since there’s no need for it to change in your current code). This way you only have to change the value one time to have it change everywhere else where it’s referenced.
  • You could have one event method, and check the sender to decide whether the function (cycleLED) should be called with true or false, since everything else seems to be the same… It would help avoid writing repetitive code, which is always a bonus in programming!
  • You have ledStrip.SetLed(i, true), and Thread.Sleep(wait); in both code paths for the if statement in your cycleLED function. Why not put that outside of that entire if statement structure? Then you only have to have it written in your code once, and it will execute regardless of what condition is met.
  • If you had some bounds checking, you shouldn’t need to have those try statements in your code that are just used to “ignore” the exception of what I presume is supposed to catch an out of bounds exception?

I’m just getting into the world of Gadgeteer, but I have a history in programming in .NET languages, as well as other non-managed low level and high level languages. :slight_smile:

Other than that, great work! Looking forward to seeing what kind of other games you can come up with.

1 Like