Click A PictureBox And Then Move That PictureBox With Keyboard?

Nov 11, 2009

Ok, so I have a new challenge for the D.I.C. Heads. I'm making a simple little game using VB controls. I know it's not the best idea in the world but it'll have to do for now!

Here is whats happening. I've created a class that inherits the PictureBox control that I want to use to place my game pieces on the playing field.

Dim pbArmyUnit(0) As ArmyUnit ' ArmyUnit is a Class that inherits Picturebox now I create the playing pieces at runtime as needed and append them to the array. Player currently buys the units and places them on the playing field.

[Code]...

On a side note how can I look at a stack of pictureboxes all created at runtime to determine whats at a particular location? Example. I move my army unit over top of the picturebox that shows my forest. How can I tell what picturebox I just moved on top of? does that make sense? I don't need code for this just directions on looking at the right info so I can figure it out.

I am creating my terrain at runtime as well since it's randomly generated. and I'm basically making an array of 192 pictureboxes with the appropriate terrain image as well as some other modifiers. Just like with my armies above I've inherited picturebox and created a terrain class array, this way I'm able to add my movement modifiers etc, directly to the picturebox I place on the screen. It's these pieces of terrain that I want to be able to check before allowing the unit to move into them! to get movement costs etc.

View 3 Replies


ADVERTISEMENT

Keyboard Scrolling A Picturebox In VB 2010?

May 20, 2011

I am building an image processing program. As part of this, I have a picturebox, set to AutoSize.

When I load an image larger than the size of the picturebox's container the box automatically expands and shows scroll bars. This is what I want. I can scroll the picturebox using the mouse to click on these, but I would like to be able to scroll the image using the arrow keys. This poses a couple of problems:

1) finding what properties to change or events to raise when a key is pressed. It is a property of the picturbox, or a property of the container?

2) dealing with repeated scrolling while the arrow keys are held. I know I can use keydown to detect that an arrow key has been pressed, but how do I continue to scroll as long as the key is held down?

View 2 Replies

How To Move PictureBox To Set Location

Oct 18, 2009

I am currently working on a game that I want to add squirrels running around at random for me to kick off the form.
Ex..
picturebox.location=200,200
And I set a new location for it, as 5,5, how can iIget the picturebox to move to that coordinate, a few pixels at a time until it gets there, so it looks like my squirrel is running to that location?

View 1 Replies

Making A Picturebox Move Right Then Down?

Apr 27, 2012

I am creating a vending machine that has moving items. My issue is making a certain picturebox move left/right to a specified point, then down to the " Item return" label. I'm using a timer to make the items move. I just cant figure out how to get this item to stop then go down then stop again.

After that I'll display a message telling the user the item is ready. How would i get the item I moved to go back to it's original place?

View 3 Replies

Move A Picturebox In Form

May 17, 2009

I want to move a picturebox in my form.[code]I get an error saying: Cross-thread operation not valid: Control 'PictureBox1' accessed from a thread other than the thread it was created on.

View 4 Replies

Move Picturebox With Keys?

Dec 9, 2009

i am trying to get a picture box to move by using a key on the program microsoft visual basic.net this is my code and i know im wrong..

View 5 Replies

Move Picturebox With Mouse

Jan 25, 2011

I'm making a very simple space invaders game using pictureboxes.The goal is to have the space ship move with the mouse.I tried this code but the space ship simply disappears when I mouse over the form.I only want the spaceship to move along the x axis.[code]

View 9 Replies

Move Picturebox With Mouse?

Aug 28, 2009

I have a form with a picturebox and I want to be able to drag the picturebox up and down with my mouse. I'm currently using a trackbar to move the picturebox up and down like this[code]...

View 9 Replies

Forms :: Set Boundaries For Where Picturebox Can Move?

Jun 11, 2011

I'm using KeyDown to get the picturebox to move around, but I don't know how to keep the boat within the boundaries of the form. So if it hits the side of the form, I want it to just stop.

What control/procedure should I use to do this?

View 14 Replies

Make A Picturebox Move Very Smoothly?

Aug 5, 2010

Is there anyway to make a picturebox move very smoothly, with my code it is very jerky and ruins the jumping effect i am currently using:

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Select Case e.KeyCode
Case Keys.Left

[code]....

View 5 Replies

Move A Panel And A Picturebox At The Same Time?

Jun 29, 2010

Ok i got a problem when ever i move a panel and a picturebox at the same time. Ok well them bolth move but the panel has a image in it and when ever i move it with the picturebox it creates a balck square behind the picturebox and the panel and how can i see it, well it on the top like picturebox.location(20,20) well balck quare.location(0,0) same size as picturebox how do i fix this cause it messes up the image. Here is my code:

[Code]...

View 4 Replies

Move An Image From Picturebox To A Folder?

Jan 15, 2012

Here is my code to save image in a folder,but i am getting this error(a generic error occurred in gdi+).[code]...

View 3 Replies

Move Form With No Border From A PictureBox?

Aug 17, 2009

I made the formborderstyle=None and put a pixturebox in the place of "Title Bar" that gone. I want the PictureBox to act exactly like the title bar, so when move cursor while clicking left button of the mouse inside that PictureBox the form move.[code]....

View 2 Replies

Move Label And Picturebox Togather?

Apr 12, 2012

I have one label and one picture box and i want to move both label and picture box ,when i drag picture box by mouse.

View 2 Replies

Move The Picturebox's Image Like A Map Viewer

Sep 9, 2011

i'm trying to move the picturebox's image Like a Map Viewer (Clicking on button < > ^ V) and the image moves, but i can't make it I want to move the image NOT THE PICTURE BOX

[Code]...

View 4 Replies

Stop PictureBox Move On Collision?

Oct 17, 2009

I Am Trying To Figure Out How To Put A Border On That Rectangle.

View 1 Replies

VS 2008 Move And Resize The Picturebox?

Apr 17, 2012

The end user should be able to move and resize the image in picturebox in the same way as I do in my Form1.vb. (Design) *.

View 3 Replies

Add A Control Like Picturebox Programmatically And Allow User To Move It?

Jun 5, 2012

How to add a control like picturebox programatically and Allow user to move it with mouse? on google but cant find anything. Thats why I am here. In my application user creates a picturebox and a label at runtime by selecting a file from drag drop. User can create as many files he wants. But the problem is that I dont know that how to move both picturebox and label to change their location in a flowlayoutpanel which contains these controls with mouse. I know that how to add a control like picturebox programatically but dont know how to move it. I add picturebox by:

dim picturebox as new picturebox
flowlayoutpanel1.controls.add(picturebox)

View 3 Replies

Forms :: Picturebox - Move The Image By Using The Button?

Feb 17, 2009

I have a problem :

In VB.NET.

Window Application :

I have a form..in that form..there are four buttons and an image (using picBox). That buttons named as "Up", "Down", "Left", "Right".How to move the image by using the button. For example : If I click "Up" button, the image will move upward and so on..

View 15 Replies

Game Programming :: Move An Object Around A Picturebox?!

Jan 2, 2011

how to make a collision between the player object and the wall which is a picturebox

i can move the player object (which is also a picture box) with the arrow keys and i've made it move inside the form border, but the porblem is how to make it stop when it touches the wall (picture box) if im moving left and the left border of the player touched the right border of the wall then it should stop and only the up, down and right keys will be working!!!

View 12 Replies

Make A Picturebox Move Towards Square That Is Red In A 100 By 100 Radius?

Jun 3, 2010

I have a picturebox. Lets say i have 5 ,64 by 64 , squares that are evenly spaced out by 100 by 100. Is it possible to make it were if a pitcturebox finds a red square near it, it will move twords it and then if it finds another square that is red it will move twards that one, and so on ect , ect , ect.

View 2 Replies

Make Arrows Keys Move A Picturebox?

Jul 15, 2011

I have a way of moving a picturebox. I type either 1, 2, 3, or 4 in a textbox. Each number is assigned a direction. Then I click the mouse and the picturebox moves in that direction. This is a little cumbersome for a small video game. Is there a way to assign the four arrow keys to do this?

View 3 Replies

Move A PictureBox Produces Incorrect Results?

Feb 17, 2011

Im working on a board game in vb.net. But Ive stumbled on a problem; for some reason Im not getting the correct location reference when I move my picturebox. Let me explain the procedure; First it locates the current position of Red1 with Red1Top and Red1Left, and assigns a number for its position; intCurrentSpot. Then it adds what ever was rolled from the dice intDieA to the current location; intCurrentSpot and the second case statement moves it to the new location. HOWEVER position 11 reads as position 10 and hence gives the user an incorrect reading to where the dice points. Ive checked the numbers over a thousand times and still getting an incorrect reading, what am I doing wrong or can I use something else to get Red1 location?[code]...

View 12 Replies

Move Dynamic Borderless Form Via PictureBox?

May 7, 2012

From the dynamic form I added. I realized that I can't get a gif animation to run in the form's background. So I thought I'd give it a try by embeding a picturebox on the dynamic form, but it's not working hence why I'm here.

So on my main form (Form1) I have 2 buttons, openfiledialog, and a picturebox. When you click button1 you browse for the an image to display in the picturebox, and when you press button2 as you can see from the code below. It'll open a new form, but what I want is to have the picturebox displayed over the whole form, but also play the gif animation I selected from my main form via Form1 onto the dynamically embeded one, but in the picturebox. Now I can't use it as BackgroundImage so I'm using it as just an Image, but my problem now is I'm unable to move each borderless form, and am unable to close each as well.[code]....

View 1 Replies

Move Dynamic Picturebox Based On Context?

Nov 9, 2011

When i press W, i'm creating a dynamic picturebox of a bullet but i have no clue how to make it move to the target.I can create myself a picturebox and call it picBullet1, but what about bullet 2, 3,4 etc? what should i read/learn?

View 3 Replies

Move Form Change Location Of PictureBox?

Jul 25, 2011

I'm new on VB.Net.When I move my Form,it changes my picture location automatically so i can not Get pixel value correctly and it gives me Error.[code]...

View 5 Replies

Picturebox - Move - Resize And Rotate With Mouse

Jun 17, 2009

My nam's Maurizio and i from italy Sorry for my bad english... is Possibile Move position, resize and rotate a picturebox with Mouse?

View 6 Replies

VS 2010 Grab Picturebox To Move The Form?

Dec 26, 2009

A new journey, A new problem. As I downloaded VS2010 Today, there's a new UI, New Code, new problems.

Now I looked for a code that seemed to work for the VS2008, I found the one .Paul made, but it sure didn't work for me. Is there anyone who managed this on the new 2010? Please tell me.

If there were any confusion what I really wanted, I'll explain.

Mousedown on Picturebox = Move around the form free.

View 5 Replies

Check The Picturebox Location When Move Them Anywhere In Winform Using With Splitcontainer?

Aug 14, 2011

How do I check the picturebox location when I move them anywhere in my winform using with splitcontainer?

Something is like this?

Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
Dim x As Integer

[Code].....

View 6 Replies

VS 2005 Drawing On PictureBox Erase When A Window Move On Front

Dec 25, 2009

I used a picturebox to allow user draw lines by mouse. I used this code in mouse down:


Dim D As New System.Drawing.Pen(DrawingColor, 2)
Dim g As Graphics = PB.CreateGraphics()
g.DrawLine(D, X1, Y1, X2, Y2)

but when a window appear on front of picturebox... its seams that picturebox redraw itself, so drawn lines erased.

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved