Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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  
  [Slick2d] Convert TiledMap to use Float instead of Int.  (Read 2061 times)
0 Members and 1 Guest are viewing this topic.
Offline Rayvolution

JGO Kernel


Medals: 199
Projects: 2
Exp: 1 year


Resident Crazyman


« Posted 2014-03-07 02:57:14 »

In my dire need to make TiledMaps render smoother, I figured out the steps needed to modify Slick2D's TiledMap class (and the classes effected by it) to accept floats instead of ints, that way you can move the map via float*delta, instead of just straight ints. This will allow your maps to move much smoother around the map.

This process actually ended up being a lot more simple than I had originally thought but I figured I should still share the process anyway, it's only 6 edits in 3 files. I removed a few edits that didn't need to be done, to keep this as minimally invasive as possible to Slick2d.

(This is done with Slick2d build #237, the exact lines may differ in your copy)

org.newdawn.slick.tiled.TiledMap.class
Line: 417
Change:
1  
   public void render(int x, int y, int sx, int sy, int width, int height,

To:
1  
   public void render(float x, float y, int sx, int sy, int width, int height,


Line: 502
1  
   protected void renderIsometricMap(int x, int y, int sx, int sy, int width,

To:
1  
   protected void renderIsometricMap(float x, float y, int sx, int sy, int width,


Lines: 515, 516
1  
2  
   int initialLineX = x;
   int initialLineY = y;

To:
1  
2  
   float initialLineX = x;
   float initialLineY = y;


Line: 524
1  
   int currentLineX = initialLineX;

To:
1  
   float currentLineX = initialLineX;





org.newdawn.slick.tiled.Layer
Line 198
1  
   public void render(int x, int y, int sx, int sy, int width, int ty,

To:
1  
   public void render(float x, float y, int sx, int sy, int width, int ty,





org.newdawn.slick.SpriteSheet
Line 267
1  
   public void renderInUse(int x,int y,int sx,int sy) {

To:
1  
   public void renderInUse(float x,float y,int sx,int sy) {



- Raymond "Rayvolution" Doerr.
Retro-Pixel Castles - Survival Sim/Builder/Roguelike!
LIVE-STREAMING DEVELOPMENT: http://www.twitch.tv/SG_Rayvolution
Offline fapmaster69

Innocent Bystander


Exp: 7-9 months



« Reply #1 - Posted 2014-03-26 13:59:14 »

Dumb question... How do I make edits in eclipse? Every time I try & open the TiledMap.class it shows a "source not found" error.
Offline Rayvolution

JGO Kernel


Medals: 199
Projects: 2
Exp: 1 year


Resident Crazyman


« Reply #2 - Posted 2014-03-26 15:17:57 »

You have to grab the slick2d source code (should be supplied in the slick2d download), and grab the .java files you want to edit. Then place them in your Workspace in the same folders.

1. Right click on your \src\ folder in your program
2. Click "New Package"
3. Name the new package org.newdawn.slick
3b. Repeat, make another package called org.newdawn.slick.tiled (Or make a \tiled\ folder in org.newdawn.slick)
4. Go into the Slick2d zip file you downloaded (Not just the jar, the file with everything in it, sourcecode, javadocs, etc)
5. Navigate to \src\org\newdawn\slick, drag and drop SpriteSheet.java into org.newdawn.slick
6. Navigate to \src\org\newdawn\slick\tiled and drag and drop Layer.java and TiledMap.java into your org.newdawn.slick.tiled folder

The alternative method would be to just drag+drop the entire Slick2d source code into org.newdawn.slick and delete the reference library completely inside your project, but then you'd be recompiling the entire slick2d source code every time you export the game, really wont hurt anything but why bother? One benefit to this is once your game is "complete" you could selectively remove parts of Slick2d you don't use in your game. But really, that'd be silly. Slick isnt that big. Cheesy

- Raymond "Rayvolution" Doerr.
Retro-Pixel Castles - Survival Sim/Builder/Roguelike!
LIVE-STREAMING DEVELOPMENT: http://www.twitch.tv/SG_Rayvolution
Pages: [1]
  ignore  |  Print  
 
 

 

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

The first screenshot will be displayed as a thumbnail.

BurntPizza (24 views)
2014-09-19 03:14:18

Dwinin (39 views)
2014-09-12 09:08:26

Norakomi (68 views)
2014-09-10 13:57:51

TehJavaDev (93 views)
2014-09-10 06:39:09

Tekkerue (47 views)
2014-09-09 02:24:56

mitcheeb (68 views)
2014-09-08 06:06:29

BurntPizza (51 views)
2014-09-07 01:13:42

Longarmx (38 views)
2014-09-07 01:12:14

Longarmx (44 views)
2014-09-07 01:11:22

Longarmx (40 views)
2014-09-07 01:10:19
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!