469,623 Members | 1,683 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,623 developers. It's quick & easy.

Setting a picturebox image at runtime and offsetting

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

Jun 28 '08 #1
3 8480
On Jun 28, 5:50 am, "Jeff Ciaccio" <non...@noreply.orgwrote:
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
Jun 28 '08 #2
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

"kimiraikkonen" <ki*************@gmail.comwrote in message
news:17**********************************@r66g2000 hsg.googlegroups.com...
On Jun 28, 5:50 am, "Jeff Ciaccio" <non...@noreply.orgwrote:

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

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

like that...

Hope this helps,

Onur Güzel

Jun 28 '08 #3
On Jun 28, 5:13 pm, "Jeff Ciaccio" <non...@noreply.orgwrote:
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

"kimiraikkonen" <kimiraikkone...@gmail.comwrote in message

news:17**********************************@r66g2000 hsg.googlegroups.com...
On Jun 28, 5:50 am, "Jeff Ciaccio" <non...@noreply.orgwrote:

'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
Jun 28 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Jeff | last post: by
2 posts views Thread by **Developer** | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.