You are not logged in.
Lost Password?


Register To Post



 Bottom   Previous Topic   Next Topic

#21
Re: Castle of Doom
Posted on: 2010/4/27 18:25
PVB Elite
Joined 2008/4/26
USA
937 Posts
CoderContributorTop10 PosterHOTY09 3rdLong Time User (11 Years) PVBCC 2010 EntryPVBCC 2013 Entry
OK, I worked on the collision detection of the walls. How is this? Better? Next up: Working on the jumping.

Attach file:


vb cd.VB Size: 256.00 KB; Hits: 180
c cd.c Size: 10.67 KB; Hits: 199
Top

#22
Re: Castle of Doom
Posted on: 2010/4/27 20:21
VUE(xpert)
Joined 2010/2/15
Netherlands
250 Posts
Long Time User (9 Years)
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)
Top

#23
Re: Castle of Doom
Posted on: 2010/4/28 13:04
PVB Elite
Joined 2008/4/26
USA
937 Posts
CoderContributorTop10 PosterHOTY09 3rdLong Time User (11 Years) PVBCC 2010 EntryPVBCC 2013 Entry
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.

Attach file:


vb cd.VB Size: 256.00 KB; Hits: 154
c cd.c Size: 9.44 KB; Hits: 164
Top

#24
Re: Castle of Doom
Posted on: 2010/4/28 14:42
VUE(xpert)
Joined 2010/2/15
Netherlands
250 Posts
Long Time User (9 Years)
Crashes for me in Mednafen, not sure if it's the emulator.
Top

#25
Re: Castle of Doom
Posted on: 2010/4/28 15:03
PVB Elite
Joined 2008/4/26
USA
937 Posts
CoderContributorTop10 PosterHOTY09 3rdLong Time User (11 Years) PVBCC 2010 EntryPVBCC 2013 Entry
That's odd, it works fine in Reality Boy.
Top

#26
Re: Castle of Doom
Posted on: 2010/4/28 15:06
VUE(xpert)
Joined 2010/2/15
Netherlands
250 Posts
Long Time User (9 Years)
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.

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 (0"something";
else if (
== 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. ;)
Edited by DaVince on 2010/4/28 15:19
Edited by DaVince on 2010/4/28 15:24
Top

#27
Re: Castle of Doom
Posted on: 2010/4/29 5:14
Nintendoid!
Joined 2009/8/11
USA
112 Posts
Long Time User (10 Years)
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.
Top

#28
Re: Castle of Doom
Posted on: 2010/4/29 13:55
VUE(xpert)
Joined 2010/2/15
Netherlands
250 Posts
Long Time User (9 Years)
Yeah, I did it really quickly to give just a push in the right direction, so there's bound to be things missing. :P 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).
Top

#29
Re: Castle of Doom
Posted on: 2010/12/29 11:19
PVB Elite
Joined 2008/4/26
USA
937 Posts
CoderContributorTop10 PosterHOTY09 3rdLong Time User (11 Years) PVBCC 2010 EntryPVBCC 2013 Entry
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.

Attach file:


vb cd.VB Size: 512.00 KB; Hits: 157
Top

#30
Re: Castle of Doom
Posted on: 2010/12/30 1:20
VUE(xpert)
Joined 2010/10/22
Sweden
343 Posts
ContributorLong Time User (8 Years) 30+ Game Ratings
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 :)
Top

 Top   Previous Topic   Next Topic


Register To Post