zparticle
|
 |
«
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.zipYou 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.
|
|
|
|
draycasejr
JGO Visitor
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.  Ray
|
space empire games rule...
|
|
|
rdcarvallo
|
 |
«
Reply #2 - Posted
2002-11-25 22:30:56 » |
|
woa  80fps smoothnes @ 1024x768, now I need to read the code!!
|
|
|
|
|
Games published by our own members! Check 'em out!
|
|
zparticle
|
 |
«
Reply #3 - Posted
2002-11-26 01:09:51 » |
|
Don't be too impressed.  On some older versions of the NVIDIA drivers, it sucks. However the newer drivers work excellent.
|
|
|
|
swpalmer
|
 |
«
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
|
|
|
|
zparticle
|
 |
«
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.
|
|
|
|
swpalmer
|
 |
«
Reply #6 - Posted
2002-11-30 01:57:41 » |
|
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  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)
|
|
|
|
javatypo
|
 |
«
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.
|
|
|
|
|
zparticle
|
 |
«
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=1038158514swpalmer: Opps, I did mean Ghz not Mhz.  Also there is a new tile map scrolling demo included in the code. See the thread mentioned above for details.
|
|
|
|
cknoll
|
 |
«
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!
|
|
cknoll
|
 |
«
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
|
|
|
|
|
zparticle
|
 |
«
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.
|
|
|
|
cknoll
|
 |
«
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
|
|
|
|
|
zparticle
|
 |
«
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.
|
|
|
|
zparticle
|
 |
«
Reply #14 - Posted
2002-12-06 03:17:15 » |
|
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.
|
|
|
|
cknoll
|
 |
«
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
|
|
|
|
|
cknoll
|
 |
«
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  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
|
|
|
|
|
zparticle
|
 |
«
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.jarJust 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.  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.
|
|
|
|
zparticle
|
 |
«
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.
|
|
|
|
Abuse
|
 |
«
Reply #19 - Posted
2003-01-04 19:57:52 » |
|
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  1400*1050*4*3 = 17640000 bytes = 16.8mb 1280*1024*4*3 = 15728640 bytes = 15mb  anyhow, its nice and smooth 
|
|
|
|
MickeyB
|
 |
«
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?  jk M
|
|
|
|
zparticle
|
 |
«
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? 
|
|
|
|
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? Also URL above is 404... Great Forum...
|
A probability is a desperate attempt of chaos to become stable.
|
|
|
cfmdobbie
|
 |
«
Reply #23 - Posted
2003-01-31 11:48:32 » |
|
|
Hellomynameis Charlie Dobbie.
|
|
|
zparticle
|
 |
«
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.
|
|
|
|
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.
|
|
|
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
|
|
|
|
|
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.
|
|
|
|
|
zparticle
|
 |
«
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.
|
|
|
|
PuppetMaster
JGO Visitor
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?
|
|
|
|
|
|