Sign in to follow this  

How to do a basic 2D map editor?

This topic is 3861 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone. I want to do a basic Mario style 2D map editor. The only things i know is C and a bit C++ and using SDL library. I think i need to learn win32api but I'm not sure. Can you give me some references/tutorials or etc for how to do a 2D map editor? Thanks a lot :)

Share this post


Link to post
Share on other sites
First you decide what you want the map editor to do, then in no particular order decide how it's going to look/how it's laid out, how it will function and how it will store and retrieve the information. Then you program it based on these decisions using whatever you want.

I decided that the map editor would be only be used to place tiles, I thought that the map on the left, tiles on the right approach would be good, and that it would use plain text to store/retrieve the data. I then fired up trusty notepad++ and wrote it in javascript, using the html/javascript knowledge I have. The full source is available by hitting view->source in your browser if you want to see what I have done.

Share this post


Link to post
Share on other sites
Here is how I made my tile map editor. Hope it helps. I'll explain best I can on each one.

This is the ItemElements constructor which gives all objects that extends to this class all it's instances. an x, and position. An image, an audioclip, and an element id, to tell what object it is.
// constructor
public ItemElements(int x, int y, Image image, AudioClip sound, Component parent, int element_id)
{
// initialize position
x_pos_left = x;
y_pos_up = y;
x_pos_right = x + GlobalVars.level_width;
y_pos_down = y + GlobalVars.level_height;


// initialize image
element_image = image;
element_audioclip = sound;

// store element id, and other personal variables for the game.
this.element_id = element_id;

inSight = true;

this.parent = parent;
}


This is the actual Item Object class that is extended to the ItemElements class. It simply provides away to create multiple bojects at a time that inherits, can use all instances, variables, and other objects of the ItemElements class.

import java.awt.Image;
import java.awt.Component;
import java.applet.*;

//All game objects in the entire game except for the player, and bosses when I get to it.
public class Items extends ItemElements
{
// Constructor, calls super constructor
public Items(int x, int y, Image image, AudioClip sound, Component parent, int element_id)
{
super(x, y, image, sound, parent, element_id);
}
}



The last class 2 classes are the level class, and the leveleditor generator

The LevelEditor generator reads strings from the level and depending on the character of each line in each string it spits out a certain object from the Item Class
 (Please note that other objects (i.e. Boss, and Enemy objects are definied, and created the same way as the Item Class, and ItemElement class, but has more instances for the game.
//parse the definition string and generate levelemenets arrays
public void initializeLevel(String [] definitions)
{
//initialize collision control array
collision_array = new ItemElements[GlobalVars.level_width] [definitions[0].length()];

//initialize level data
level_length = definitions[0].length() * GlobalVars.level_width;
left_level_border = 0;
right_level_border = GlobalVars.width;

//counter for the number of elements
int elements_counter = 0;

for(int i=0; i<definitions.length; i++)
{
char [] definition_line = definitions[i].toCharArray();

for(int j=0; j<definition_line.length; j++)
{
//Convert all chars in string to actual 2d images
if(definition_line[j] == ':') collision_array[i][j] = null;

if(definition_line[j] == 'a')
{
Items axe_element = new Items(j*GlobalVars.level_width, i*GlobalVars.level_height, axe, music, parent, GlobalVars.axe_id);
elements_counter ++;
}

if(definition_line[j] == 'b')
{
Items fireball_element = new Items(j*GlobalVars.level_width, i*GlobalVars.level_height, fireball, music, parent, GlobalVars.fireball_id);
elements_counter ++;
}

if(definition_line[j] == 'c')
{
Items diamond_element = new Items(j*GlobalVars.level_width, i*GlobalVars.level_height, diamond_blue, music, parent, GlobalVars.diamond_id);
elements_counter ++;
}

if(definition_line[j] == 'd')
{
Items door_element = new Items(j*GlobalVars.level_width, i*GlobalVars.level_height, door_brown, music, parent, GlobalVars.door_id);
elements_counter ++;
}

if(definition_line[j] == 'e')
{
Items exit_element = new Items(j*GlobalVars.level_width, i*GlobalVars.level_height, door_exit, music, parent, GlobalVars.exit_door_id);
elements_counter ++;
}

if(definition_line[j] == 'f')
{
Items fire_element = new Items(j*GlobalVars.level_width, i*GlobalVars.level_height, fire, music, parent, GlobalVars.fire_id);
elements_counter ++;
}

if(definition_line[j] == 'g')
{
Items ground_element = new Items(j*GlobalVars.level_width, i*GlobalVars.level_height, ground, music, parent, GlobalVars.ground_id);
elements_counter ++;
}

if(definition_line[j] == 'h')
{
Items health_element = new Items(j*GlobalVars.level_width, i*GlobalVars.level_height, health, music, parent, GlobalVars.health_id);
elements_counter++;
}

if(definition_line[j] == 'k')
{
Items key_element = new Items(j*GlobalVars.level_width, i*GlobalVars.level_height, key_blue, music, parent, GlobalVars.key_id);
elements_counter++;
}

if(definition_line[j] == 'm')
{
Items mud_element = new Items(j*GlobalVars.level_width, i*GlobalVars.level_height, mud_mud, music, parent, GlobalVars.monster_id);
elements_counter++;
}

if(definition_line[j] == 'p')
{
Items spikes_element = new Items(j*GlobalVars.level_width, i*GlobalVars.level_height, spikes, music, parent, GlobalVars.spike_id);
elements_counter++;
}

if(definition_line[j] == 'q')
{
Items qbox_element = new Items(j*GlobalVars.level_width, i*GlobalVars.level_height, spikes, music, parent, GlobalVars.qbox_id);
elements_counter++;
}

if(definition_line[j] == 'r')
{
Items rock_element = new Items(j*GlobalVars.level_width, i*GlobalVars.level_height, rock, music, parent, GlobalVars.rock_id);
elements_counter++;
}

if(definition_line[j] == 's')
{
Items skull_element = new Items(j*GlobalVars.level_width, i*GlobalVars.level_height, skull_white, music, parent, GlobalVars.skull_id);
elements_counter++;
}

if(definition_line[j] == 'z')
{
Boss daBoss = new Boss(j*GlobalVars.level_width, i*GlobalVars.level_height, parent, skull_white, music, move, move, move, GlobalVars.skull_id, GlobalVars.skull_id);
elements_counter++;
}


}
}



Now the part that makes everything come together or make sense is the level class itself which is just a one class that represent one level
It simply just creates strings, and is extended to the Leveleditor, LevelEngine for everything else to work

public class Level1 extends LevelEngine
{
/**
Legend:

g: ground
m: mud mud monster
b: box to use.
f: fireball.
d: door
h: hot fire

*/


// Strings to represent the level
public static final String row1 = "gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg";
public static final String row2 = "g::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row3 = "g::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row4 = "g::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row5 = "g::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row6 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row7 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row8 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row9 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row10 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row11 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row12 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row13 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row14 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row15 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row16 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row17 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row18 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row19 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row20 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row21 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row22 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row23 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row24 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row25 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row26 = "g::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::c:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row27 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::h::::::::m:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row28 = "g::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::ggggggggggg:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row29 = "g::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row30 = "g::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g:::::::::::::::::::::::::::::::::c::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q:::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row31 = "g::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row32 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::c::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row33 = "g::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::m::::::::::::::m::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row34 = "g::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g::::::::::::::::::::::::::::::ggggg:::::::::::::gggggg:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::ggggg:::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row35 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g:::::::::::::::::::::::::::::::::::::::::c::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row36 = "g::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::c:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row37 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g:::::::::::::::::::::g::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row38 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::gg::::::::gg::::::::::gg::::::::gg::::::::::::::::::gg:::::::::::::::cc:::::::::::::::c:::::::::::::::::::::::::c::::::::::::::c:::::::::::::::::::::::::::::::::::::::g";
public static final String row39 = "g:::::s::::::::::::::::::::::::::::g::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::gg::::::::gg::::::::::gg::::p:::gg:::::::::p::::::::gg:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row40 = "g::::::::::::::::::::::::::::::::::p::::::::::::::::::::::::::::::::::g::::::::::::::::::::::::::::::::::ggg::::::::gg::::::::::gg::::g:::gg:::::::::g::::::::ggg::::::::::::::::::::::::::::::::::::::::::::::::::gg::::::::::::gg::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row41 = "g:::::q:::::::::::::::::gg::::::::::::::::gg::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::gggg::::::::gg::::::::::gg::::::::gg::::::::::::::::::gggg::::::::::::::::::::::::gg::::::::::gg:::::::::::gg::::::::::::gg::::::::::::::::::::::::::::::::::::::::::::::e";
public static final String row42 = "g::::::::::::::::::::::gg::::::::::::::::::gg::::::::::::::::::::::::::::::::::::::::::::::::::::::::::ggggg::::::::ggp::::::::pgg::::::::gg::::::::::::::::::ggggg:::::::::::::::::::::::gg::::::::::gg::::::g::::gg::::::::::::gg:::::::::::::::::::::::::::::::::::::::::::::::";
public static final String row43 = "g::::p::::::::a:::::m:ggg:::g::::::g:::::::ggg::::::::::::::::::::m::::::::::::::m:::::::::::m::::::::gggggg::::p:::gg::::::::::gg::::::::gg::::::p:::::::::::gggggg::::m:::::::::::::::::gg:::::p::::gg:::::p:::::gg::::::p:::::gg:::m:::::::::::::::::m:::::::::::::::::::::::::";
public static final String row44 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row45 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row46 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row47 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row48 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row49 = "g:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::q::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::g";
public static final String row50 = "gggggggggggggggggggggggggffffffffffffffffffgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggffffffffggffffffffffggffffffffggffffffgfffffffffffggggggggggggggggggggggggggggggfffffgffffggfffffgfffffggffffffgfffffggggggggggggggggggggggggggggggggggggggggggggggggg";

// level name
public static final String level_name = "Castle1";

// color array to hold background colors
private Color [] colors;

// constructor
public Level1(Component parent, Applet applet)
{
// call super constructor
super(parent, applet, level_name);

// generate Array with background colors
initializeColorArray();

// set background color array in super class


String [] definitions = {row1, row2, row3, row4, row5, row6, row7, row8, row9, row10,
row11, row12, row13, row14, row15, row16, row17, row18, row19, row20,
row21, row22, row23, row24, row25, row26, row27, row28, row29, row30,
row31, row32, row33, row34, row35, row36, row37, row38, row39, row40,
row41, row42, row43, row44, row45, row46, row47, row48, row49, row50};

// initialize the level with the definitions given in this child class
super.initializeLevel(definitions);
}

// method to reset level
public void resetLevel()
{
String [] definitions = {row1, row2, row3, row4, row5, row6, row7, row8, row9, row10,
row11, row12, row13, row14, row15, row16, row17, row18, row19, row20,
row21, row22, row23, row24, row25, row26, row27, row28, row29, row30,
row31, row32, row33, row34, row35, row36, row37, row38, row39, row40,
row41, row42, row43, row44, row45, row46, row47, row48, row49, row50};

super.initializeLevel(definitions);
}

// method to initialize Color array
private void initializeColorArray()
{
colors = new Color[255];

for(int i=0; i<255; i++)
{
Color color = new Color(150, 150, 150);
colors[i] = color;
}
}

}



If you just read the code carefully you'll find out how to create a 2d engine map it's really easier than what everyone makes it out to be. If you need help just send me a private message.

Good Luck

Share this post


Link to post
Share on other sites
eedok
Ok about design i got it. The problem comes when i want to do something like this:
Left side of the program will show the map from an array, if it creates new array I'll initialize it to 0 and show an empty map if it load an array it will show textures depends on their ID.
The right side will be Tree view object of textures like:
-Textures
-Ground
-Grass
-NPC
-Very bad guy
-Bad guy
and etc.
And i want to add menu bar at the top like File: New, Open, Save as and etc
The problem i don't know how to realize it in c or c++, i mean how to realize this objects like tree view, menu bar and etc.

banhminds
Wow very nice :) It looks good :)
Thanks for sharing your code with me =)

Share this post


Link to post
Share on other sites
Hi,

Normally you use the components delivered by your IDE e.g. The Borland 5 IDE has a number of components to create menu, forms etc. You drag and drop them on a form a you're ready to go. If you don't use an IDE things are a little more complicated. You should look for a framework that creates GUI's, like QT. I shouldn't write it yourself and stay away from low level Windows programming.

Share this post


Link to post
Share on other sites
Quote:
Original post by EmmetjeGee
I shouldn't write it yourself and stay away from low level Windows programming.

You mean: " You shouldn't write it yourself and stay away from low level Windows programming".
Yes?
Thanks I'll check QT.

Share this post


Link to post
Share on other sites

This topic is 3861 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this