Fun little program

Discussion in 'Computer Science & Culture' started by domesticated om, Dec 17, 2006.

Thread Status:
Not open for further replies.
  1. domesticated om Stickler for details Valued Senior Member

    Messages:
    3,277
    I'm a novice programmer that's been working with VB.net. This weekend, I've started learning C#. It's interesting for the most part, but the only thing I've learned is how to create simple forms with different kinds of standard controls (textboxes, radio buttons, checkmark boxes, etc).

    I want to do something fun now.

    Here is my idea---- I want to make a windows form. On the right top corner will be two two buttons labeled "start" and "stop". The majority of the form to the right will be a square white space with a small black circle in it.

    When I click start, I want the white circle to move horizontally from one side of the white square to the other. When I click "stop" I want it to stop moving.


    I don't want the code for doing this, but you can post small snippits if needed that explain the basic gist.
    Is this even possible with C#?
     
    Last edited: Dec 17, 2006
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. Voodoo Child Registered Senior Member

    Messages:
    1,296
    I don't know C#, but the basic gist would be to have a thread that redraws the circle and have the buttons start and stop this thread. Or you could have the redrawing thread investigate the state of the buttons.
     
  4. Google AdSense Guest Advertisement



    to hide all adverts.
  5. Alva Urbanus et instructus Registered Senior Member

    Messages:
    163
    For this personally i would use flash.
     
  6. Google AdSense Guest Advertisement



    to hide all adverts.
  7. domesticated om Stickler for details Valued Senior Member

    Messages:
    3,277
    How would you go about defining the circle?
     
  8. domesticated om Stickler for details Valued Senior Member

    Messages:
    3,277
    I don't currently have a copy of Studio, but I would love to learn to work with Flash
     
  9. Kunax Sciforums:Reality not required Registered Senior Member

    Messages:
    2,385
    oh i thought this thread would be about fun little programs, anyway is my suggestion for a simple old school fun little program.: http://games.acont.de/Detailed/32.html

    play it with a friend, or try playing 2 worms at once
     
  10. domesticated om Stickler for details Valued Senior Member

    Messages:
    3,277
    I know ya mean well, but I'm trying to 'write' an application....that is unless the link you posted is a list of programming tutorials. It looks like a list of downloadable games. If you have any ideas for fun novice-level C# projects, then I would love to check it out.
     
  11. zanket Human Valued Senior Member

    Messages:
    3,777
    It is doable in C#. When you click Start, you enter a loop that ends only when a variable is set to True. Clicking Stop sets the variable to True. The circle is assigned an initial position just before the loop. Within the loop, the circle is drawn, wait a little bit, the circle is removed, the assigned position is slightly changed, repeat. Since you want the circle to remain when you click Stop, exit the loop after the circle is drawn and before it is removed. You could have the circle move randomly and bounce off the walls of the box.
     
  12. superluminal I am MalcomR Valued Senior Member

    Messages:
    10,876
    Everything is possible with C# or C++ (my language of choice).

    Place a timer object on your form and set it for about 100ms. In your start button handler enable the timer. Disable it in your stop button handler
    (timer1->enable = true/false or timer1.enable = true/false).

    In the timer routine, increment the x coordinate of your circle position, then call Invalidate(). This will cause your form's OnPaint handler to be invoked.

    In this handler call your circle draw routine. This will cause the form to be redrawn with the circle at the new position. This may flicker a bit, but who cares, right?

    It's even easier if you have a managed circle object you can place. Then you don't even have to call Invalidate() or draw it. Just update the X coordinate in your timer handler.
     
  13. river-wind Valued Senior Member

    Messages:
    2,671
  14. superluminal I am MalcomR Valued Senior Member

    Messages:
    10,876
    GDI. Win API. .NET. Fun, fun, fun.
     
  15. Alva Urbanus et instructus Registered Senior Member

    Messages:
    163


    I wouldn't quite say anything is possible with C, i tend to run into problems often with it actually. But I'll agree 100% on you with it being my favorite langauge.
     
  16. c7ityi_ Registered Senior Member

    Messages:
    1,924
    how do you program programs which can program programs?
    magic?
     
  17. superluminal I am MalcomR Valued Senior Member

    Messages:
    10,876
    Yes. It's called the "magic" of metaprogramming or adaptive programming.
     
  18. Alva Urbanus et instructus Registered Senior Member

    Messages:
    163

    It depends, if you wanted to make a pretty dumb one you could. More complex ones come with exactly what they sound like.
     
Thread Status:
Not open for further replies.

Share This Page