Let me show you the way.

Tuesday, 26 August 2008

So I got bored tonight and figured I'd write a game...

I'm genuinely not sure whether I've seen this concept before, or came up with it myself. I suspect the former. I know that I sat down with the intention of coding this game and knew how it would play and what the mechanics would be.

Having said that though I cannot think of a similar game I've played - though parts are obviously derivitive.

Anyway the aim of the game:

  • A (single currently) ball bounces around the screen.
  • You draw lines upon the screen, using the mouse, to influence the movement of the ball.
  • The level (game) is over when the ball lands in the "exit box".

Thus far the game exists only in the skelital form with the minimum required functionality. There are two modes currently: "easy" & "hard". The hard mode was primarily added to prove to myself that the "leveling" system could work in a fun way.

Feedback welcome. Especially if it can tell me where I'm going wrong with the collision detection - but even if it is to critique my hacked-up SDL coding.

(The only other SDL coding I've done was in C, and was the mousetrap game.)

Obviously the game is written in perl, and I admit nasty perl at that. To play it you'll only need:

apt-get install libsdl-perl

Code:

ObQuote: The Chronicles of Riddick

| 12 comments.

 

Comments On This Entry

[gravitar] Steinar H. Gunderson

Submitted at 23:25:48 on 26 august 2008

This sounds like a fun concept (somewhat like The Incredible Machine), although perhaps a short-lived. On my laptop the collision detection is _completely_ borked, though, so it's basically unplayable (the ball goes in a random direction). I haven't looked at the code, but it doesn't sound very difficult: You know the formula for the line (ax by = 0), you know the distance from the centre of the ball to the line (just insert x and y into the formula for the line), and if the centre is less then R (ie. the ball's radius) away from the line and heading towards it (motion vector line normal < 0), you need to reflect the motion (new motion vector = 2 * line normal old motion vector gives you the direction, the magnitude is the same).
/* Steinar */
[gravitar] Felipe Sateler

Submitted at 23:31:58 on 26 august 2008

A similar game comes preloaded with Windows Vista, so I'm guessing that's were you got the idea.
[gravitar] Jo Shields

Submitted at 23:44:35 on 26 august 2008

Promise you won't get mad?
It's a game provided with Windows Vista, called InkBall
http://en.wikipedia.org/wiki/InkBall
[gravitar] rpetre

Submitted at 23:46:54 on 26 august 2008

Sounds like one of the default games in Vista, I forgot its name, maybe you've seen it?
[gravitar] Ben Hutchings

Submitted at 01:51:32 on 27 august 2008

Sounds a bit like QIX
[gravitar] Warbo

Submitted at 02:07:07 on 27 august 2008

Thinking of this maybe? http://en.wikipedia.org/wiki/Crayon_Physics
[gravitar] Roopesh Chander

Submitted at 07:05:19 on 27 august 2008

Hey, that's Inkball, the only decent game that ever shipped default with any version of Windows (eek). Well, yeah, skx is pretty primitive, I agree. (What's skx anyway?)
[gravitar] Fabian

Submitted at 07:30:25 on 27 august 2008

Sounds like one of the games that is shipped with Windows Vista. Not kidding...
[gravitar] Robert Hart

Submitted at 07:42:55 on 27 august 2008

Anything like this http://en.wikipedia.org/wiki/InkBall?
[author] Steve

Submitted at 08:01:40 on 27 august 2008

I think you've all told me that it's the Vista game, Inkball.

I swear I've never played it, but I guess I've seen it around on TV/adverts or something!

I'll have to see if I can tidy up the collision detection Steinar. For me it seems to be correct a lot of the time, but not entirely..

[gravitar] Steinar H. Gunderson

Submitted at 16:39:30 on 27 august 2008

Steve, I guess you just have a faster machine than I. Try it on a slower one so the framerate goes down, and you'll see it bounces all over the place :-)
/* Steinar */
[author] Steve

Submitted at 16:54:39 on 27 august 2008

That could well be the case. I've tried it on two machines and both cases it was acceptible.

I guess we could change the heartbeat() function to slow things down, but I'm not too sure how that would affect things.

Anyway my current plan is :

  • Either fix the recoil & declare it done.
  • Leave it alone and move on.

No strong preference yet. For completeness I'd like to make it "perfect", but I'm stumped.

 

Comments are closed on posts which are more than ten days old.

Recent Posts

Recent Tags