The Geek Biker

Rambles of a geek that rides a bike

Monthly Archives: September 2010

When to jump from a moving vehicle

Yesterday I was faced with this question. And not in the sense of “When is it safe to jump from a moving vehicle?”, but rather, in what kind of situations justifies jumping from a moving vehicle?

I’ll tell you what happened to me yesterday and you can judge for yourself…

I worked a bit later that usual yesterday, and by work late a meant coding the dying sequence of the enemies in my game! Yip…they die and there is blood everywhere. … anyway…I’m digressing.

So not wanting to wait 20 minutes for a train and another 20 minutes for a bus, I decided to catch a cab. (Not physically running after it…). I got in the cab and the driver was having a massive argument with someone over the phone…I mumbled where I wanted to go and he kept arguing.

So I sat there in silence and let my wife know that I’m on my way home. The text was “I’m in a cab”…followed by “It stinks”. She gave me some sound advice in return…”Hold your breath”. Still contemplating what she meant by that I sat there in silence.

Suddenly the cab driver (who finished arguing) turned his attention to me. “Sorry sir, I was on the phone with my brother. You see, there is something wrong with my stomach and I got blood in my stool…” …. WTF!!!! My response … “Ooo”.

So he continued: “What field do you work in”. My answer was short as you might have learnt, I don’t like talking to people I don’t know : “computers”.

That did not stop him; “So do you know what could be the cause?”…”, trying to divert the conversation I said “probably not”. He continued again :”…of blood in stool…you know…what causes it?” … I was now trying to hold my breath as my wise wife said in the hope of passing out. “No, no, I don’t …no medical experience at all. Never had biology, can’t help you whatsoever..” was my answer at  last…He then nodded and offered me a drink of water. “Do you want some water, I carry this bottle around”. I managed to say through my astonishment “I’m fine, ..thanks…”

So we sat in silence while I was looking for a soft landing.

Close to home he was on the phone again in a language I luckily didn’t understand. But my great mind started to decipher what he was talking about…since he spelt it out in English to the person on the other side of the phone… it went along the lines of “bla bla bla blood in stool,…blood in stool, bla  bla S-T-O-O-L,….O-O-L, bla bla bla.”

I told the cab to stop so my landing will be softer, paid really quickly and ran…I think my last words to him was “good luck with that”.

Next time, here is a reference card:

Advertisements

Maps and Tiles

Right,

It has been a while after I’ve implemented the looting system (which was a major mile stone), but I haven’t been doing nothing. I’ve started looking at the map system and a world scenario. This involved digging through old blogs and gather information around top down map systems in general to see what will best fit my game. -The last bit is quite ironic as I’m making this up as I go along.

I’m pretty sure I’ve gone about it the wrong way, but decided to go with Mappy.

Not being impressed with it’s look and feel initially, I kept going and found Tiled. This looked pretty good, but the examples were lacking and even though I really liked the XML state it stores maps in, I found it bothersome to implement. But it had a few tiles that looked pretty good.

So back to Mappy; with new determination and a will to get it done, I spend an hour or two getting mappyal.c implemented. This didn’t go as smooth as I hoped as there was a lot of casting issues all around.

Once that was done, I created my first map, loaded it in game a few hours later and BINGO.

Next step was to implement map transition when you walk off screen. Luckily I implemented the loading of maps in such a way that it can easily be loaded when passed in a simple x and y coordinate.

Next on the to-do list. Associate objects with each map. So different maps have different objects as an obvious answer. Here is a quick screen shot of what my first map looks like. This should be the starting point of the game. Well, that is the idea….and no, there is no story line yet.

Simple looting system

I’m pretty sure that there are a lot of looting systems out there, so again I thought I’d write one that I’d understand….so it’s going to be a very simple one.

The main idea is that the odds of getting a weapon type in the game, should range from good to bad. This should depend on the type of weapon,right?

So…currently I have 6 types of weapons built into the game.

  1. hands (no actual damage, it is like holstering you weapon…yes, there is a reason behind the madness).
  2. revolver
  3. pistol
  4. shotgun (spreadable bullets is a future concern)
  5. MG
  6. Rifle.

So the odds of picking up the weapons should resemble:

  1. hands      100%
  2. revolver 60%
  3. pistol       50%
  4. shotgun (spreadable bullets is a future concern)40%
  5. MG     30%
  6. Rifle   20%

“But hold on! that doesn’t add up!” I head you say. Actually it does, in a round about kind of way.

So the pseudo flow would look like this.

1. You throw a 6 die to see which weapon you will get.

2. Then you throw a “100” die and if your value rolled is between 0 and the weapon’s probability, then you get it.

One last step though. You flip a coin to see if you actually get a weapon or the weapon type’s ammo. Which ends up being a random number between 0 and 20.

In code it looks a lot neater I have to say.

I haven’t actually added health and power ups. I’m still thinking about this. “Health” is something you should buy at a doctor’s office in a town. Not something a criminal should throw down…Or you open a chest in hell and out pops a bottle of ACME’s Cure Me Quick.

And power ups is the other. Let’s say you pickup a power up for your weapon…personally I don’t think that you should be fiddling with a weapon while there are monsters/bad guys around.

Maybe that is another feature I should add. When you buy a power up from the shops. There should be an odd chance of the person attaching it to your weapon to actually do damage to your weapon. i.e. degrade the weapon life or something like that.

BTW.  weapon degradation is already included.

Well done and pat myself on the back for that.

O yeah…got the graphics to work as well and have been playing around with old GTA 1 sprites.

Shooting and Looting

Another update on the game in the making….I might actually call it that as it will never finish.

The Game In the Making.

So after struggling a bit with cross platform coding etc etc. I’ve decided to ditch the netbeans on Linux, and rebuild another old laptop at home with a bare WinXP running MinGW, allegro and Code::blocks.

Code::Blocks is definitely  not the best IDE I’ve seen or used, but it is light weight and easy to set up. I decided to go with Code::Blocks when I realised I had to install JDK to install netbeans for C++ development…Pass.

So back to my game. my little avatar can do the following:

1. Walk around (pretty important for any game).

2. Pick up ammo on the ground.

3. handle two guns and pick up another if you discard one. (Currently the discarded weapon is wiped from memory, so no return if you throw it away by accident.

4. Different weapons -> different damage.

6. Can kill an enemy( HP decreases as per the weapon damage).

What is next?

Well I thought I’d better introduce an improvement on the looting system. When you shoot an enemy they shoot at least help you out by throwing down some ammo, weapons or health (maybe even a power up). It is in the enemy code of conduct to help the main character when dying.

There after I should think about map generation and tiles….arg….

From wall to wall and beyond

A quick update on the game in the making.

Last time I wanted to do the following to things.

1. See what happens when my moveable box collides with one that moves from side to side

2. Implement some type of page flipping to be able to have a bigger arena to play in than a physical screen allows.

The first was pretty easy. I added a box that moves in one direction and as soon as it touches the edge of the screen, change direction. Then I moved my character in front of it and viola, it collided with great success.

The next one was a bit … well… interesting. I added a virtual screen and had to move the physical screen offset when my moveable character cam close to the physical screen’s edge….make sense? didn’t to me the first few tries. After I got the 4 main directions down, had to implement the 4 in between.

Now that the main movement is done, I can try to add other functionality, like shooting!

I know, I had shooting in there, but had to be removed (basically forgot about it) during major re-factoring.

I think I need to sit down and pen down how my objects will work.

i.e What properties does a bullet object have? how will the health system work? will I have a weapon object or should the damage be a property on the gameCharacter object? You know, all the things I should have thought about ages ago.

And I need to think about splitting my code into a better structure. i.e. have the movement engine source separate from map engine source etc.

too many things