Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (472)
Games in Android Showcase (105)
games submitted by our members
Games in WIP (524)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  Tile maps and scrolling  (Read 6610 times)
0 Members and 1 Guest are viewing this topic.
Offline zparticle

Senior Member




Thick As A Brick


« Posted 2002-11-02 13:46:41 »

There seem to be a number of questions on how to

1> get smooth scrolling
2> use tile maps
3> use full screen
4> etc...

So I thought this example code might help in all of these areas.

http://www.scottshaver2000.com/files/scrollerexample.zip

You need to unzip it and then cd into the scroller directory and type:

java -cp . com.sas.planetation.examples.MapDisplayExample

Use the cursor keys to scroll around the map and the 'Q' key to exit the program.

Update: I just tried this at work with an NIVIDIA RIVA TNT2 Model 64 and the scrolling isn't very smooth, in fact it is awful. Strange given that I had it perfectly smooth on my home machine with the same card before I upgraded to a GeForce4. Must be a driver issue.

Offline draycasejr

Innocent Bystander




Java games rock!


« Reply #1 - Posted 2002-11-08 21:14:56 »

I didn't look at the code(I don't have time), but it works as advertised and looks good.  nice job.  I will definitely look into it further later. Cheesy

Ray

space empire games rule...
Offline rdcarvallo

Senior Member


Projects: 5
Exp: 15 years


2D Java games forever!


« Reply #2 - Posted 2002-11-25 22:30:56 »

woa  Shocked

80fps smoothnes @ 1024x768, now I need to read the code!!



Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline zparticle

Senior Member




Thick As A Brick


« Reply #3 - Posted 2002-11-26 01:09:51 »

Don't be too impressed.  Grin On some older versions of the NVIDIA drivers, it sucks. However the newer drivers work excellent.

Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #4 - Posted 2002-11-27 00:19:41 »

It sucked for me :-)

1024x768x32bit @ 70Hz I got from 11-21 fps.. and the movement was very jerky. Oh, and it only took up the upper right corner of the screen.

Java 1.4.1-b21
Dual 667MHz P-III
nVidia  GeForce DDR  
driver version 6.13.10.2312

Tried again on another system

Java 1.4.1_01
Dual 1GHz P-III
nVidia GeForce2 MX/MX 400
driver version 6.13.10.4072

1024x768x32bit @ 70Hz - got nothing but a black screen
tried again at:
640x480x16bit @ 60Hz - got 60 fps, cool!
800x600x32bit @ 75Hz - got 75 fps (but only in the upper right corner)

went back to 1024x768x32bit @ 70Hz and it was working..  doh!  (70 fps)

So the code is cool.. but something with fullscreen mode is flakey


Offline zparticle

Senior Member




Thick As A Brick


« Reply #5 - Posted 2002-11-27 01:38:04 »

Disturbing, I can max the frame rate (to the refresh rate) with any mode.

Java 1.4.0
1.2MHz P-IV (640meg ram, dual displays)
nVidia  GeForce Ti 4600 (128megs ram)  
driver version 6.13.10.3082

There seem to be a lot of issues with the nVidia drivers. Everytime I've changed versions it messed something up. So I'm sticking with the ones I have.

The map is intentionally only displayed in the upper right of the screen. The MapDisplay class allows you to place it anywhere on screen at any size. This way you don't have to use the entire screen for the map.  Like adding other components around it, score, meters, etc.

Edit: I wonder if I should upgrade to 1.4.1 and recompile everything.  Perhaps this would help the systems that are having trouble.

Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #6 - Posted 2002-11-30 01:57:41 »

Quote
1.2MHz P-IV (640meg ram, dual displays)


That would be really impressive if you could max the frame rate with a 1.2 MHz machine, I think you meant GHz  Grin

If you make any changes/recompile and would like me to test again on that machine that was only getting 11-21 fps, just email me (scott dot palmer at 2connected dot org)

Offline javatypo

Junior Member





« Reply #7 - Posted 2002-12-01 14:43:16 »

How did you make the .map, and .pal files?

And thank you. I'm going to try and take different parts of that out to figure out the absolute basics.
Offline zparticle

Senior Member




Thick As A Brick


« Reply #8 - Posted 2002-12-02 13:57:03 »

The .map and .pal files are created with a map editor I have built. (note that the code has changed slightly since this zip was put together and I haven't updated the zip. it still works but the map and pal file formats have changed. I needed to add version numbers, exception handling and some other info to the data files. Use the MapDisplayExample in the files refered to by the link below for the latest and greatest) See the following thread for more info:

http://www.java-gaming.org/cgi-bin/JGOForums/YaBB.cgi?board=volunteer;action=display;num=1038158514

swpalmer: Opps, I did mean Ghz not Mhz.  Grin Also there is a new tile map scrolling demo included in the code. See the thread mentioned above for details.

Offline cknoll

Junior Member




Flame On!


« Reply #9 - Posted 2002-12-05 13:40:44 »

Hi, I have a laptop that supports up to 1400x1050@32 and all the resolutions gave me 60fps (max based on the refresh rate) except running at 1400x1050@32 and 1280x 1024@32 which gave me 6fps.  (however, 10400x1050@16 gave me 60fps and 1024x768@32 gave me 60fps).  I have a 1.8ghz P4 with NVIDIA GF4 Go video.  Very smoothe animation except for the very high resolutions...I don't know if it's a geometry problem, driver problem, or what, but to get max frames at 1024x768@32 is nice. (even 1400x1050@16 is good)

-Chris
 
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline cknoll

Junior Member




Flame On!


« Reply #10 - Posted 2002-12-05 13:42:02 »

one commonly asked question is doing independent animation loops of sprites in the game, I was wondering if this could be added to your code, and then the source provided for learning experiences?  I'm sure everyone has an idea of how to do it properly, but since you already have the drawing routines down to scroll smoothly, could it be extended to support animation loops of arbitrary sprites?

-Chris
Offline zparticle

Senior Member




Thick As A Brick


« Reply #11 - Posted 2002-12-05 14:15:28 »

I'm not sure what you mean by "independent animation loops ". I assume you don't mean a separate thread per sprite. My sprite system can handle animations at different speeds for any number of sprites. Also has ability for 1 to n animations per sprite.

I'm working on a Impossible Mission (from the old C-64 days) rip off with a few new twists that uses the tile map system. I'll put it up when it's finished. Also the AnimImageSprite example show a number of sprites animating at different speeds.

I need to get the animated tile palette code working in the map editor so you can have animated tiles as well.

Offline cknoll

Junior Member




Flame On!


« Reply #12 - Posted 2002-12-05 17:34:12 »

Yep, you would be correct: I don't want separate threads for animation.  I'm sorry I didn't look closer at the code, I'll take a closer look and see how you are doing it, but basically, that's exactly what I would want: N sprites animated at X FPS with any number of animation frames per sprite....and manged through a single thread (the main game thread).  Thanks for the info.

-Chris
Offline zparticle

Senior Member




Thick As A Brick


« Reply #13 - Posted 2002-12-05 20:13:59 »

I'm working on completeing the javadocs for all of the classes. Hopefully this will help shed some light on what I was thinking as I built the system.

Currently everything is based on milliseconds for animations, updates, movement, etc. I'm thinking about adding methods that allow these thing to be controlled via a specific number of screen frames as well.

The way I have it set up that shold be easy to do without breaking anything I already have, and then you can choose which way you want the control to happen.

Offline zparticle

Senior Member




Thick As A Brick


« Reply #14 - Posted 2002-12-06 03:17:15 »

Quote
Hi, I have a laptop that supports up to 1400x1050@32 and all the resolutions gave me 60fps (max based on the refresh rate) except running at 1400x1050@32 and 1280x 1024@32 which gave me 6fps.  (however, 10400x1050@16 gave me 60fps and 1024x768@32 gave me 60fps).  I have a 1.8ghz P4 with NVIDIA GF4 Go video.  Very smoothe animation except for the very high resolutions...I don't know if it's a geometry problem, driver problem, or what, but to get max frames at 1024x768@32 is nice. (even 1400x1050@16 is good)

-Chris
 


I think the problem with the two slow modes is that I have the program set to use 3 buffers in the buffer strategy. When there isn't enough video memory to fit all of them some can be put in main memory and therefore they won't be accelerated.  You might try changing the buffers down to 2 and then run it.

1400x1050@32 * 3 buffers is around 141 megs of video ram. 1280x 1024@32  * 3 buffers is around 125 megs of video ram.

Offline cknoll

Junior Member




Flame On!


« Reply #15 - Posted 2002-12-06 14:12:54 »

I'll try it.  I wonder if there's a way to figure out how much volitile storage you have (I would guess not, seems very platform specific) but I'm wondering how I would do this in practice, start with 3 frames of buffered strategy, and if the fps is low, reduce the number of frames in the strategy? hmm

-Chris
Offline cknoll

Junior Member




Flame On!


« Reply #16 - Posted 2002-12-06 14:37:21 »

Hi, I tried to do a build on the source you gave, but the compiler says the follwoing problems:

com/sas/planetation/examples/MapDisplayExample.java [13:1] cannot resolve symbol
symbol  : class BitmapFont  
location: package data
import com.sas.planetation.data.BitmapFont;
                               ^
com/sas/planetation/examples/MapDisplayExample.java [14:1] package com.sas.planetation.sprites does not exist
import com.sas.planetation.sprites.ScoreSprite;
                                  ^
2 errors

Looks like a few classes weren't included in the zip.  care to update the zip with the classes so I can see if changing the buffer strat works?

-Chris

UPDATE:
Doh! I just removed the imports because they aren't actually being used in the code and got it to recompile. I will send an update to this message when I see if a buff strat of 2 works better.

UPDATE2:
Ok, I made the buffstrat use 2 frames instead of 3, and the 1280x1024x32@60 worked properly now, but 2 would not work at 1400x1050x32@60 (I should use the proper notation for the display modes, eh?).  I set the buffered strategy to 1 (I donno if that's legal) but got hideous screen flickering, so never use a buffer strat of 1 Smiley  The 1400x1050x16@60 worked fine with a buff strat of 2.

That's very interesting how the buffer strategy requires all frames to be alloocated in memory or it gives up (guess it makes sense, but it's interesting to me, nonetheless).

Thanks for the demo and source, I think this is the right way to do 2d based games.

-Chris

Offline zparticle

Senior Member




Thick As A Brick


« Reply #17 - Posted 2002-12-06 14:58:32 »

Okay, that old zip file is out of date so I've put up a new jar file that contains all the classes, source, resources and javadocs at:

http://www.scottshaver2000.com/planetation/files/planetation.jar

Just unzip the enitre contents of the jar into a directory. You will get the following sub directories:

src  <-- java source files
api  <-- javadocs
com <-- compiled classes and resource files

This file is the lastest for the system, I'm almost at version 1.0.  Grin

The javadocs are far more complete now.  I've also included an example of the MultiAnimImageSprite class in the AnimImageSpriteExample. All examples classes are in the com.sas.planetation.examples package and each one has a main() method.  Also I've turned the display of the FPS on for all examples.

The new MapDisplayExample contains a better map file than the old one.

Offline zparticle

Senior Member




Thick As A Brick


« Reply #18 - Posted 2002-12-22 05:04:49 »

I found a number of bugs in the MapDisplay class from my Planetation system that only show up under very specific cercumstances. If anyone is using that code from the tile map and scrolling demo I put up and would like to have a new version of the source let me know.

Offline Abuse

JGO Coder


Medals: 11


falling into the abyss of reality


« Reply #19 - Posted 2003-01-04 19:57:52 »

Quote


I think the problem with the two slow modes is that I have the program set to use 3 buffers in the buffer strategy. When there isn't enough video memory to fit all of them some can be put in main memory and therefore they won't be accelerated.  You might try changing the buffers down to 2 and then run it.

1400x1050@32 * 3 buffers is around 141 megs of video ram. 1280x 1024@32  * 3 buffers is around 125 megs of video ram.


8 bits in a byte, 32bit = 4byte Wink

1400*1050*4*3 = 17640000 bytes = 16.8mb
1280*1024*4*3 = 15728640 bytes = 15mb

Lips Sealed

anyhow, its nice and smooth Grin

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline MickeyB

Senior Member




my game will work, my game will work!


« Reply #20 - Posted 2003-01-04 20:57:11 »

I know I am late getting in on this thread, but since I am haveing some 3D "issue's" I though I would take a look.

Win 2k, java 1.4.0
GeForce II nvidia
AMD Athlon 1.1 ghz.

and BOOM very, very nice 69 fps and perfectly smooth.  
Can I use it to make an RPG?  Grin  jk

M

MickeyB

Current Project: http://www22.brinkster.com/mbowles/
Offline zparticle

Senior Member




Thick As A Brick


« Reply #21 - Posted 2003-01-06 14:03:09 »

Abuse: Thanks for the math correction, what the hell was I on when I did that? Cheesy

Offline demon_coder

Junior Newbie




2600


« Reply #22 - Posted 2003-01-31 09:52:20 »

Received this error on older code:
Exc in thread "main" java.lang.NoSuchMethodError
   at com.sas.util.gui.FullScreenJFrame.getDisplayModes <Unknown Source>
   at com.sas.util.gui.VideoModeSelector.<init> <Unknown Source>
   at com.sas.planetation.examples.MapDisplayExample. main<Unknown Source>

I'm coding in (1.3.0-C) do I need 1.4 to run this?


Quote
Okay, that old zip file is out of date so I've put up a new jar file that contains all the classes, source, resources and javadocs at:

http://www.scottshaver2000.com/planetation/files/planetation.jar


Also URL above is 404...

Great Forum...



A probability is a desperate attempt of chaos to become stable.
Offline cfmdobbie

Senior Member


Medals: 1


Who, me?


« Reply #23 - Posted 2003-01-31 11:48:32 »

Looks like the Planetation home has moved to:

http://www.scottshaver2000.com/template/template.php?page=planetation_main

Try this for a direct download:

http://www.scottshaver2000.com/sections/libraries/planetation/files/planetation.jar

Hellomynameis Charlie Dobbie.
Offline zparticle

Senior Member




Thick As A Brick


« Reply #24 - Posted 2003-01-31 14:08:00 »

cfmdobbie: Thanks for showing the new location, I pu up a notice about the site change in the Planetaion thread but forgot to put one here.

demon_coder: You do need 1.4 to run it.

Offline demon_coder

Junior Newbie




2600


« Reply #25 - Posted 2003-01-31 20:31:41 »

cfmdobbie / zparticle:

Thanks for the update.  Upgrade to 1.4.   :-/  Well, I've been putting this off long enough.

demon_coder

A probability is a desperate attempt of chaos to become stable.
Offline mrdon

Junior Newbie




Java games rock!


« Reply #26 - Posted 2003-02-02 03:05:02 »

First off, thanks for the great code.  I'm new to game programming (but not Java) and it has been very helpful in learning the ropes.

I started playing around with planetation and ran into a couple of issues (athlon 1gz, 512mb, geforce4 ti4200, jdk 1.4.1_01):

1.  When I created a map with a number of tiles (10-20 I believe), while scrolling around, a few places the framerate would plunge down to 5-7.  I added a few more and it pretty much stayed that low there no matter where I went.  The map was 100x100 using 30 px by 30 px tiles.

2.  The map editor allowed tiles larger than the map tile size.  This worked out good because then I could easily add larger images like mountians and castles to the map.  However, when scrolling around, once the original tile is out of the viewport, the entire image disappears (the part that was larger than the origin tile's height or width).  It would be nice to be able to lay out tiles as well as larger images in the map editor.  Any way to get around this limitation?

Thanks

Don
Offline mrdon

Junior Newbie




Java games rock!


« Reply #27 - Posted 2003-02-02 03:09:48 »

Forgot to mention, I'm testing at 640x480x16 and the original examples work beautifully.
Offline zparticle

Senior Member




Thick As A Brick


« Reply #28 - Posted 2003-02-03 14:48:27 »

mrdon: I'm moving so it may take a little bit for me to get to your issues. Bare with me, next month I should be able to look into it.

One thing to remember is that the use of transparent images and images with alpha blending will slow things down a lot. Also I've found that starting a game in 16 bit video mode and using 256 color gifs for the tiles will increase the speed. My examples used 32 bit PNG tiles. But in practice GIFs are faster and less memory intensive.

Offline PuppetMaster

Innocent Bystander




Java games rock!


« Reply #29 - Posted 2003-05-20 09:31:37 »

I cant seem to get it to work I get the error:
Registry key 'Software\JavaSoft\Java Runtime Environment\CurrentVersion'
has value '1.3', but '1.2' is required.

Can anybody please help?
Pages: [1] 2
  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.

Riven (23 views)
2014-07-10 20:20:18

CopyableCougar4 (22 views)
2014-07-10 02:26:14

CopyableCougar4 (29 views)
2014-07-09 02:55:38

Code Mage (29 views)
2014-07-08 23:57:00

Code Mage (16 views)
2014-07-08 23:49:08

AppleSauce (25 views)
2014-07-08 19:25:32

CopyableCougar4 (25 views)
2014-07-06 01:51:26

ipe369 (30 views)
2014-07-05 14:18:25

vastrolorde (41 views)
2014-07-04 18:45:44

theagentd (58 views)
2014-07-02 22:19:37
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!