Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

INT based array to display as graphic tiles ...

cSharpNewBEEcSharpNewBEE Posts: 2Member
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
{
[b] int C=1;
[/b] //---ROOM 1----------------------
[b] int[,] Room1 = {
[/b] {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 [color=Blue]would appreciate any help anyone can offer to get me started with TILES in C#..[/color]
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...
Sign In or Register to comment.