[Need Help] PC Programming

Discussion in 'Other Consoles & Oldies' started by rob graham, Feb 22, 2013.

  1. rob graham
    OP

    rob graham Gamer, Programmer, Music Editor and GFX Designer!

    Newcomer
    29
    2
    Feb 21, 2013
    UK
    I am creating a game with Visual Basic. I know everyone will probably be saying that I should use C++ or something else to create my game but I was wondering if I could make a picturebox lock in it`s position without an IOException popping up.
     


  2. fafaffy

    fafaffy GBAtemp Fan

    Member
    331
    160
    Sep 1, 2012
    United States
    Lock in it's position? What do you mean by that? Elaborate.

    You can always grab the x/y coordinate of the form, and adjust the position of the picturebox according to the forms position.

    Still, gaming in Visual Basic is a big no no.
     
  3. GeorgeFoulds

    GeorgeFoulds BrokenGeode

    Newcomer
    33
    5
    Aug 21, 2012
    Leeds
    Don't do games with VB, that's a definite no-no. What languages do you know other than VB. I'm still learning Java and haven't tried C++/# yet so I can't help you on the technical front, but I can help you find a more fitting language.
     
  4. rob graham
    OP

    rob graham Gamer, Programmer, Music Editor and GFX Designer!

    Newcomer
    29
    2
    Feb 21, 2013
    UK
    I have a increasing knowledge on Java and a very limited language on C++
     
  5. rob graham
    OP

    rob graham Gamer, Programmer, Music Editor and GFX Designer!

    Newcomer
    29
    2
    Feb 21, 2013
    UK
    i want to make it so the picturebox cant move
     
  6. fafaffy

    fafaffy GBAtemp Fan

    Member
    331
    160
    Sep 1, 2012
    United States
    ... It doesn't move.

    If I move the form, the picture box is still 30px to the right and 50px to the bottom from the form.

    Elaborate exactly what you're doing, you're too vague.
     
  7. rob graham
    OP

    rob graham Gamer, Programmer, Music Editor and GFX Designer!

    Newcomer
    29
    2
    Feb 21, 2013
    UK
    I have it so when you press W,A,S,D it moves the picturebox 10px at a time. I want it so when you click on the picturebox, it freezes its position and it cant be moved
     
  8. McHaggis

    McHaggis Fackin' Troller

    Member
    1,715
    939
    Oct 24, 2008
    To the people already saying don't make games with Visual Basic: you probably have no idea what you're talking about. It depends on what type of game and what the point of creating it is. If it's a glorified version of Minesweeper, then there's no advantage to making the game in something else. Even if it's intended to be a full-scale game utilising graphics, there's nothing particularly wrong with Visual Basic if you're using .NET; in fact, XNA, Windows Phone and―if you want,―Windows RT games are coded using the .NET framework. The former two can only be programmed using the .NET framework.

    As for the original question, you need to clarify a little. My VB-fu is very old, it's a fair few years since I've touched it, but IIRC PictureBox objects aren't movable by default. You might want to try asking on http://stackoverflow.com (make sure you add as much detail as you can, including source code, otherwise your question will get down voted).

    I'd suggest setting a boolean flag when the PictureBox is clicked, and checking that flag in your key event. If the flag is false, then move the PictureBox. If you posted your code it might be a little easier to help.
     
  9. rob graham
    OP

    rob graham Gamer, Programmer, Music Editor and GFX Designer!

    Newcomer
    29
    2
    Feb 21, 2013
    UK
    I have some source code that I used to make the picturebox move
    Code:
        Private Sub Search_KeyDown5(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
            If e.KeyCode = Keys.W Then
                placableItem.Visible = True
                placableItem.Top -= 10
            ElseIf e.KeyCode = Keys.S Then
                placableItem.Visible = True
                placableItem.Top += 10
            ElseIf e.KeyCode = Keys.A Then
                placableItem.Visible = True
                placableItem.Left -= 10
            ElseIf e.KeyCode = Keys.D Then
                placableItem.Visible = True
                placableItem.Left += 10
            End If
        End Sub
    the placableItem is the picture box
     
  10. McHaggis

    McHaggis Fackin' Troller

    Member
    1,715
    939
    Oct 24, 2008
    What do you do in the PictureBox's click event?
     
  11. rob graham
    OP

    rob graham Gamer, Programmer, Music Editor and GFX Designer!

    Newcomer
    29
    2
    Feb 21, 2013
    UK
    Well you done click it at the moment, but I want to make it so the picturebox freezes when it is clicked
     
  12. McHaggis

    McHaggis Fackin' Troller

    Member
    1,715
    939
    Oct 24, 2008
    Without meaning to offend, I think you need to start with some simple tutorials before you make your game. We're talking about a very basic task that is easily solvable even by beginners to programming. If you're stuck on this, imagine how you're going to accomplish more complex tasks when you come to them. Like I said, I don't mean to offend, and it's a good idea to learn whilst doing, but if you have to ask how to do everything every step of the way then you're not really going to learn anything. More often than not, if you ask a question that equates to "Please do my work for me", you'll get shunned or treated with contempt on a lot of sites.

    If you're looking at multiple clickable/movable objects, I'd recommend a global pointer to the currently selected object. During the click event of each object, make sure that global pointer is set to the clicked object. Then change your key event to set the properties on the global, unless it's Null (in which case just return).
     
  13. rob graham
    OP

    rob graham Gamer, Programmer, Music Editor and GFX Designer!

    Newcomer
    29
    2
    Feb 21, 2013
    UK
    Thanks for your advice! I am trying to learn it
     
  14. Coto

    Coto GBAtemp Addict

    Member
    2,353
    403
    Jun 4, 2010
    Chile
    VB is just a handful shortcuts to what users would call "guided input data". C# (.net) would be much better because, you can actually code in C and that compiling gets executed by the machine, at the fastest speed possible. VB is just a "frontend with limited functions"

    To code a game, you need knowledge on streaming data structures, gathering data structures, assembly if possible to get the best of the target machine (so any clock/feature of the machine isn't wasted), and coding in a main loop.
     
  15. McHaggis

    McHaggis Fackin' Troller

    Member
    1,715
    939
    Oct 24, 2008
    That's a common misconception, Visual Basic 5 and later had the option of compiling to machine code rather than an interpreted language. In .NET, there's absolutely no compilation difference between Visual Basic and C#. They're functionally equivalent languages with different syntax and operators. They're both compiled to Common Intermediate Language (CIL), which is then JIT compiled to machine code at runtime.

    You're very welcome. Don't give up, once you get into it things like this become much easier. :)
     
  16. Coto

    Coto GBAtemp Addict

    Member
    2,353
    403
    Jun 4, 2010
    Chile
    C# != oldie VB

    Also, VB (not under C#,nor compiled into CRL, but the older VB that didn't belong to .net framework) is just a gui with fixed functions. My point was, even if the oldie VB was compiled to the target machine, and had some "network functions", you have no control over what you wanted to code. A game structure (say, a game that will deploy rendering actual 3D or 2D), will make use of sounds, and such. requires at least running in a main loop, memory management, pointers [so fast seeks or database-like data can be stored], and the code itself if you're dealing with raw data
     
  17. McHaggis

    McHaggis Fackin' Troller

    Member
    1,715
    939
    Oct 24, 2008
    Go school yourself on DirectX in Visual Basic. Main loops, self-managed memory and pointers aren't required to create games, that's just absurd. To make a cutting edge game with astounding graphics and physics, then yes, a lower-level language such as C or C++ would be recommended.

    My point was that your technical claims about VB were incorrect. It's possible to do many things in VB that you wouldn't benefit much more from other languages, because you don't need a sledgehammer to knock in a nail.
     
  18. Coto

    Coto GBAtemp Addict

    Member
    2,353
    403
    Jun 4, 2010
    Chile
    I don't need school to learn, no need to insult me either. Or is that what you all do when you're a bit cornered? It's not absurd at all. If you could point me, to what VB (not .NET/ C#), could do better than C++,C, asm, enlighten me.

    VB (oldie), could be considered a gui with few functions so new coders could join the coding world, or code proyects by using OO environments. (VB is pretty much the father of today's Object Oriented IDEs). But that's it. Again, no need to mention C# with its CRL bytecode translator, because that's part of .NET which is different from the old Visual Basic IDEs you used to create code back in 90's


    If you want to develop a full fledged game requiring custom ideas to happen, you'll need either C, C++ or C# (asm too..).
     
  19. Rydian

    Rydian Resident Furvert™

    Member
    27,883
    8,108
    Feb 4, 2010
    United States
    Cave Entrance, Watching Cyan Write Letters
    Game Maker.

    Your argument is now invalid. :)
     
    Scuba156 and McHaggis like this.
  20. rob graham
    OP

    rob graham Gamer, Programmer, Music Editor and GFX Designer!

    Newcomer
    29
    2
    Feb 21, 2013
    UK
    I am only making a simple 2d RPG Game, it doesn`t need to be special. It doesn`t need the complex things that C, C++ or C# have, Visual Basic seems pretty fine at the moment. I am using Visual Basic to see how good of a game I can make in Visual Basic. No need for any more arguing over programming languages. Anyway the game is made by me, no one will stur me in a different direction, what so ever. So there.......... done!
     
    Scuba156 likes this.