Slick Forums

Discuss the Slick 2D Library
It is currently Sat May 25, 2013 1:07 pm

All times are UTC




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Wed Sep 07, 2011 1:19 pm 
Offline
User avatar

Joined: Thu Aug 25, 2011 8:45 pm
Posts: 27
Location: USA
Hey all,

I've completed my second game on my way to introducing myself to Slick. I call it 'Cave In'; it's a simple "avoid the falling stuff" game where you're a miner in a cave/mine and there are falling stalactites that you must avoid.
Every 10 seconds the fall speed of the objects will increase until, well, until you can no longer keep up (perhaps there should be a ceiling to this speed). You use 'A' and 'D' to move left and right to avoid the falling objects. If you die your score will be displayed and you will need to press 'S' to start a new game. The score will continuously increase until you die.
Previously there were performance issues with the applet, I think they've been fixed, at least for me they have, let me know. Other than that, it looks at least presentable for me. I did all the gfx by hand with paint/Gimp and that's always the hardest as I am never satisfied, but there is only so much I can do. Also, it's another silent game... I really need to stop saying I'll fix that and actually do it.

Direct link to game applet:
http://www.onewordtale.com/games/CaveIn/cavein.html
Feel free to check out my other games, just Real Knight for now:
http://www.onewordtale.com/othergames.html
Or even my first project with a website, One Word Tale:
http://www.onewordtale.com


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 07, 2011 1:41 pm 
Offline
Slick Zombie

Joined: Wed Apr 02, 2008 1:32 pm
Posts: 1315
Location: Italy
It's really slow on loading jars and slow on play :(


About applet. Can you consider using this a splash before load applet? this method for example? http://ninjacave.com/appletsplash

_________________
Blog | Last game Gravity Duck tribute | In progress Gravity Duck tribute


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 07, 2011 2:20 pm 
Offline
User avatar

Joined: Thu Aug 25, 2011 8:45 pm
Posts: 27
Location: USA
Very good idea, did not know this was possible! Now, you said the game was still running slow as well? Stuttering? Or was that the slow loading you were mentioning?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 07, 2011 2:39 pm 
Offline
Slick Zombie

Joined: Wed Apr 02, 2008 1:32 pm
Posts: 1315
Location: Italy
slow on load and play :(

_________________
Blog | Last game Gravity Duck tribute | In progress Gravity Duck tribute


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 07, 2011 5:07 pm 
Offline

Joined: Wed Sep 07, 2011 5:02 pm
Posts: 36
Location: Netherlands
When I first started the applet it took almost a minute before the stalactites actually got to the bottom of the playing field. The next time they went much fast, so fast in fact that I could often not manage to avoid a stalactite even though I tried.

It's a nice simple idea, but you may have to balance it out a bit more.

_________________
Researcher & game development hobbyist.
http://www.grunnt.nl


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 07, 2011 5:09 pm 
Offline
User avatar

Joined: Thu Aug 25, 2011 8:45 pm
Posts: 27
Location: USA
Wooow.. I now know what Gornova meant... it had been running fine for me until I just tried now.. the stalactites were barely moving.. I don't know why this was fine before but now it's not... definitely something I will look into..

sorry!!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 07, 2011 6:11 pm 
Offline
User avatar

Joined: Thu Aug 25, 2011 8:45 pm
Posts: 27
Location: USA
There is something odd going on with my movement code. I am using a float for the stalactite position but if its under a certain value it is getting rounded to 0 instead of up. I don't think it should be rounded at all:

y += (float)delta/1000*speed;

where delta is typically 1,2, or 3 (and an int). If speed (also a float) is less than 500 then they move horribly slow, and if its greater it moves as it is now...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 07, 2011 7:52 pm 
Offline
Slick Zombie

Joined: Wed Apr 02, 2008 1:32 pm
Posts: 1315
Location: Italy
my suggestions is to move using a counter something like:

Code:

private int counter = 0;

...update (...){
   counter +=delta;
   if (counter > 1000){
      counter = 0;
      movedown();
   }
}



so your entity move down every second or so

_________________
Blog | Last game Gravity Duck tribute | In progress Gravity Duck tribute


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 07, 2011 7:59 pm 
Offline
User avatar

Joined: Thu Aug 25, 2011 8:45 pm
Posts: 27
Location: USA
I should use something like that perhaps..

What I just did was use setTargetFramerate on my container; when I wasn't doing this it was up as high as 500 or so and the delta was too small (and is an int) so this was a problem. I now limited it to 60 and it seems to be working a lot better, with delta being around 16.
I do see how your solution would take care of this though and that would be another option.. Should be okay now.

--ED
Not sure if it's bad practice to set a target frame rate..


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 08, 2011 6:57 am 
Offline

Joined: Wed Sep 07, 2011 5:02 pm
Posts: 36
Location: Netherlands
Fonix wrote:
There is something odd going on with my movement code. I am using a float for the stalactite position but if its under a certain value it is getting rounded to 0 instead of up. I don't think it should be rounded at all:

y += (float)delta/1000*speed;

where delta is typically 1,2, or 3 (and an int). If speed (also a float) is less than 500 then they move horribly slow, and if its greater it moves as it is now...


I'm not 100% sure but I think that Java may consider the "1000" to be an int, and because of this round off the 1000*speed part of the equation. You could try using 1000.0 or 1000f instead?

_________________
Researcher & game development hobbyist.
http://www.grunnt.nl


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 08, 2011 1:54 pm 
Offline
User avatar

Joined: Thu Aug 25, 2011 8:45 pm
Posts: 27
Location: USA
I see, I appreciate your explanation. The way I saw it and think Java computes it is, both delta and 1000 are ints, but by casting delta to a float the outcome of delta/1000 is also a float. I think you only need 1 operator to be a float in division for the outcome to be a float. Then the speed is also a float so it should be fine, but there is no harm in adding the 1000f, so I should.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 08, 2011 2:44 pm 
Offline
Slick Zombie

Joined: Wed Apr 02, 2008 1:32 pm
Posts: 1315
Location: Italy
Fonix wrote:
I should use something like that perhaps..

--ED
Not sure if it's bad practice to set a target frame rate..


Trust me and try, it's a 5min change and works :D

setting target frame rate is NOT a bad pratice, but a guarantee that your game works fine on every computer

_________________
Blog | Last game Gravity Duck tribute | In progress Gravity Duck tribute


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 08, 2011 4:17 pm 
Offline
Regular
User avatar

Joined: Wed Apr 27, 2011 3:29 pm
Posts: 195
Location: United State of California
That was an excellent tutorial you posted up there, Gornova.

-edit
Whatever you guys did, the game is running much smoother than before. I couldn't really tell if the game took long to load because I'm on a real fast connection at the campus here.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 08, 2011 6:48 pm 
Offline
Slick Zombie

Joined: Wed Apr 02, 2008 1:32 pm
Posts: 1315
Location: Italy
about load time: put file into a googlecode account :D

_________________
Blog | Last game Gravity Duck tribute | In progress Gravity Duck tribute


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 09, 2011 5:00 pm 
Offline
User avatar

Joined: Thu Aug 25, 2011 8:45 pm
Posts: 27
Location: USA
Instead of implementing a fade in for the stalactites, they now creep down slowly before they wait and fall. I couldn't figure out fading, I think alpha can only be set once per image, I'd need some kind of filter image over the top so I just went with this.

As for hosting my code elsewhere, wouldn't that be slower =P than being right there on the server?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group