Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  Google Map Race  (Read 2135 times)
0 Members and 1 Guest are viewing this topic.
Offline Bonbon-Chan

Sr. Member
**

Posts: 417
Medals: 14



« on: 2010-07-12 05:56:40 »

Long time I didn't make something... to mush work and too big projects. To make a pause, I give a try to an idea that I had.

One of the annoying thing is to create maps, so I wanted to take map form google so I only have to define start point and end point for a racing game  Tongue (yes race all around the world !!!).

I manage to "stream" map but it was too slow (I only download 1 image at a time to not harm server) and maps from google are far too mush inacurrate. So I go for an editor that download map with a few tools to define road limite. Even so, the size of data is far too mush  Sad (6mo for a small part of a small town...)

So there is the result (a flew day of works  Wink), it is not polished but it is complet : Google Map Race
And the editor : Google Map Race Editor
The source code : User : guest , Password : guest0

For the game :
left : turn left
right : turn right
up : speed up
space : select

For the editor,  everything should be put in the "~/.bonbonchan/" folder. To add a race, you have to add a ".txt" file with 3 line :
1/ Name of the race
2/ Start point  : ix,dx,iy,dy,angle
3/ End point  : ix,dx,iy,dy,angle

ix,iy are integer of the coordinate of the image. dx,dy are double of the coordinate inside the image. angle is a double in radian.

To conclude, this game is not really good (or even legal), but I did't want to waste the code so  Grin.


Offline gouessej

JGO Kernel
*****

Posts: 3558
Medals: 30


TUER


« Reply #1 on: 2010-07-12 06:02:54 »

Nice game  Grin I would have loved to be able to get out the car to shoot some people lol.

Julien Gouesse
Offline DzzD

JGO Kernel
*****

Posts: 2134
Medals: 16



« Reply #2 on: 2010-07-12 06:22:19 »

hey very good idea, It would be nice to be able to see road "locked" also zoom in & out would be awesome.

Games published by our own members! Go get 'em!
Offline Hansdampf

Sr. Member
**

Posts: 412
Medals: 2


too offending?


« Reply #3 on: 2010-07-12 06:48:28 »

Got the bread in 2:19:00

lots of sillystupid games: http://www.emaggame.com
Offline gouessej

JGO Kernel
*****

Posts: 3558
Medals: 30


TUER


« Reply #4 on: 2010-07-12 07:19:42 »

To conclude, this game is not really good (or even legal), but I did't want to waste the code so  Grin.
Will you release the source code?

Julien Gouesse
Offline Eli Delventhal
« League of Dukes »

JGO Kernel
*****

Posts: 3573
Medals: 44


Game Engineer


« Reply #5 on: 2010-07-12 10:38:50 »

Cool. :-) I think the main thing this could benefit from (and is missing) is the ability to take any side road you want. I felt like I saw all these little roads that I would try to go down to save some time but I would just end up being cut off.

See my work:
OTC Software
<br />
Currently Working On:
Secret project...
Quote from: _Riven
I edit JGO in production, because I simply don't waste time writing bugs
Offline Bonbon-Chan

Sr. Member
**

Posts: 417
Medals: 14



« Reply #6 on: 2010-07-13 06:17:24 »

Will you release the source code?

You miss the versionning link  Wink

https://free1.projectlocker.com/bonbonchan/GoogleMapRace/trac/browser
Login : guest
Password : guest0

Quote
Cool. :-) I think the main thing this could benefit from (and is missing) is the ability to take any side road you want. I felt like I saw all these little roads that I would try to go down to save some time but I would just end up being cut off.

There is several  possible paths but it takes a lots of time to edit all the roads.
Offline gouessej

JGO Kernel
*****

Posts: 3558
Medals: 30


TUER


« Reply #7 on: 2010-07-13 07:28:55 »

You miss the versionning link  Wink

https://free1.projectlocker.com/bonbonchan/GoogleMapRace/trac/browser
Login : guest
Password : guest0
Thanks. I'm reading the whole source code now. Getting all files one by one is a bit painful. Do you have a GIT or SVN repository?

Maybe it would be easy to allow the car to move back by doing this:
1  
2  
3  
double acceleration = 0;
if(up) { acceleration = A; }
if(down) { acceleration = -A/10; }

instead of
1  
2  
double acceleration = 0;
if(up) { acceleration = A; }

Julien Gouesse
Offline Bonbon-Chan

Sr. Member
**

Posts: 417
Medals: 14



« Reply #8 on: 2010-07-14 09:39:56 »

Thanks. I'm reading the whole source code now. Getting all files one by one is a bit painful. Do you have a GIT or SVN repository?
https://free1.projectlocker.com/bonbonchan/GoogleMapRace/svn
Same login/password

Maybe it would be easy to allow the car to move back by doing this:
1  
2  
3  
double acceleration = 0;
if(up) { acceleration = A; }
if(down) { acceleration = -A/10; }

instead of
1  
2  
double acceleration = 0;
if(up) { acceleration = A; }

Usually in racing game, I don't even think about slowing down or going backware  Tongue
Online h3ckboy

JGO Kernel
*****

Posts: 1645
Medals: 4



« Reply #9 on: 2010-07-14 17:11:17 »

Usually in racing game, I don't even think about slowing down or going backware  Tongue
if u get stuck in a corner?
Games published by our own members! Go get 'em!
Offline Swattkidd7

Full Member
**

Posts: 203



« Reply #10 on: 2010-07-14 19:55:36 »

if u get stuck in a corner?
I usually just smash down the acceleration until some miracle happens and I am out of the corner haha...maybe thats just me though.
Online h3ckboy

JGO Kernel
*****

Posts: 1645
Medals: 4



« Reply #11 on: 2010-07-15 12:13:21 »

hahahahahahaha
Offline teletubo
« League of Dukes »

Sr. Member
*****

Posts: 463
Medals: 17



« Reply #12 on: 2010-07-17 12:11:04 »

This is quite funny, but I wish there was some hint on where is drivable and where is not  ... on the end of the track I spent hours trying to find where to enter the parking lot .
Good job anyway !

(ps: the link for the editor is not working )

Offline Bonbon-Chan

Sr. Member
**

Posts: 417
Medals: 14



« Reply #13 on: 2010-07-18 03:14:53 »

Quote from: teletubo link=topic=22710.msg187631#msg187631
(ps: the link for the editor is not working )
[/quote

Corrected  Smiley
Offline gouessej

JGO Kernel
*****

Posts: 3558
Medals: 30


TUER


« Reply #14 on: 2010-08-27 10:04:09 »

When I replaced Timer and TimerTask by their JDK equivalent, the window stayed gray. As I did not want to keep these classes, I used something more simple:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
public void run() {
        long elapsedTimeInNano = 0, previousTimeInNano, timeInNano = System.nanoTime();
        state = new Title();

        try {
            while ((thread != null) && (thread.isAlive())) {
                time = System.currentTimeMillis();

                previousTimeInNano = timeInNano;
                timeInNano = System.nanoTime();
                elapsedTimeInNano += timeInNano - previousTimeInNano;

                int nb = (int) (elapsedTimeInNano / (1000000000 / FRAMERATE));

                if (nb > 0) {
                    elapsedTimeInNano -= nb * (1000000000 / FRAMERATE);
                }

                for (int i = 0; i < nb; i++) {
                    state.logic();
                }
               
                initDraw();
                state.draw();
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }


Does my solution consume more CPU time?

Julien Gouesse
Offline Bonbon-Chan

Sr. Member
**

Posts: 417
Medals: 14



« Reply #15 on: 2010-08-27 11:07:31 »

Without testing I will say yes, it consumes more CPU time. You have remove all wait so draw() will be invocaded as mush as possible. In my case, draw() is invocaded at most of 60 fps.

For the Timer / TimerTask, I have just copy the jdk code and made modification to have a better accuracy (you should check if I use a time in nanosecond while the original one is in milisecond, I don't remember how I have done it).
Offline gouessej

JGO Kernel
*****

Posts: 3558
Medals: 30


TUER


« Reply #16 on: 2010-08-27 16:27:27 »

Without testing I will say yes, it consumes more CPU time. You have remove all wait so draw() will be invocaded as mush as possible. In my case, draw() is invocaded at most of 60 fps.
Ok that is what I feared.

For the Timer / TimerTask, I have just copy the jdk code and made modification to have a better accuracy (you should check if I use a time in nanosecond while the original one is in milisecond, I don't remember how I have done it).
I compared the both, I only found an attribute called "offset" in TimerTask and something different in the scheduling. The problem is that I was unable to explain your modifications to some students so I preferred using something more simple. Would it be dangerous to invoke Thread.sleep() in the method JMain.run()?

Julien Gouesse
Offline Bonbon-Chan

Sr. Member
**

Posts: 417
Medals: 14



« Reply #17 on: 2010-08-30 03:04:28 »

Ok that is what I feared.
I compared the both, I only found an attribute called "offset" in TimerTask and something different in the scheduling. The problem is that I was unable to explain your modifications to some students so I preferred using something more simple. Would it be dangerous to invoke Thread.sleep() in the method JMain.run()?
I'm an example to students  Grin funny

In JMain.run(), if nb == 0, it's mean that you have time to do a Thread.wait(  ((1000000000 / FRAMERATE) -  elapsedTimeInNano)/1000 ) (or use the nano second method).

For TimeTask, it use System milisecond and there is "rounding" error while using a framerate of 60. So I use an "offset" to correct the error.
Pages: [1]
  Print  
 
 
Jump to:  


Add your game by posting it in the showcase section.

The first screenshot will be displayed as a thumbnail.

obsidian_golem 2012-05-23 10:14:50

Danny02 2012-05-21 17:10:34

Danny02 2012-05-21 17:07:10

Danny02 2012-05-21 16:56:12

davedes 2012-05-21 13:59:23

obsidian_golem 2012-05-20 20:28:41

darkjava55 2012-05-12 16:14:40

Ultroman 2012-05-12 09:36:05

Ultroman 2012-05-11 22:49:53

Ultroman 2012-05-11 22:20:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.152 seconds with 20 queries.