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.
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.
... It doesn't move.i want to make it so the picturebox cant move
... 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.
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.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
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
What do you do in the PictureBox's click event?I have some source code that I used to make the picturebox move
the placableItem is the picture box
What do you do in the PictureBox's click event?
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.Well you done click it at the moment, but I want to make it so the picturebox freezes when it is clicked
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).
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.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"
You're very welcome. Don't give up, once you get into it things like this become much easier.Thanks for your advice! I am trying to learn it
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.
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.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
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.
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..).