Public Class frmCandyMash Dim NewBoard As Graphics Dim KeyBoardOK As Graphics Dim rect As Rectangle Dim stable As Bitmap Dim game As Boolean = True Dim mouseX As Integer Dim mouseY As Integer Dim mouseMapX As Integer Dim mouseMapY As Integer Dim ResWidth As Integer = 265 Dim ResHeight As Integer = 290 Dim TileSize As Integer = 50 Dim Map(100, 100, 10) Dim MapX As Integer = 20 Dim MapY As Integer = 20 Dim Tiles(265, 290) As PictureBox Dim TileImages As Bitmap Private Sub frmCandyMash_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Show() Me.Focus() NewBoard = Me.CreateGraphics stable = New Bitmap(265, 290) candyLoop() End Sub Private Sub candyLoop() Do While game = True Application.DoEvents() DrawGraphics() Loop End Sub Private Sub DrawGraphics() For x = 0 To 4 For Y = 0 To 4 rect = New Rectangle(x * TileSize, Y * TileSize, TileSize, TileSize) NewBoard.FillRectangle(Brushes.Transparent, rect) NewBoard.DrawRectangle(Pens.Black, rect) Next Next NewBoard.DrawRectangle(Pens.Orange, mouseX * TileSize, mouseY * TileSize, TileSize, TileSize) NewBoard = Graphics.FromImage(stable) KeyBoardOK = Me.CreateGraphics KeyBoardOK.DrawImage(stable, 0, 0, 265, 290) NewBoard.Clear(Color.Transparent) End Sub Private Sub frmCandyMash_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick End Sub Private Sub frmCandyMash_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove mouseX = Math.Floor(e.X / TileSize) mouseY = Math.Floor(e.Y / TileSize) MapX = MapX + mouseX MapY = MapY + mouseY End Sub Private Sub btnInstructions_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnInstructions.Click MessageBox.Show("Click 3 matching candies to earn points. The progress bar will go up when points are gained") End Sub End Class
I have all the tiles and stuff, but how can i add pictures into the tiles? I've tried tutorials online, but many of them seem to need pictureboxes...i don't have enough time for adding pictureboxes....
My project is a 5x5 grid, and the user can click on images in the tiles to earn points.
Can someone help me with adding pictures? thanks!
This post has been edited by macosxnerd101: 12 January 2014 - 09:13 PM
Reason for edit:: Please use code tags