[Need Help] PC Programming

rob graham

Gamer, Programmer, Music Editor and GFX Designer!
OP
Newcomer
Joined
Feb 21, 2013
Messages
29
Trophies
0
Location
UK
XP
77
Country
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.
 

fafaffy

Well-Known Member
Member
Joined
Sep 1, 2012
Messages
345
Trophies
0
XP
717
Country
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.
 

GeorgeFoulds

BrokenGeode
Newcomer
Joined
Aug 21, 2012
Messages
33
Trophies
0
Location
Leeds
XP
181
Country
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.
 

rob graham

Gamer, Programmer, Music Editor and GFX Designer!
OP
Newcomer
Joined
Feb 21, 2013
Messages
29
Trophies
0
Location
UK
XP
77
Country
I have a increasing knowledge on Java and a very limited language on C++
 

rob graham

Gamer, Programmer, Music Editor and GFX Designer!
OP
Newcomer
Joined
Feb 21, 2013
Messages
29
Trophies
0
Location
UK
XP
77
Country
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.

i want to make it so the picturebox cant move
 

rob graham

Gamer, Programmer, Music Editor and GFX Designer!
OP
Newcomer
Joined
Feb 21, 2013
Messages
29
Trophies
0
Location
UK
XP
77
Country
... 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 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
 

McHaggis

Fackin' Troller
Member
Joined
Oct 24, 2008
Messages
1,749
Trophies
0
XP
1,466
Country
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 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
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.
 

rob graham

Gamer, Programmer, Music Editor and GFX Designer!
OP
Newcomer
Joined
Feb 21, 2013
Messages
29
Trophies
0
Location
UK
XP
77
Country
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
 

McHaggis

Fackin' Troller
Member
Joined
Oct 24, 2008
Messages
1,749
Trophies
0
XP
1,466
Country
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).
 

rob graham

Gamer, Programmer, Music Editor and GFX Designer!
OP
Newcomer
Joined
Feb 21, 2013
Messages
29
Trophies
0
Location
UK
XP
77
Country
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).

Thanks for your advice! I am trying to learn it
 

Coto

-
Member
Joined
Jun 4, 2010
Messages
2,979
Trophies
2
XP
2,565
Country
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.
 

McHaggis

Fackin' Troller
Member
Joined
Oct 24, 2008
Messages
1,749
Trophies
0
XP
1,466
Country
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"
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.

Thanks for your advice! I am trying to learn it
You're very welcome. Don't give up, once you get into it things like this become much easier. :)
 

Coto

-
Member
Joined
Jun 4, 2010
Messages
2,979
Trophies
2
XP
2,565
Country
Chile
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.

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
 

McHaggis

Fackin' Troller
Member
Joined
Oct 24, 2008
Messages
1,749
Trophies
0
XP
1,466
Country
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.
 

Coto

-
Member
Joined
Jun 4, 2010
Messages
2,979
Trophies
2
XP
2,565
Country
Chile
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..).
 

rob graham

Gamer, Programmer, Music Editor and GFX Designer!
OP
Newcomer
Joined
Feb 21, 2013
Messages
29
Trophies
0
Location
UK
XP
77
Country
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..).

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!
 
  • Like
Reactions: Scuba156

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    NinStar @ NinStar: where are my cute girls