cppgameprogramming.com

It is currently Mon Sep 06, 2010 9:25 pm

All times are UTC




Post new topic Reply to topic  [ 27 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Nameless platformer game
PostPosted: Wed Jul 28, 2010 2:09 pm 
Offline
Moderator
User avatar

Joined: Wed Feb 25, 2009 3:00 am
Posts: 498
Location: Argentina
Here is my nameless platformer game.
My internet stopped working for about 3 days so I had enough time to finish it (not like I had anything better to do in my PC)

Screenshots:

Editor mode with badass settings turned on:
http://img442.imageshack.us/i/editor.png/

Game mode:
http://img411.imageshack.us/i/gamemode.png/

Main menu:
http://img228.imageshack.us/i/mainmenuu.png/

Download link -> http://www.mediafire.com/?yjzvjajyc1wkesf
Read the readme file please.

Fun facts:
-The player collision detection is made up from a set of boxes, so you can resize your player as you want and it should still work (I didn't try many sizes though, report any bugs you find)

-The default (and only, for now) name for the map is map.js this is because the original game that I made was written in javascript and used the HTML canvas.

-The credit list is quite long.

-The .exe size is 90 KBytes.

-When the player dies he explodes in a bloody mess of red pixels

If anybody has got anything that would like to share (name suggestion, character skins, tiles, maps (multiple maps planned), gameplay suggestions, sounds (yeah, sounds planned too), menu skins, whatever) please do post :)

_________________
Image


Top
 Profile  
 
 Post subject: Re: Nameless platformer game
PostPosted: Thu Jul 29, 2010 12:10 pm 
Offline
Code Master

Joined: Sat Jul 03, 2010 9:28 am
Posts: 110
Location: Belgium
Nicely made. You can have fun killing the guy by going into the editor, selecting the spawn tile, and left-click on it once(setting it to deadly) :twisted: :twisted: :twisted: . Start the game, and he will fall from the air as there is no spawn point. If you run into the flag then, he will die and keep spawning at the flag, so he will keep dying...
Just fun

_________________
- Addicted Memory programmer XD - made a port to TI-83+/TI-84+ and planning nds version


Top
 Profile  
 
 Post subject: Re: Nameless platformer game
PostPosted: Thu Jul 29, 2010 7:35 pm 
Offline
Moderator
User avatar

Joined: Wed Feb 25, 2009 3:00 am
Posts: 498
Location: Argentina
XD, Didn't test that out. The behaviour of the character without spawn point is unpredictable

_________________
Image


Top
 Profile  
 
 Post subject: Re: Nameless platformer game
PostPosted: Fri Jul 30, 2010 12:34 pm 
Offline
Code Master

Joined: Sat Jul 03, 2010 9:28 am
Posts: 110
Location: Belgium
One other thing Flacko, I found a little "mistake" in your readme file: in the game, you have to use zqsd/wasd to move your character instead of the arrow keys, as stated in the readme.

PS: I'd like to know how you did the bloody mess, because I'd like to use something like it for fireworks in my game.

_________________
- Addicted Memory programmer XD - made a port to TI-83+/TI-84+ and planning nds version


Top
 Profile  
 
 Post subject: Re: Nameless platformer game
PostPosted: Fri Jul 30, 2010 1:13 pm 
Offline
Moderator
User avatar

Joined: Wed Feb 25, 2009 3:00 am
Posts: 498
Location: Argentina
Whoops, fixed for the next version.
For that I used an array of classes
Code:
#include <allegro.h>

class CPixel
{
   public:
      void draw()
      {
         putpixel(buffer,(int)(-SCR_X+x),(int)(-SCR_Y+y),color);
         putpixel(buffer,(int)(-SCR_X+x)-1,(int)(-SCR_Y+y),color);
         putpixel(buffer,(int)(-SCR_X+x)+1,(int)(-SCR_Y+y),color);
         putpixel(buffer,(int)(-SCR_X+x),(int)(-SCR_Y+y)-1,color);
         putpixel(buffer,(int)(-SCR_X+x),(int)(-SCR_Y+y)+1,color);

         putpixel(buffer,(int)(-SCR_X+x)+1,(int)(-SCR_Y+y)+1,color);
         putpixel(buffer,(int)(-SCR_X+x)+1,(int)(-SCR_Y+y)-1,color);
         putpixel(buffer,(int)(-SCR_X+x)-1,(int)(-SCR_Y+y)+1,color);
         putpixel(buffer,(int)(-SCR_X+x)-1,(int)(-SCR_Y+y)-1,color);
      }
      void move(char dir, float sp)
      {
         switch(dir)
         {
            case 'u':
               y -= sp;
               break;
            case 'd':
               y += sp;
               break;
            case 'l':
               x -= sp;
               break;
            case 'r':
               x += sp;
               break;

            default:
               break;
         }
      }
      float yvel;
      float xvel;
      int color;
      float x;
      float y;
};


And then when the player gets killed
Code:
void CPlayer:: kill()
{
   dead = true;
   blood = new CPixel[240];
   for(int i=0; i<240; i++)
   {
      blood[i].color = makecol(rand()%128+128,0,0); //color will range from 128,0,0 to 255,0,0
      blood[i].x = x+w/2;//Spawn the pixels in the center of the player
      blood[i].y = y+h/2;
      blood[i].xvel = rand()%10;
      blood[i].yvel = -(rand()%15);
      bool dir = rand()%2;
      if(!dir) blood[i].xvel = -blood[i].xvel;
   }
}


And this is the code for collision detection (without the collision detection, I just added a check if the player is dead, if he's not, it checks collisions, else it makes the blood fall)
Code:
      int a = 1;
      for(int i=0; i<240; i++)
      {
         blood[i].yvel += 0.2;
         if(blood[i].xvel > 0) blood[i].xvel -= (rand()%5)/10;
         else if(blood[i].xvel < 0) blood[i].xvel += (rand()%5)/10;
         blood[i].x += blood[i].xvel;
         blood[i].y += blood[i].yvel;
         if(-SCR_Y+blood[i].y > SCR_H)
         {
            a++; //If this is out of screen, increase counter
         }
      }
      if(a>=240) //If all the drops are out of screen, revive the player and delete the array
      {
         delete[]blood;
         blood = 0;
         spawn();
      }

_________________
Image


Top
 Profile  
 
 Post subject: Re: Nameless platformer game
PostPosted: Fri Jul 30, 2010 1:25 pm 
Offline
Code Master

Joined: Sat Jul 03, 2010 9:28 am
Posts: 110
Location: Belgium
What do these two vars/constants mean?
SCR_X and SCR_Y

_________________
- Addicted Memory programmer XD - made a port to TI-83+/TI-84+ and planning nds version


Top
 Profile  
 
 Post subject: Re: Nameless platformer game
PostPosted: Fri Jul 30, 2010 1:27 pm 
Offline
Moderator
User avatar

Joined: Wed Feb 25, 2009 3:00 am
Posts: 498
Location: Argentina
They are variables that store the actual X and Y position of the screen.
I only use them in game and editor modes.

_________________
Image


Top
 Profile  
 
 Post subject: Re: Nameless platformer game
PostPosted: Fri Jul 30, 2010 1:28 pm 
Offline
Code Master

Joined: Sat Jul 03, 2010 9:28 am
Posts: 110
Location: Belgium
Thanks, I get it now

_________________
- Addicted Memory programmer XD - made a port to TI-83+/TI-84+ and planning nds version


Top
 Profile  
 
 Post subject: Re: Nameless platformer game
PostPosted: Sat Jul 31, 2010 1:08 am 
Offline
Moderator
User avatar

Joined: Tue Aug 19, 2008 2:34 pm
Posts: 102
Cool game Flacko 8-). The editors a nice touch aswell and easy to use. The javascript intrigues me though, is it true js or a file with a js extension?

And I know its been said before but the death effect looks amazing!


Top
 Profile  
 
 Post subject: Re: Nameless platformer game
PostPosted: Sat Jul 31, 2010 6:06 am 
Offline
Moderator
User avatar

Joined: Wed Feb 25, 2009 3:00 am
Posts: 498
Location: Argentina
I just kept the extension, however, the old maps would look like this:
Code:
//JS Mapfile 24610
//10,11
map = new CMap(
[
[2,2,2,2,2,2,2,2,2,2,],
[2,0,0,0,0,0,0,0,0,2,],
[2,0,0,0,0,0,0,0,0,2,],
[2,0,0,0,0,0,0,0,0,2,],
[2,0,0,0,0,0,0,3,4,2,],
[2,0,0,0,0,0,0,0,0,2,],
[2,0,0,0,0,0,0,0,0,2,],
[2,0,0,0,0,0,0,0,0,2,],
[2,0,0,0,0,0,0,0,0,2,],
[2,0,1,0,0,0,5,0,0,2,],
[2,2,2,2,2,2,2,2,2,2,],
]
)


Then I remade the game in C++ and changed the map format to a binary so maps would take less time to load and they'd be smaller in file size.
It seems like javascript hasn't got file I/O capabilities so I just linked my html file with the map.

_________________
Image


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group