Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Pearl Harbour game

 
Post new topic   Reply to topic Printable version
 View previous topic  Quick Links to Projects Post :: Post <py> to java applet  View next topic  
Author Message
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Sat Mar 10, 2007 6:23 pm    Post subject: Pearl Harbour game Reply to topic Reply with quote

I made this little game in a day for a competition. Bak make sure you're sitting down when you read the next sentence. Source is included. It works on both windows and linux.



There are bugs (torpedoes don't work) and implementation issues (it draws everything, even offscreen items!). I may update it to add/fix stuff but I don't have much time for this sort of thing these days.
_________________
ss news




win/linux binary + src v0.1.1

pearlharbour-0.1.1.zip - 391.63 KB
File downloaded or viewed 97 time(s)

screenshot

pearlharbour-0.1.1.png - 18.91 KB
File downloaded or viewed 62 time(s)
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Sat Mar 10, 2007 6:52 pm    Post subject: Reply to topic Reply with quote

Look into using SDL_RLEACCEL with your SDL_SetColorKey, and look into SDL_DisplayFormat. It helps increase the speed of your blitting. If you want a basic FPS calculator, here is one I used a while ago. It requires GL/glut.h unless you want to use a different cross-platform time grabbing function.
Code: Show/Hide
double RecordFPS()
{
   /* Source: http://cone3d.gamedev.net */

#define FPS_BUCKET_SIZE 20
#define FPS_AVERAGE_TIME 1000

   static unsigned int bucket[FPS_BUCKET_SIZE];
   static int now = 0, end = 0;
   int FPS = 0;
   unsigned int tick = glutGet(GLUT_ELAPSED_TIME);

   /* Add current time to bucket */
   end++;
   if (end == FPS_BUCKET_SIZE)
      end = 0;
   bucket[end] = tick;

   /* If too high FPS, need a safe wrap around so FPS won't jump.
    * Bug from original source would have the time difference jump
    * down to near 0, causing the FPS for a couple of frames to show
    * up incorrectly by not using the whole bucket to search.
    */
   if (end == now)
   {
      now = end + 1;
      if (now == FPS_BUCKET_SIZE)
         now = 0;
   }

   /* Loop through till we find time of at least X seconds ago */
   if (tick < FPS_AVERAGE_TIME)
      tick = 0;
   else
      tick -= FPS_AVERAGE_TIME;

   while (bucket[now] < tick)
   {
      now++;
      if (now == FPS_BUCKET_SIZE)
         now = 0;
   }

   /* How much difference is between 'now' and 'end' is how many frames drawn in last 10 seconds */
   FPS = end - now;
   if (end < now)
      FPS += FPS_BUCKET_SIZE;

   if (end == now)
      return 0.0;

   return FPS * 1000.0 / (double)(bucket[end] - bucket[now]);
}

Just call RecordFPS and read back the floating variable for your current FPS. You can just call it inside of a Gfx_DrawText for even easier usage.
Back to top
View users profile Send private message Add User to Ignore List Send email
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Sat Mar 10, 2007 8:58 pm    Post subject: Reply to topic Reply with quote

cool, a bit hard to see friendly/enemy fire
_________________
SubSpace Discretion: A Third Generation SubSpace Client
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Sun Mar 11, 2007 2:00 pm    Post subject: Reply to topic Reply with quote

@MGB
Thanks for you comment but I already know about those 3 things, I was pushed for time on the day so didn't have time to tweak it.

@Bak
You want bigger bullets, different colors for each side or what?

Also on my list of things todo:
-Fully implement torpedoes.
-Add stalling if you fly too slow for too long.
-Add AI gunners to the bomber.

Things that would be nice:
-Better font.
-AI friendlies to help you, especially when you are a fighter or a bomber since those planes are at the extreme ends of anti-plane/anti-ship balance.
-Plane -> terrain collisions.
-Implement landing on the carrier for repairs and rearming.
-Fancy hud gfx.
-More levels, including defence of pearl harbour and playing on the jap side.
-Higher res.
-Possibly use opengl to add dynamic rotations, this would allow you to pitch down and fire rockets or dive bomb.
-Sound.
-Parallax background and clouds.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Sun Mar 11, 2007 6:06 pm    Post subject: Reply to topic Reply with quote

I want bigger bullets and different colors for each side.

My laptop does this weird thing with moving graphics where small moving graphics are blended with close by pixels, which makes them a lot harder to see.
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Tue Mar 13, 2007 7:14 pm    Post subject: Reply to topic Reply with quote

Update
Fully implemented torpedoes.
Improved bullet graphic (suggested by Bak).
Fixed not being able to win when flying as a fighter (because you can't bomb ships).
Added a tail gun to the US bomber.
Added fighter backup for bombers if you destroy all flak emplacements/turrets.
Added some graphical performance tweaks.
Added "viewable area" to radar.
Added stalling if you fly too slow for too long.
Increased resolution to 800x600 (from 640x480).

Updates were done on windows so the makefile is now outdated and no linux binary is provided.




pearlharbour-0.2.1.zip - 382.95 KB
File downloaded or viewed 92 time(s)
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
BDwinsAlt
Agurus's Posse


Age:33
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Wed Mar 14, 2007 12:34 am    Post subject: Reply to topic Reply with quote

I seem to be getting some errors when building on Linux.

Code: Show/Hide

brad@brad-laptop:~/Desktop/pearlharbour/pearlharbour$ make
gcc -O2 -s -DNDEBUG -Wall -fomit-frame-pointer main.o util.o graphics.o game.o -o pearlharbour -lSDL
main.o: In function `main':
main.c:(.text+0x19b): undefined reference to `Game_DrawShips'
main.c:(.text+0x1a1): undefined reference to `Game_DrawMap'
main.c:(.text+0x1a6): undefined reference to `Game_DrawWeapons'
main.c:(.text+0x1ab): undefined reference to `Game_DrawPlanes'
main.c:(.text+0x1b1): undefined reference to `Game_DrawAnims'
game.o: In function `Game_DrawRadar':
game.c:(.text+0xc0): undefined reference to `mapobjectset'
game.c:(.text+0x16a): undefined reference to `shipobjectset'
game.c:(.text+0x21c): undefined reference to `planeset'
game.o: In function `Game_Update':
game.c:(.text+0x475): undefined reference to `UpdatePlanes'
game.c:(.text+0x47a): undefined reference to `UpdateWeapons'
game.c:(.text+0x47f): undefined reference to `UpdateFlak'
game.c:(.text+0x484): undefined reference to `UpdateShips'
game.c:(.text+0x489): undefined reference to `UpdateAnims'
game.o: In function `TryFireSecondary':
game.c:(.text+0x59e): undefined reference to `AddWeapon'
game.o: In function `TryFirePrimary':
game.c:(.text+0x6f0): undefined reference to `AddWeapon'
game.o: In function `CheckWin':
game.c:(.text+0x760): undefined reference to `SpawnFighters'
game.c:(.text+0x77f): undefined reference to `planeset'
game.c:(.text+0x795): undefined reference to `SpawnBombers'
game.o: In function `Game_CleaupLevel':
game.c:(.text+0x7ae): undefined reference to `planeset'
game.c:(.text+0x7ba): undefined reference to `planeset'
game.c:(.text+0x7ce): undefined reference to `mapobjectset'
game.c:(.text+0x7da): undefined reference to `mapobjectset'
game.c:(.text+0x7ee): undefined reference to `shipobjectset'
game.c:(.text+0x7fa): undefined reference to `shipobjectset'
game.c:(.text+0x80e): undefined reference to `flakobjectset'
game.c:(.text+0x81a): undefined reference to `flakobjectset'
game.c:(.text+0x84e): undefined reference to `animset'
game.c:(.text+0x85a): undefined reference to `animset'
game.o: In function `Game_LoadLevel':
game.c:(.text+0x87b): undefined reference to `planeset'
game.c:(.text+0x88f): undefined reference to `mapobjectset'
game.c:(.text+0x89b): undefined reference to `shipobjectset'
game.c:(.text+0x8a7): undefined reference to `flakobjectset'
game.c:(.text+0x8bf): undefined reference to `animset'
game.c:(.text+0xc5e): undefined reference to `AddShip'
game.c:(.text+0xc93): undefined reference to `AddShip'
game.c:(.text+0xcc3): undefined reference to `AddShip'
game.c:(.text+0xcf5): undefined reference to `AddShip'
game.c:(.text+0xcfd): undefined reference to `AddFlakProtectShip'
game.c:(.text+0xd2d): undefined reference to `AddShip'
game.c:(.text+0xd5d): undefined reference to `AddShip'
game.c:(.text+0xd8f): undefined reference to `AddShip'
game.c:(.text+0xd97): undefined reference to `AddFlakProtectShip'
game.c:(.text+0xdc7): undefined reference to `AddShip'
game.c:(.text+0xde9): undefined reference to `AddIsland'
game.c:(.text+0xe09): undefined reference to `AddFlakEmplacement'
game.c:(.text+0xe1d): undefined reference to `AddJungle'
game.c:(.text+0xe38): undefined reference to `AddIsland'
game.c:(.text+0xe4c): undefined reference to `AddJungle'
game.c:(.text+0xe60): undefined reference to `AddJungle'
game.c:(.text+0xe74): undefined reference to `AddIsland'
game.c:(.text+0xe94): undefined reference to `AddFlakEmplacement'
game.c:(.text+0xeb4): undefined reference to `AddFlakEmplacement'
game.c:(.text+0xec7): undefined reference to `SpawnEnemies'
game.c:(.text+0xf1f): undefined reference to `AddPlane'
game.c:(.text+0xf69): undefined reference to `AddPlane'
game.c:(.text+0xfbb): undefined reference to `AddPlane'
game.c:(.text+0x1005): undefined reference to `AddPlane'
collect2: ld returned 1 exit status
make: *** [pearlharbour] Error 1

Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Wed Mar 14, 2007 4:45 am    Post subject: Reply to topic Reply with quote

Smong wrote:
Updates were done on windows so the makefile is now outdated and no linux binary is provided.
Basically what you need to do is add all the game-*.c files to the Makefile (but with .o extension).
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
BDwinsAlt
Agurus's Posse


Age:33
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Wed Mar 14, 2007 9:52 pm    Post subject: Reply to topic Reply with quote

Thanks. icon_biggrin.gif
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Fri Mar 16, 2007 8:08 pm    Post subject: Reply to topic Reply with quote

Updates
Improved radar blips.
Added Defence of Pearl Harbour level.
Added Battle of Coral Sea level.
Added Battle of Midway level.
Tail gunners now only shoot fighters to increase difficulty level.
Added sound.

Still no linux binary.




pearlharbour-0.3.1.zip - 687.55 KB
File downloaded or viewed 62 time(s)
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Sat Mar 17, 2007 2:20 am    Post subject: Reply to topic Reply with quote

Is there supposed to be a way to change ships? Otherwise you can't sink any ships with just a fighter or kill fighters with a bomber.







3.PNG - 21.88 KB
File downloaded or viewed 55 time(s)

ssph.png - 16.11 KB
File downloaded or viewed 58 time(s)
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Sat Mar 17, 2007 6:34 am    Post subject: Reply to topic Reply with quote

I'm not sure if that is some kind of rhetorical question given the second screenshot.

You can't change planes half way through a mission. So if you are a fighter and shoot down all the planes then 3 bombers will fly in behind you and line bomb everything. If you're a bomber and destroy all the flak cannons then 4 fighters will fly in and protect you.

The bomber still has guns on it so it can complete a mission on its own. Also I have tested the 3 bomber backup for the fighter and they always destroy everything before flak can shoot them down.

It would be nice to be able to land and change plane, repair and maybe rearm. Only problem is it requires making some kind of menu/UI. Would the game pause while you have landed? Any objections to using alpha blending on the menu? It will reduce FPS noticeably on some machines.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Non-Subspace Related Coding All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 672 page(s) served in previous 5 minutes.

phpBB Created this page in 0.487514 seconds : 40 queries executed (92.0%): GZIP compression disabled