Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
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  
  Sail 4K  (Read 9492 times)
0 Members and 1 Guest are viewing this topic.
Offline Rick

Junior Member


Projects: 1


Java games rock!


« Posted 2006-02-21 19:52:56 »

Here is a new entry. http://unlimited.woogley.net/games/view.php?id=95

It's a simple sailing game. You are the red sail boat.
Use the left and right arrow keys to control the rudder.
Use the up and down arrow keys to easy and trim the sail. To start moving use the the up arrow to easy the sail.
Navigate around the markers in an anti-clockwise direction and beat the other boats to earn a star.
The compitition gets harder each round.
The wind is blowing from the bottom of the screen. Remember for thoses that do not sail  you can not sail directly into the wind.
The sail must be adjusted to the wind direction for maximum speed.
You can watch your progress on the mini display in the botom corner. Each completed leg of the race will turn red on the mini map once completed. If you take a marker too wide it will not register as being completed.

Some of the features.
Z sorted 3D sailing boats.
Water and wave effects as sailing boat moves through water.
Collision detection between boats and markers and boat to boat.


Offline Markus_Persson

JGO Wizard


Medals: 14
Projects: 19


Mojang Specifications


« Reply #1 - Posted 2006-02-21 19:57:19 »

Very difficult to control.

Very very nice (and fast!) water. =D

Play Minecraft!
Offline f.l.x

Senior Member


Projects: 3


there is no place like 127.0.0.1


« Reply #2 - Posted 2006-02-21 20:12:01 »

 Embarrassed
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
java.lang.ClassCastException: sun.awt.image.DataBufferNative
   at W.<init>(Unknown Source)
   at W.main(Unknown Source)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at com.sun.javaws.Launcher.executeApplication(Launcher.java:1154)
   at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1101)
   at com.sun.javaws.Launcher.continueLaunch(Launcher.java:944)
   at com.sun.javaws.Launcher.handleApplicationDesc(Launcher.java:515)
   at com.sun.javaws.Launcher.handleLaunchFile(Launcher.java:218)
   at com.sun.javaws.Launcher.run(Launcher.java:165)
   at java.lang.Thread.run(Thread.java:595)


kubuntu 5.10
jdk1.5.0_06

Litterarum radices amaras, fructus dulces
http://flx.proyectoanonimo.com
figth spam!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Rick

Junior Member


Projects: 1


Java games rock!


« Reply #3 - Posted 2006-02-21 20:29:24 »

f.l.x What platform is the exception on.

Marcus you machine is  just too fast.  Smiley I guess I will have to add a better timer loop.

Offline Markus_Persson

JGO Wizard


Medals: 14
Projects: 19


Mojang Specifications


« Reply #4 - Posted 2006-02-21 20:43:56 »

No, no, I didn't mean it ran too fast. It ran perfect. =)

Very smooth, is what I meant.

Play Minecraft!
Offline g666

Junior Member





« Reply #5 - Posted 2006-02-21 21:29:56 »

i get this : platform win 2000 screen bpp=16
Quote
java.lang.ClassCastException: java.awt.image.DataBufferUShort
   at W.<init>(Unknown Source)
   at W.main(Unknown Source)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at com.sun.javaws.Launcher.executeApplication(Unknown Source)
   at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
   at com.sun.javaws.Launcher.continueLaunch(Unknown Source)
   at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)
   at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)
   at com.sun.javaws.Launcher.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

desperately seeking sanity
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #6 - Posted 2006-02-21 22:25:31 »

Runs a bit slow on my Mac, quite fast on Windows.

Offline reardonj

Senior Newbie





« Reply #7 - Posted 2006-02-21 22:46:12 »

It's crashing on my machine as well:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
java.lang.ClassCastException: sun.awt.image.DataBufferNative cannot be cast to java.awt.image.DataBufferInt
   at W.<init>(Unknown Source)
   at W.main(Unknown Source)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:589)
   at com.sun.javaws.Launcher.executeApplication(Launcher.java:1176)
   at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1122)
   at com.sun.javaws.Launcher.doLaunchApp(Launcher.java:970)
   at com.sun.javaws.Launcher.run(Launcher.java:104)
   at java.lang.Thread.run(Thread.java:626)


I'm running Ubuntu Linux with Java 1.6 b69. Just a guess, but it looks like it may be some sort of problem with the bit depth on mine, g666's and f.l.x.'s computers. Linux only has a bit depth of 24 at most and g666 lists his as 16.
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 75
Projects: 15


★★★★★


« Reply #8 - Posted 2006-02-21 22:48:05 »

1  
2  
3  
4  
5  
6  
7  
An error occurred while launching/running the application.

Title: Sail 4k
Vendor: Rick McConney
Category: Unexpected Error

sun.awt.image.DataBufferNative


i'm on suse 10, java 1.5
Offline individ

Junior Newbie





« Reply #9 - Posted 2006-02-21 23:04:34 »

Works like a charm, even though I couldn't get past the first level (didn't really make an effort, it's pretty hard I tell you) Smiley

Randy: Hey, Earl, you wanna go write "Wash Me" on dirty cars? I already did ours.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Rick

Junior Member


Projects: 1


Java games rock!


« Reply #10 - Posted 2006-02-21 23:07:01 »

Thanks for the reports. I will try and change my color depth and see if I can reproduce the problem. I just ask for a compatible BufferedImage so I am not sure why I would get back one that fails. It looks like it might be when I try to get the raster and asign it to an int array.  Does anyone have a code snipet of the platform independent way of getting at the writable raster of a compatible BufferedImage.

I am useing the following.

1  
2  
        BufferedImage image = g.getDeviceConfiguration().createCompatibleImage(width,height, Transparency.OPAQUE);
        int[] skyImagePixelData = ((DataBufferInt)image.getRaster().getDataBuffer()).getData();
Offline reardonj

Senior Newbie





« Reply #11 - Posted 2006-02-21 23:22:41 »

Thanks for the reports. I will try and change my color depth and see if I can reproduce the problem. I just ask for a compatible BufferedImage so I am not sure why I would get back one that fails. It looks like it might be when I try to get the raster and asign it to an int array.  Does anyone have a code snipet of the platform independent way of getting at the writable raster of a compatible BufferedImage.

I am useing the following.

1  
2  
        BufferedImage image = g.getDeviceConfiguration().createCompatibleImage(width,height, Transparency.OPAQUE);
        int[] skyImagePixelData = ((DataBufferInt)image.getRaster().getDataBuffer()).getData();


I think I see the problem. Your casting the result of "image.getRaster().getDataBuffer()" to a DataBufferInt. All of our errors are class cast exceptions, involving some kind of DataBuffer , which I'm betting originate at that line of code. That cast will have to change to a plain DataBuffer for it to work without exceptions for us. Of course, I have no idea if that'll work with your code.
Offline Rick

Junior Member


Projects: 1


Java games rock!


« Reply #12 - Posted 2006-02-22 00:02:41 »

Yes that is the problem. But what is the solution. It looks like I have assumed I could get a 32 bit color buffer to work with. But some platforms do not support such high color. I do not think I have the space to support multiple color depths. The algorithm for rendering the water looks totally different at 16 bits and 32 bits. At 32 bits it is nice and smooth, but at 16 bits I see all kinds or morie patterns in the water. For now the workaround for thoses that do have support for 32 bit color is to change the setting to 32 bit color and it will run fine. I will have to see if there is any way to support lower color depths.

I would love to here if any one has an easy solution.
Offline Rick

Junior Member


Projects: 1


Java games rock!


« Reply #13 - Posted 2006-02-22 00:36:23 »

Ok. I think I fixed the problem. I now use the following to create the buffer.

1  
        BufferedImage skyImage = new BufferedImage(640, 480, BufferedImage.TYPE_INT_RGB);


So now since I create and int buffer it should be safe to cast it back to an int[] when I get the raster.

The only issue now is that since it is not a compatible image it will be converted on each redraw which might be a speed problem on some platforms. Let me know if the problem is fixed and how the speed is with the new way of doing things. Make sure you see the java webstart reloading the jar file if not try again my site always seems to need two tries to detect the jar is out of date.
Offline reardonj

Senior Newbie





« Reply #14 - Posted 2006-02-22 00:51:59 »

It's working without complaint now!
Offline jojoh

JGO Knight


Medals: 5
Projects: 7


games4j.com


« Reply #15 - Posted 2006-02-22 01:58:09 »

Quite nice, maybe a bit fast, but nice looking. Was first in goal, but I didn't advanced a level.  Sad Seems like one have to round the marks really close by for it to count. Varying wind directoins and stealing wind would really add to it I think, if possible to squeeze in. Boat also stops on a dime if there is no wind in sail. would be nice it if would glide a bit forward still.

Offline Malohkan

Senior Member




while (true) System.out.println("WOO!!!!");


« Reply #16 - Posted 2006-02-22 05:25:20 »

Yeah after a while I started to get a vague understanding of how the wind and sail angles helped control the ship, but stopping dead immediately when you turn just the wrong angle doesn't make sense.  Also I had my sails pulled all the way back, then turned and hit forward and my sails completely flipped back around Tongue

Admin and Game Developer at
GameLizard.com
Play Rimscape!    |    Play Conquer!
Offline Rick

Junior Member


Projects: 1


Java games rock!


« Reply #17 - Posted 2006-02-22 06:59:24 »

Quote
Quite nice, maybe a bit fast, but nice looking. Was first in goal, but I didn't advanced a level.   Seems like one have to round the marks really close by for it to count. Varying wind directoins and stealing wind would really add to it I think, if possible to squeeze in. Boat also stops on a dime if there is no wind in sail. would be nice it if would glide a bit forward still.

Great suggestions finally some one who knows how to sail  Smiley


I have done as much as I could fit in. I have made the rounding of the markers eaiser. You no longer have to be soo close. You still however can not be way away.
I have slowed the game down a bit.
I have added momentum to the boat so turning once moving is a little smoother.
I have add a wind indicator (the red line in the middle of the mini map).
And the wind now slowly changes over time.

I could not get the wind stealing in. It is too much computations to figure out who is bocking who. Too bad I would have liked to get that in.

Here's the new link so you don't have the scroll to the begining of the post.

http://unlimited.woogley.net/games/view.php?id=95



Quote
Also I had my sails pulled all the way back, then turned and hit forward and my sails completely flipped back around

Yes if the wind is in your back and you change direction you will "Jibe". That is the wind will swing the sails over to the other side of the boat. Many an sailor has gone over board this way. When going into the wind too far the wind will colapse the sail until the "Tack" or turn through the wind is complet. Then the sails will again fill at whatever setting was present before the turn.

Think of the sails being controlled by a length of rope. The up down arrows control the rope length. The wind will simply fill the sail until the rope is taught. But if you turn you can't push a rope so the sail will be blown around until the rope is once again taught. Just like how a real sail boat works.
Quote
Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2
Exp: 14 years


Make it work; make it better.


« Reply #18 - Posted 2006-02-22 13:16:31 »

I won 8 times in a row, but as pointed out, I was too far away from the markers on 4 of them.  It's pretty fun though.  My biggest problem is learning how to tack properly.  The wind is usually against you on the bottom part of the lap.  I have never sailed, but know the concepts, because I read a lot of Sci Fi/Fanatasy books and they are pretty descriptive sometimes.

Also, really nice water effects.

Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #19 - Posted 2006-03-08 02:16:19 »

Holy psycho graphics, batman! Shocked

弾幕 ☆ @mahonnaiseblog
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.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (25 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (43 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

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

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
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!