Closed Thread
Results 1 to 4 of 4

Thread: A tiny bit of beginners help

  1. #1
    TheLea is offline Newbie
    Join Date
    Mar 2010
    Posts
    2
    Rep Power
    0

    A tiny bit of beginners help

    Hello there!

    I'm new to programming in C# (And pretty much every other language) and have been fiddling around with a lot of basic stuff such as "Click this button and do this" and textbased games with leaderboards for a time.

    Since I'm new I don't know every rule there is for where certain characters and commands go, and that causes some problems.

    Recently I've been trying to make a small game with keyboard input.
    Hence my plea for help:

    I can't get the darn playingobject to move. It's the first step I've been trying to master, but all I get is torn pieces of hair.
    I don't know how to make something on the screen to move by pressing a key.
    f.e.x I can make a label increase it's width or height by clicking a button, but not move up or down with either button or keypressing.

    I don't have any lines of code to show, I end up starting over and not saving the last project when I try again, it's not like it's a lot of code down the drain.

    I do this in VS10 with the Windows form application preset.

    Is there a kind soul out there who could point me (and the playingobject) in any direction?

    PS: Treat me like a complete newbie, since that's what I am.

    //Simon

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Apr 2009
    Location
    Uppsala, Sweden
    Posts
    9,547
    Blog Entries
    5
    Rep Power
    98

    Re: A tiny bit of beginners help

    Code:
                // Left
                <name of object>.Left += <Move Length>;
    
                // Right
                <name of object>.Left -= <Move Length>;
    
                // Up
                <name of object>.Top -= <Move Length>;
    
                // Down
                <name of object>.Top += <Move Length>;
    Replace <name of object> with the name of your object and <Move Length> with how far you want it to move

  4. #3
    TheLea is offline Newbie
    Join Date
    Mar 2010
    Posts
    2
    Rep Power
    0

    Re: A tiny bit of beginners help

    Thankyou! That was invaluable to me!

    There's only one problem left, I am completly lost when it comes to keyinput.

    I've been searching for tutorials and looking at others problems, but so far I can't get the code to work at all, even though it's compilable.

    f.e.x:
    Code:
     private void keycontrol (Object sender, System.Windows.Forms.KeyEventArgs e)
            {
                switch (e.KeyCode)
                {
                    case Keys.Left:
                        ovalShape1.Left += 100;
                        break;
    
                    case Keys.Right:
                        ovalShape1.Left -= 100;
                        break;
    
                    case Keys.Up:
                        ovalShape1.Top -= 100;
                        break;
    
                    case Keys.Down:
                        ovalShape1.Top += 100;
                        break;
                }
            }
    does nothing.

    (That's code I took off a post somewhere else)

  5. #4
    cdg10620's Avatar
    cdg10620 is offline Programming Expert
    Join Date
    Jun 2009
    Location
    Texas
    Posts
    387
    Blog Entries
    3
    Rep Power
    12

    Re: A tiny bit of beginners help

    Check this out from MSDN. Maybe this will help you. How to: Modify Keyboard Input to a Standard Control
    -CDG10620
    Software Developer

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Tiny cc
    By darknoobie in forum C and C++
    Replies: 1
    Last Post: 09-06-2010, 09:56 PM
  2. Very tiny iframe problem
    By amrosama in forum JavaScript and CSS
    Replies: 9
    Last Post: 10-24-2008, 11:46 AM
  3. Hi5 tiny slideshow code crap...
    By Godiva983 in forum General Programming
    Replies: 1
    Last Post: 06-23-2008, 02:46 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts