Quantcast
Viewing all articles
Browse latest Browse all 2703

INT based array to display as graphic tiles ...

hi, trying to recreate a simple top down view zelda type game in C# I had made in VB6 i had created years and years ago, and then again in Javascript like 2 years ago..
so far all i have is 2 bmps 1 = floor2.bmp
2 = wall2.bmp
1 button
1 function called updateDisplay()

here i have a simple room array...

public partial class Form1 : Form
{
int C=1;
//---ROOM 1----------------------
int[,] Room1 = {
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
};

followed by a simple function for a button to display the room
private void updateDisplay(int r)
{
for (int X = 0; X < 20; X++)
{
for (int Y = 0; Y < 15; Y++)
{
//---------------------------------------------ROOM 1--------
if (r == 1)
{
if (Room1[Y, X] == 1) //wall
{
PictureBox p = new PictureBox();
p.BackColor = Color.Black;
p.Image = Properties.Resources.wall2;
p.Location = new Point(X * 32, Y * 32);
p.Size = new Size(32, 32);
panel1.Controls.Add(p);
}
if (Room1[Y, X] == 0) //floor
{
PictureBox p = new PictureBox();
p.BackColor = Color.White;
p.Image = Properties.Resources.floor2;
p.Location = new Point(X * 32, Y * 32);
p.Size = new Size(32, 32);
panel1.Controls.Add(p);
}
}
}
}
}
and then the button:
private void btnCreate_Click(object sender, EventArgs e)
{
panel1.Size = new Size(32 * 20, 32 * 15);
updateDisplay(C);

}
( i know ill be able to detect walls and such for movement purposes later with the room array )
but right now its in a PANEL and i caint seem to update that panel ..id much rather it draws in the form itself but caint seem to understand how that all works..
ive already learned the key inputs from a previous program/game i have made in C#(sort of like a space exploration vessel)
but would appreciate any help anyone can offer to get me started with TILES in C#..
seems like everywhere i have posted for assistance I eighter get treated ignorantly or "just google C#games making" witch of course brings me to XNA links, but id like to learn more C# first...


Attachment:tileAdventure.rar (75202 bytes | downloaded 6 times)

Viewing all articles
Browse latest Browse all 2703

Trending Articles