Original Post

Ever since I was a kid, I had an idea for a game in which a guy is trapped in a castle with tons of rooms, and the object of the game was to exit the door in each room. It’s kind of like a platform game, but with puzzle elements. This is a proof-of-concept to see if I could actually program such a game, and here it is. Left/right moves guy, A is for jumping. Right now, there’s no enemy or door to another room, so there’s not really that much to do so far.

Attachments:
64 Replies

Yes, the movement and collision are a LOT smoother, good job. πŸ™‚

I did notice that it’s very easy to fall off the top of the little wall parts sticking out, perhaps a bit *too* easy. Also, after touching the end door, collision detection stopped working on the sprites and I could jump through some of the lower ceilings.

(post edited)

OK, I can’t come up with a good jumping code, so I’m asking you guys. What should I do about this? I’ve changed the code around so the walking animation is back, but I have removed the jumping code.

Attachments:

Crashes for me in Mednafen, not sure if it’s the emulator.

That’s odd, it works fine in Reality Boy.

Wait, nevermind… Something odd is going on on my side. Time to reboot I guess, sorry for the false alarm.

Edit: pretty good. There’s something about the animation that makes the movement speed seems like it’s varying, though. Not sure what causes it, maybe his back moving like it does.

As for jumping, something like this works decently (very much pseudo code):

yspeed = 0;
gravity = 1;  //Change this to whatever gravity value works well.

while (gameloop)
{
  yspeed += gravity;
  player_y += yspeed;  //You can divide yspeed or lower gravity to alter jump speeds.

  if (pressing jump key)
    yspeed = -some_value;  //You can tweak this value to alter jump height.

  if (touching floor)
    yspeed = 0;
}

Sorry for not having checked your .c file yet, if it’s obvious. :rolleyes

Also, the above system is VERY simple, not taking into account for pixel-perfect collision detection. You need a bit more for that (and to avoid your character getting stuck in the floor), but I’m sure you can figure it out from here. πŸ™‚

EDIT: just checked the code… It’s a pretty big mess of if conditions I see. You can at least make the engine itself a bit more efficient by using “else if”s where appropriate.

Example:

if (x < 0) "something";
else if (x == 0) "something else";
else "something when x > 0";

Why is this more efficient? Well, if the first if ran, we already know that all other related conditions WILL be false (if x < 0 we know it can't be 0 or higher). Thus the engine doesn't actually NEED to check these extra conditions, and an else if / else in the code WILL actually skip them for you. That's less checking and code execution per frame. πŸ˜‰

  • This reply was modified 14 years ago by DaVince.
  • This reply was modified 14 years ago by DaVince.

DaVince, your code seemed to be missing stuff. Looking at the code, it looks like the y distance would increase by 1 acceleration unit whenever speed = 0. I think this would work better.

while (loop_condition == TRUE) {
	if(y_dist == 0) {
		/* We are on the floor, so check if a jump is requested */
		if ((keys & jump_key) == jump_key) {
			/* Only checks if key is pressed when on the floor */
			y_speed = max_jump_velocity;
			y_dist  = y_speed;
		} else {
			/* No jump requested, make velocity equal to 0 */
			y_speed = 0;
		}
	} else {
		/* Middle of a jump, update speed, calculate distance */
		y_speed -= accel;
		y_dist  += y_speed;
	}
}

Once again, untested code.

Could be beneficial to check to make sure y_dist is within range for the original if statement. If you are outside of the possible range a y could be, then you have to error handle. But this was intentionally left out.

This code assumes ground is 0, and you jump in the positive y direction.

A more realistic feel would include checking how long the button was held for to adjust the length of the jump, which is not included in the above code.

I have not looked at the game’s C code either, or even tried out the game. I will get around to it sometime, just been busy.

Yeah, I did it really quickly to give just a push in the right direction, so there’s bound to be things missing. πŸ˜› You’re right about that part, but it could be avoided simply by not adding to the yspeed (or velocity, in your case) at all when he’s on the floor (or one pixel above it, anyway).

OK, I worked on the collision detection some more and fine tuned it a lot (spent the last few hours on it, actually!) and got it to an acceptable IMO level. I still haven’t put any improved jumping code in yet, though. Works on Mednafen, untested in Reality Boy. (Changed Mednafen to my default emulator.) Up next, walking animation.

Attachments:

Tried the game and it was good. Sure it reminded me of a Colecovision game but if it had been in the contest I’d totally have voted for it. Love platformers πŸ™‚

Tried it on my flashboy; works perfectly on hardware! Great potential!

Made the guy smaller and added a new level. Thanks for the compliments thus far.

Attachments:

The smaller person does make the game more fun and after you played about 5 levels it does get harder

The only thing I dont like is that there is no life system so you can play the same level over and over forever without ever really getting challenge to not get game over and have to start all over

Pretty cool… one suggestion I’d make is to make it not keep jumping if you hold A. It’s like he’s on a pogo stick πŸ˜› .

DogP

DogP’s suggestion is in the game now, but I think it’s too early for another release. I was thinking about putting some form of life counter or timer in for each room, so I think I will, only trouble is, I don’t know how many lives should each room start out with, or should there be a timer? Also, I’d really appreciate it if someone could help with the room designs. That’d be really nice.

I’ve changed things a lot. I’ve added a link to my signature to the latest version. I update this page whenever I work on it. Here’s a picture of what the game looks like now.

Attachments:

I was thinking more like 5 life in total and once you lose you must start all over from the begining of the game, gives more challenge

Other things might be to hard for you
-Music, some nice ingame music
-A menu system
A) options
B) gameplay
C) demo (you get to see the machine play some quick 30 sec demo)
D) An option to choose 2+ chars
-A nice intro story (blox 2 had one after all)
-Add in the game: moving platforms, pipes (like in Mario), ladder…

Not to be mean (just my option after all) but I would prefer to have the game be 100 levels at most if it has all the other features like music, menu system… then to make it 1000 levels but with nothing extra but then blox 2 had over 300 levels and still had so many nice features

Anyways, keep working on the game..its not that bad at all for being your first homebrew game that might get 100% finished

Oh how I wish I could put music in the game! I wrote a couple short songs that should be relatively easy to program in because the notes are all the same length. Unfortunately, no one has stepped up and decided to teach me how to put music in yet. Anyway, I put in a little backstory that plays once you start the game. As always, you can get the latest rom by clicking the link in my signature.

How does the king find anything in his messy castle where the doors are placed in the most weird place? πŸ˜›

Nice intro even if I prefer more of a cinematic intro like bound high its still a good enought intro for being your first one πŸ™‚

Maybe its an error but I play the game like 1-2 days ago and it was alright
I try it now on rdagon emulator and the intro is there but level one telle me its room 14
I enter door and I go to room 15 thats the same exact room
I enter door again and still same room but door 16

Anywqys keep working on it, with music, menu system… it could be as good as blox and then who knows, you might make more vb games πŸ˜›

Yes, I’m aware of this. It’s because I set the game to the latest room for testing (to see if I can complete it or not and to check if everything is in the correct place.) The reason that it says (right now) that level 15 is the same as level 14 is because I haven’t designed anything after level 14.

Hey, gang, I’ve now added jumping sfx! While I just can’t get the hang of music quite yet, at least it’s something to listen to!

Attachments:

 

Write a reply

You must be logged in to reply to this topic.