Moving Right Along...Okay, That's Far Enough

Talk about making games.

Moving Right Along...Okay, That's Far Enough

Postby Pete Holland Jr. » Sat Feb 16, 2008 4:23 pm

I'm playing around with a new idea, and I'm hitting a snag. I'm hoping someone here can help me out.

First, the background. It's a simple 2D side-scroller. In fact, picture the original Super Mario Bros., because I am trying to replicate an effect from the game and having problems with it.

Because I want to keep this flexible, I'm not drawing out the entire level (I use GE on a 1.6G machine, but also want the resulting game to work on my 400Mhz machine, like some of my other goofing around projects), so this may be a little more complicated, but it's to take system resources into account. The current plan is to create a marker. As the player advances, the marker moves off the screen. Once it moves off the screen, it is destroyed, but not before setting up the next marker (roughly one screen away) and any obstacles that would appear on that screen. Gameplay proceeds only to the right, backtracking to the left is not allowed. This has implemented fine so far (it's still early, I'm sure testing will reveal problems later).

So, here's what I've got. My character appears on screen. He runs to the right normally. When he hits the halfway point, (x == 0), he stays in place and the path starts moving to the left, creating the illusion of movement. When he stops or goes left, the path stops moving and the character moves normally. I have a barricade set up just offscreen on the left side, with collision detection preventing the character from going any further to the left. So, on the left half of the screen, the character can move wherever he wants. He never touches the right half, the screen scrolls to the left to advance him. Just like SMB.

Some of you may already be getting what my problem is.

Now, what I want to do is the level-ending boss set-up. When you reach the end of the level, the scrolling doesn't work. Basically, the path will hold steady and the character can roam anywhere onscreen, even the right half. Sort of like facing King Koopa at the end of the levels in SMB. The problem is, how do I do it?

In my global code, I set up a variable called "allrange" and initialized it with a 0. This is supposed to be normal movement. The scripting under Right Key Down checks the allrange variable. If it's set for 0, the player moves around as I've described. If it's set for 1, the player is supposed to move anywhere on the screen without regard for the halfway point.

For some reason, I'm not making this work, though. I set up a couple of keys to switch the variable from 0 to 1 and back again whenever I want, and set up a textNumber actor to show me what value is currently in allrange. I can manipulate the value no problem. But for some reason, the screen just won't follow suit. Regardless of what allrange has in it, it will continue to behave in normal mode, with the screen scrolling once the character hits the halfway point.

I only cover this in the Right Key Down portion of the actor control, since that is the only circumstance that would cause the behavior of the playfield to change. The decision is handled with a condition branch, if allrange == 0, then the normal movements are done. If allrange == 1, (not an ELSE statement), then the character moves no matter what and the xvelocity of the playfield is set for 0.

Like I said, I can see the register changing, but for some reason, when it comes time to switch to allrange mode, changing the variable doesn't seem to make a difference. Can anyone help me figure out what I need to do differently to make the actor acknowledge the change?
Pete Holland Jr.
 
Posts: 19
Joined: Thu Aug 17, 2006 2:15 am
Score: 0 Give a positive score

Re: Moving Right Along...Okay, That's Far Enough

Postby DilloDude » Sat Feb 16, 2008 9:20 pm

Maybe something like this:
Code: Select all
if (x >= 0 && allrange == 0)
{
    //move path
}
else
{
    x += 3;//move player
}
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron