The Geek Biker

Rambles of a geek that rides a bike

Walking into walls

Another game post.

So after numerous pages on collision detection and trying to implement some examples, I decided..screw that.

So I’ve decided to use a the simplest bounding box collision detection for my upcoming 2D game and rewrote it so I actually understand it.

It still didn’t work, taking into consideration that I haven’t touched C++ in 4 years, I re-tried and re-tried…but nothing.

No collisions are detected. even the simplest of (object1.x + object1.w/2 > object2.x – object2.w/2) didn’t work…fuck’ol!!

So I sat there/here and looked at my screen…for a while and thought to myself….”Myself, mybe you should try passing the object pointers to the function….”.

And vio-fucking-la….(object1->x + object1->w/2 > object2->x – object2->w/2) worked a treat.

So I uncommented the rest of my miserable code and suddenly my little rectangle sprite was walking head first into walls.

What is next???

Two things to do:

1. Create a sprite (box) that moves from side to side and make sure both my movable object and the auto-movable one stops when they collide. Or at least make the auto-movable one change directed.

2. Implement a virtual screen and let the screen scrolling begin. Since I want a retro look and feel, I decided that the screen resolution will be 320×200 (or 640×400 depending on my patience) and make it scrollable to at least twice the size. So I will have a 320×200 screen displayed and scrollable to a bigger “arena”.

…But first I received an el’cheap-o mp3/video player which I will strip of it’s ROM and attempt (once again) to install RockBox on it.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: