i need help getting a picturebox(my character)to move
i need help getting a picturebox(my character)to move
i need help getting a picturebox(my character)to move
i need help getting a picturebox(my character)to move
i need help getting a picturebox(my character)to move
i need help getting a picturebox(my character)to move i need help getting a picturebox(my character)to move i need help getting a picturebox(my character)to move i need help getting a picturebox(my character)to move i need help getting a picturebox(my character)to move i need help getting a picturebox(my character)to move i need help getting a picturebox(my character)to move i need help getting a picturebox(my character)to move
i need help getting a picturebox(my character)to move i need help getting a picturebox(my character)to move
i need help getting a picturebox(my character)to move
Go Back  Xtreme Visual Basic Talk > > > i need help getting a picturebox(my character)to move


Reply
 
Thread Tools Display Modes
  #1  
Old 12-01-2006, 05:13 PM
pojo644 pojo644 is offline
Newcomer
 
Join Date: Oct 2006
Posts: 10
Exclamation i need help getting a picturebox(my character)to move


i need to get a character to move when u use the arrow keys, the character is in a picturebox and i dont know how to do that, and if its not to hard how do i keep the character from going though walls, also in a picturebox
thanks
Reply With Quote
  #2  
Old 12-01-2006, 07:26 PM
Targe Targe is offline
Contributor
 
Join Date: Nov 2006
Posts: 615
Default

If you're using a picturebox you can simply do something like:

picturebox1.top += integer
or
picturebox1.left += integer

You could always use .bottom or .right but I stick with top and left. The top/bottom is your Y-axis while your left/right is your X-axis.

To check if a picturebox collides with a wall you could do a couple things. One is to say something like:

If picturebox1.left < 0 Then picturebox1.left = 0

This will essentially reset the picturebox back to 0 on the X-axis if it gets moved out of bounds on the form (0 could always be replaced with any other number depending.

An easy method to use for pictureboxes to check collision is the IntersectsWith command:

If picturebox1.Bounds.IntersectsWith(picturebox2.Bounds) Then ...you get the picture.

Good luck!
Reply With Quote
  #3  
Old 12-02-2006, 01:00 PM
pojo644 pojo644 is offline
Newcomer
 
Join Date: Oct 2006
Posts: 10
Default

okay well im still have problems would i set the moving in an if statement, and what kind of sub should i use. would i use something like me.pictureboxcharacter.left, cuz im getting errors when i do that
Reply With Quote
  #4  
Old 12-02-2006, 05:27 PM
Targe Targe is offline
Contributor
 
Join Date: Nov 2006
Posts: 615
Default

Don't use Me. Just use picturebox...try putting it in a timer so you can control it's speed. If keydown is pressed, have it set a flag variable so your timer can check it. On the keyup event, change that flag variable so the timer no longer makes it move.
Reply With Quote
  #5  
Old 12-03-2006, 10:39 PM
Volte's Avatar
Voltei need help getting a picturebox(my character)to move Volte is offline
Ultimate Contributor

Retired Leader
* Guru *
 
Join Date: Aug 2001
Posts: 5,344
Default

Rather than using controls to show your sprites, you should look into using the Paint event of the form to draw the scene. The Graphics object passed in with the event (e.Graphics) provides all the facilities necessary to draw shapes, images, perform translations, etc. This will give you full control over the scene and it will be much more efficient than using PictureBoxes.
Reply With Quote
  #6  
Old 12-04-2006, 05:46 AM
Targe Targe is offline
Contributor
 
Join Date: Nov 2006
Posts: 615
Default

It's true Volte but one step at a time. PictureBoxes are much easier to work with for starting.

Pojo, what's the problem? I gave you all the code you could possibly need for what you're trying to accomplish, so what more do you need to know? Just lemme know and I can provide more code if needed. After all, I'm currently working on an RPG with this sort of stuff involved. Admittedly, I'm using PictureBoxes myself because I can't seem to fully grasp the Paint methods.
Reply With Quote
  #7  
Old 12-04-2006, 04:33 PM
pojo644 pojo644 is offline
Newcomer
 
Join Date: Oct 2006
Posts: 10
Default

i need to know how to put the code in to visual basic and stuff like that cuz im not that good at programming yet, i doing stuff from close to the end of the year with making the pictureboxs move,and i have no clue at all, Thanks for your help
Reply With Quote
  #8  
Old 12-04-2006, 04:36 PM
reboot's Avatar
rebooti need help getting a picturebox(my character)to move reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,614
Default

Quote:
Originally Posted by Targe
It's true Volte but one step at a time. PictureBoxes are much easier to work with for starting.

Pojo, what's the problem? I gave you all the code you could possibly need for what you're trying to accomplish, so what more do you need to know? Just lemme know and I can provide more code if needed. After all, I'm currently working on an RPG with this sort of stuff involved. Admittedly, I'm using PictureBoxes myself because I can't seem to fully grasp the Paint methods.
You providing him code on the side completely defeats the purpose of this forum. This site is a repository for learning. If you're going to spoonfeed people, you could at the very least attach your code so others can benefit.
__________________
~ Quod non mortiferum, fortiorem me facit ~

Avatar by lebb
Reply With Quote
  #9  
Old 12-04-2006, 04:36 PM
wayneph's Avatar
waynephi need help getting a picturebox(my character)to move wayneph is offline
Web Junkie

Retired Moderator
* Expert *
 
Join Date: Apr 2004
Location: D/FW, Texas, USA
Posts: 8,393
Default

why don't you post some of the code that you have. it will be a lot easier for us to help if you can show us what you've tried.
__________________
-- wayne, MSSM Retired
> SELECT * FROM users WHERE clue > 0
0 rows returned
Reply With Quote
  #10  
Old 12-04-2006, 07:39 PM
Targe Targe is offline
Contributor
 
Join Date: Nov 2006
Posts: 615
Default

Quote:
Originally Posted by reboot
You providing him code on the side completely defeats the purpose of this forum. This site is a repository for learning. If you're going to spoonfeed people, you could at the very least attach your code so others can benefit.
I gave him what he needed, not the entire program written for him. If you notice other threads, there is much more code given then what I told him. But you're right, he needs to learn, which he doesn't seem to be doing. I don't want to be rude but he asks questions, we answer them, then he asks the same question again. I don't think he's learning...so now what?
Reply With Quote
  #11  
Old 12-04-2006, 10:33 PM
pojo644 pojo644 is offline
Newcomer
 
Join Date: Oct 2006
Posts: 10
Default

what i was doing wrong was not useing the form events so i could not find the key down event, srry guys that is why the code was not working

Last edited by pojo644; 12-04-2006 at 10:45 PM.
Reply With Quote
  #12  
Old 12-04-2006, 11:29 PM
Roger_Wgnr's Avatar
Roger_Wgnr Roger_Wgnr is offline
CodeASaurus Hex

Forum Leader
* Expert *
 
Join Date: Jul 2006
Location: San Antonio TX
Posts: 2,427
Default

Quote:
Originally Posted by Targe
It's true Volte but one step at a time. PictureBoxes are much easier to work with for starting.

Pojo, what's the problem? I gave you all the code you could possibly need for what you're trying to accomplish, so what more do you need to know? Just lemme know and I can provide more code if needed. After all, I'm currently working on an RPG with this sort of stuff involved. Admittedly, I'm using PictureBoxes myself because I can't seem to fully grasp the Paint methods.
Reboot, when Targe said this I think he was refering to post #2 of this thread wher he outlined how to move a picturebox. everything he needed was there but he still had to write the code to get it to work.
__________________
Code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. ~Martin Golding
The user is a peripheral that types when you issue a read request. ~Peter Williams
MSDN Visual Basic .NET General FAQ
Reply With Quote
  #13  
Old 12-05-2006, 12:57 AM
Targe Targe is offline
Contributor
 
Join Date: Nov 2006
Posts: 615
Default

Quote:
Originally Posted by pojo644
what i was doing wrong was not useing the form events so i could not find the key down event, srry guys that is why the code was not working
By the way, if your keydown event sometimes works and sometimes doesn't, it may be from controls on the form taking focus on the keyboard. If this happens let me know because I personally spent over a week trying to figure out how to get around that problem. Wouldn't want anyone going through what I did
Reply With Quote
  #14  
Old 12-05-2006, 12:43 PM
reboot's Avatar
rebooti need help getting a picturebox(my character)to move reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,614
Default

Sorry, I read it as if he'd sent him code on the side. My deepest appologies.
__________________
~ Quod non mortiferum, fortiorem me facit ~

Avatar by lebb
Reply With Quote
  #15  
Old 12-05-2006, 09:03 PM
pojo644 pojo644 is offline
Newcomer
 
Join Date: Oct 2006
Posts: 10
Default

okay guys i dont think im getting this but heres my code
if e.keycode.right then
pictureboxcharacter.right
endif

im getting errors on both lines so mayb im not getting any of my code right, i have put them in the keydown event. my errors are:
Warning 1 Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated. C:\Documents and Settings\Tyler\Desktop\vb\maze v1\maze v1\frmlvl1.vb 5 12 maze v1
and
Error 2 Property access must assign to the property or use its value. C:\Documents and Settings\Tyler\Desktop\vb\maze v1\maze v1\frmlvl1.vb 6 13 maze v1

any and all help will be nice
Reply With Quote
  #16  
Old 12-05-2006, 11:10 PM
Targe Targe is offline
Contributor
 
Join Date: Nov 2006
Posts: 615
Default

Quote:
Originally Posted by pojo644
okay guys i dont think im getting this but heres my code
if e.keycode.right then
pictureboxcharacter.right
endif

im getting errors on both lines so mayb im not getting any of my code right, i have put them in the keydown event. my errors are:
Warning 1 Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated. C:\Documents and Settings\Tyler\Desktop\vb\maze v1\maze v1\frmlvl1.vb 5 12 maze v1
and
Error 2 Property access must assign to the property or use its value. C:\Documents and Settings\Tyler\Desktop\vb\maze v1\maze v1\frmlvl1.vb 6 13 maze v1

any and all help will be nice
Yea, that's not right at all...

What this is saying (Property access must assign to the property or use its value.) is that it needs to equal something. So putting e.keycode.right means nothing to the program. It knows there is an e.keycode.right, but so what? What you want it to ask the computer is, did the user press the right arrow key? So to do that you need to assign it.

if e.keycode = keys.right then

I hate to spoon feed the code to you but I put the explanation above, hopefully you understand it a little more now.

The next part I already gave you code for. It's the same situation. pictureboxcharacter.right means little to the computer, other than the fact that it has a right edge. But so what? Again, you need to assign it something...I already gave the code but here it is again....

pictureboxcharacter.right = pictureboxcharacter.right + 10

this will move the picturebox 10 pixels to the right. Although, an eaiser way to achieve the same as above is to simply say:

pictureboxcharacter.right += 10

Both mean the same thing.

Last edited by Targe; 12-06-2006 at 04:45 AM.
Reply With Quote
  #17  
Old 12-06-2006, 11:42 PM
pojo644 pojo644 is offline
Newcomer
 
Join Date: Oct 2006
Posts: 10
Default

okay so i set it all up but i had to change the right to left because when i use right it says its read only......... and it does not work the same way for up and down...im not suppose to beable to use the right and down and up commands, because that would make the maze really boring
Reply With Quote
  #18  
Old 12-07-2006, 05:18 AM
Targe Targe is offline
Contributor
 
Join Date: Nov 2006
Posts: 615
Default

Quote:
Originally Posted by pojo644
okay so i set it all up but i had to change the right to left because when i use right it says its read only......... and it does not work the same way for up and down...im not suppose to beable to use the right and down and up commands, because that would make the maze really boring
Ah yes, I forgot those were read only...well I only use .right and .bottom for read-only so sorry bout that...

Anyway, like I said before...left is your X-axis and top is your Y-axis. When you subtract from the Y coordinate you are essentially moving that picturebox upwards. And if you add you are moving it downward...basic geometry.

I don't get what you mean: "im not suppose to beable to use the right and down and up commands, because that would make the maze really boring"

??? You're saying you only want to move one direction? Then what's the problem?

Also, I really hate to be rude but I've been repeating myself a lot and you still don't seem to understand some of this. Do you have a book from your class you can get some examples of code from? I'm just not sure you're understanding this is all. You're making progress but perhaps if you looked at some code in your book and followed some examples it would be more clear to you.
Reply With Quote
  #19  
Old 12-07-2006, 04:48 PM
Targe Targe is offline
Contributor
 
Join Date: Nov 2006
Posts: 615
Default

It's ok, but programming isn't really something where you can depend on others constantly for or seeing it done. A lot of programming has to be thought up by you and tried out to see if it works. There will be a lot of trial and error in the process. Don't get discouraged.
Reply With Quote
  #20  
Old 01-11-2007, 10:27 PM
pojo644 pojo644 is offline
Newcomer
 
Join Date: Oct 2006
Posts: 10
Default

well i have given up on it for now but when i got the up and down ones to work it would just keep going but ur character would "blend" in with the background/floor/wall/form
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
i need help getting a picturebox(my character)to move
i need help getting a picturebox(my character)to move
i need help getting a picturebox(my character)to move i need help getting a picturebox(my character)to move
i need help getting a picturebox(my character)to move
i need help getting a picturebox(my character)to move
i need help getting a picturebox(my character)to move i need help getting a picturebox(my character)to move i need help getting a picturebox(my character)to move i need help getting a picturebox(my character)to move i need help getting a picturebox(my character)to move i need help getting a picturebox(my character)to move i need help getting a picturebox(my character)to move
i need help getting a picturebox(my character)to move
i need help getting a picturebox(my character)to move
 
i need help getting a picturebox(my character)to move
i need help getting a picturebox(my character)to move
 
-->