Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [Update] fixed: Tile Map Design Problem  (Read 1328 times)
0 Members and 1 Guest are viewing this topic.
Offline SonicPixelation

Senior Newbie





« Posted 2012-10-22 02:28:20 »

I have been working on a Puzzle game,(basically its Like Portal in 2d). the main Ideas is going to be to get a Box on a button so that you can get out the door. But I ran into a design problem with the Tile engine. How its works is it calls entities from an array in the Tile file so as to get there id's and then compairs them to a .txt file to see were they go.

I designed the Door and Button to be Tiles and then I would use another Tile called wireTile. basically it calls every tile of one sort through the same class, so I cant have a perminiate x, or y to any Tile. Do you know anyway to give each tile a more permintate position?

Level.java
http://www.java-gaming.org/?action=pastebin&id=286


Tile.java
http://www.java-gaming.org/?action=pastebin&id=287

here is my Tile and level code.
Offline actual

JGO Coder


Medals: 23



« Reply #1 - Posted 2012-10-22 03:01:02 »

I'm not sure that I entirely understand your question but what I *think* you are asking is how can you give things positions if they are moving around? (Notice how me not understanding you doesn't stop me from answering Smiley ). Can you explain your problem in a little more detail.

1. You have x,y coordinates but those look to be for rendering. Why not add the x,y coordinates of the level to each tile. So your set tile looks like:
1  
2  
3  
4  
5  
6  
public void setTile(int x, int y, Tile tile){
     tile.setBoardPosition(x,y);
     int id = map[y][x];
     Tile.tiles[map[y][x]] = tile;
     tile.init(this);
}


2. What are your entities and is there any reason you keep a separate array of the level rather than adding them directly to the tile/

Offline SonicPixelation

Senior Newbie





« Reply #2 - Posted 2012-10-22 03:12:56 »

Ok ley me try and explain this a little better. The problem I was having is the wiretile in the map is used like 20 time so far but it calls all 20 of them through one class. I want it make copy's of every wiretile so that I can have perminate x and y cords for each tile instead of them swarming through one class per tile. So basically my code to the wire was plans to be something like if(level.getTile(x-1,y).powered) powered = true;  the x and the y would be the tiles position so this would look at the tile to your right to see if it's powered and if it is it would turn on too.

I hope this helps.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline actual

JGO Coder


Medals: 23



« Reply #3 - Posted 2012-10-22 03:46:41 »

It helps but can you show your code for WireTile?. And can you post the snippet of code where it is calling it "20 times through one class"?  I am confused about some things in your code. It may not be relevant but it might be. Why do you have these static members in Tile?
1  
2  
3  
4  
5  
6  
7  
8  
public static Tile[] tiles = new Tile[25];

public static Tile SolidTile = new SolidTile();
public static Tile EmptyTile = new EmptyTile();
public static Tile CheackPointTile = new CheckPointTile();
public static Tile ButtonTile = new ButtonTile();
public static Tile DoorTile = new DoorTile();
public static Tile WireTiled = new WireTile();


Also, why in your level update method are you updating the tile array within your Entity loop? Sorry for all of the questions but sometimes it can be hard to follow another person's code.
Offline SonicPixelation

Senior Newbie





« Reply #4 - Posted 2012-10-22 05:32:09 »

Just some quic clarifacations the static tile list was there from my old tile referance system. But I am not compleatly sure the new one is good so I left the code laying around. As for the calling it 20 times that occors in the render method when it's getting the tile. The get tile method calls from a 2d array that was loaded from a txt file, basically what I ment was that I have 20 wiretile recorded to the array. And the tile updating inside the entity loop was amistake :p. sorry for all the extra guff in my code I am not the neatest programer.

So from what I gather I need to set the tile Pos. in the set tile method. I am not sure if this is what you mean or maybe you have something better in mind. Thank you for all the help.

WireTile.java

http://www.java-gaming.org/?action=pastebin&id=288

This is basically it when it comes to the wire tile. But I removed the power checking didn't work in the first place.
Offline SonicPixelation

Senior Newbie





« Reply #5 - Posted 2012-10-22 20:24:02 »

basically to sum it up I want to make a instance of every tile that appears on the screen, because as of now it is making one instance per tile type so the x and y cores for any given tile are the last occurrence of that tile in the map. so what I want to do is every time a tile is set at the start it makes a new version of it.

you responses would be greatly appreciated.
Offline SonicPixelation

Senior Newbie





« Reply #6 - Posted 2012-10-22 23:00:06 »

ok I fixed it, what i needed to so it turn the change the getTile method into getTile(int x ,int y) and the Tile class init's the x and y.

thank you for all the help.

Hopefully the game will be done soon.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (49 views)
2014-10-17 03:59:02

Norakomi (38 views)
2014-10-16 15:22:06

Norakomi (31 views)
2014-10-16 15:20:20

lcass (35 views)
2014-10-15 16:18:58

TehJavaDev (65 views)
2014-10-14 00:39:48

TehJavaDev (65 views)
2014-10-14 00:35:47

TehJavaDev (55 views)
2014-10-14 00:32:37

BurntPizza (72 views)
2014-10-11 23:24:42

BurntPizza (43 views)
2014-10-11 23:10:45

BurntPizza (84 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!