IdeaMonk

thoughts, ideas, code and other things...

Monday, February 15, 2010

Nincompoop goes Linux

Ah! more than a year ago I wrote this yet to be finished 2d sidescrolling game with very crappy collision detection and pretty poorly programmed, blah blah called NinCompoop - The Unfinished Quest.

I felt like porting it to linux today. The good news is that allegro is already in the Ubuntu repository, so all I needed to do was a sudo apt-get install liballegro4.2.-dev

Porting again, was dead simple, just change the windows styles slashes to linux style slashes - \\ to /

So here we are, time for a demo -



Fork it here - http://github.com/ideamonk/Nincompoop, a request plz don't complain about ze lameness of teh code.

Labels: ,

Tuesday, April 07, 2009

Nincompoop is on Allegro.cc :)

I had almost forgotten what I submitted on Allegro.cc 2 months back!
Just got a mail today from Depot Manager on Allegro.cc saying the "Paint Daubs effect in Allegro" and "Nincompoop - The Unfinished Quest" has been added to Projects :)
Checkout http://www.allegro.cc/depot/Nincompoop-TheUnfinishedQuest/

I wish they have another PWNED! (game-dev) contest this year @ Shaastra 2009. Would love to play around some physics engines and XNA this time nopes Pyglet and Pymunk (python port of chipmunk) would be more satisfactory personally. Wish to get into another hacking contest too, just for some faltooo cash :)

Yippeeee!

Labels: , ,

Thursday, October 02, 2008

How object oriented programming saved me from working for hours!

A week back I was meddling with my 2-D game called nincompoop to be put to Pwned!- the game programming contest at Shaastra 2008, iit madras. Just 2 days left for submission... and I was done with the basic class for hero and level collisions. What to do?? How much still left to do?? Will this ever finish?! These were the questions daunting me hour by hour...
Untill a simple idea struck my mind! I asked to myself... What are enemies in the game? and the lord said "Nothing but a hero who is controlled by the computer" and that was precisely the point where I felt the game was almost done! What basically I mean here is that, remove all the keyboard controls from a hero class, automate its motion, and to do that we just have to modify the hero class a bit.
Here's how it works -
// The hero class
class nincompoops {
public:
// *** Bitmap & allegro assets for hero
BITMAP *sprite_walk[4][12]; // 12 frame animation for walk

// *** Motion variables
bool walking, onGround,jumping,attacking;
int heroFrame, direction,oldDirection;
int jumpVel;
int xvel, yvel;
int recoil;
.
.
.

nincompoops(){
// *** initial motion settings
score=0;
jumping=onGround = walking = dropping = false;
velMax = 3;
.
.
.
.

}
bool loadSprites();
void levelCollision(BITMAP *lev);

void draw (BITMAP *bmp);

void decideKeys();
};
And the enemies class is a very similar class with some modifications in the decideKeys() functions, where desideKeys() actually never checks for keys.
class enemies {
public:
// *** Bitmap & allegro assets for enemy
BITMAP *sprite_walk[2][12]; // 12 frame animation for walk

// *** Motion variables
bool walking, onGround,jumping,attacking;
int heroFrame, direction,oldDirection;
int jumpVel;
int xvel, yvel;
int recoil;
int MaxFrames;
.
.
.

enemies(){
// *** initial motion settings
score=0;
jumping=onGround = walking = dropping = false;
velMax = 3;
.
.
.
.

}

bool loadSprites(int type);

void levelCollision(BITMAP *lev);

void draw (BITMAP *bmp);

void decideKeys() {

// doesn't look for keyboard keys, manages by collisions etc to the level
... rest of the hero class code
}
};
So, what about the items in the game!! The answer is simple again, items are nothing but enemies that don't move! So, I come up with an item class in another 10 or so minutes. :)

Finally we do something like this -
vector<enemies> enemyset;
vector<enemies>::iterator ei;

vector<items> itemset;
vector<items>::iterator ii;
And load all enemies and items from a file, and the game loop goes like this
// pseudocode
while (!key[KEY_ESC]) {
nin.decideKeys();
nin.levelCollision (cmap);

for_each item in itemset {
item.draw(work,x,y);
item.testCollision(hero);
}


for_each enemy in enemyset {
enemy.draw(work,x,y);
enemy.decideKeys();
enemy.testCollision(hero);
}

blit_all_to_screen();
}
The game finally finished around 1 AM on 30th of September which happened to be the last date. Thanks to understanding machhas @ iit, they had no problem for late submissions. And thanks to OOP, I finished major chunk of game within four hours... and that means I couldn't work on giving finishing touches, adding a story, animations, humour etc. more about the fest soon...

Labels: , , , ,

Tuesday, September 30, 2008

NinComPoop !! all ready for shaastra 2008

Finally after a long wait I have come up with my first 2D side scroller game. I always wanted to make one, thanks to Pwnd! at Shaastra 2008, iit Chennai, the dream came to reality within 3 days of sleepless frustrations. Today is the last date for submission, I hope I get through, or atleast some people enjoy playing this mario style game [:P]

Short description for contest -
Nincompoop is a fool who has been challenged by his friends to dare to enter the silent hills.No one has come back alive from the Silent Hills ever. Nincompoop thinks that if he can come back alive, he can prove to his friends that he is not a mere fool and would never be laughed at again. Help nincompoop in his quest to prove to the world that he is the best!

Controls:
left right - movement
left alt - jump
left control - boost
spacebar - attack


after fixing and adding one more level, I will give you the final much better n funnier nincompoop.

The end result - 5 days filled with fun @ iit-m
2nd prize in Game programming! (nincompoop @ pwned!)
2nd in Hacking Contest
Cash! entire trip was rendered free!

Labels: , , , ,