Setting a picturebox image at runtime and offsetting

J

Jeff Ciaccio

I am programming a "craps table", and I would like to randomize where the
dice land.
The first one is no problem. To fit on the "table" I have the following:
picDie1.Location = New Point(Rnd() * 469, Rnd() * 245)

The second die is a little harder. I don't want any overlap of the dice,
and the second die must also fit on the table. The horz. width of the dice
is 80, and the vert. ht. is 100. Any suggestions on this (game or animation
guys)?

I also cannot seem to find the syntax for changing the image. I have
imported the resources, so they are embedded, and they are named die1.bmp,
die2.bmp, die3.bmp, etc.

I tried picDie1.image = "die" &die1 'and tried converting die1 to a
string type.
Suggestions here??

Thanks!
 
K

kimiraikkonen

I am programming a "craps table", and I would like to randomize where the
dice land.
The first one is no problem. To fit on the "table" I have the following:
picDie1.Location = New Point(Rnd() * 469, Rnd() * 245)

The second die is a little harder. I don't want any overlap of the dice,
and the second die must also fit on the table. The horz. width of the dice
is 80, and the vert. ht. is 100. Any suggestions on this (game or animation
guys)?

I also cannot seem to find the syntax for changing the image. I have
imported the resources, so they are embedded, and they are named die1.bmp,
die2.bmp, die3.bmp, etc.

I tried picDie1.image = "die" &die1 'and tried converting die1 to a
string type.
Suggestions here??

Thanks!

--
Jeff Ciaccio
Physics and AP Physics Teacher
Sprayberry High School; Marietta, GA
Blog:http://sprayberry.typepad.com/ciaccio

'To set a new image from file location, you location property

picDie1.ImageLocation = "c:\die1.bmp"

like that...

Hope this helps,

Onur Güzel
 
J

Jeff Ciaccio

What if I have imported the files into my Resources so I can embed the
images with the app? Will it include the project name or maybe the form
name in its qualifier?

Thanks a bunch!
- Jeff


'To set a new image from file location, you location property

picDie1.ImageLocation = "c:\die1.bmp"

like that...

Hope this helps,

Onur Güzel
 
K

kimiraikkonen

What if I have imported the files into my Resources so I can embed the
images with the app? Will it include the project name or maybe the form
name in its qualifier?

Thanks a bunch!
- Jeff



'To set a new image from file location, you location property

picDie1.ImageLocation = "c:\die1.bmp"

like that...

Hope this helps,

Onur Güzel

I'm not such familiar with resources for now, but after you add and
embed a image into your resources you can call it using:

' Assuming your image is named "Image1"
PictureBox1.Image = My.Resources.Image1

HTH,

Onur Güzel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top