The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.39 / 5.00 38,635 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.09 / 5.00 15,161 ViewsOkay, this is really hard to explain and probably has a really tricky answer- so firstly can you have a look at what I have so far:
As you probably noticed after a few reloads is that sometimes, when the player is in certain places on the level, when they shift gravity they go flying out of the map :S
And thats my problem- I have no idea how to stop that from happening!!
here is the code im using atm
[player mc]
onClipEvent (load) {
var ground:MovieClip = _root.ground;
var grav:Number = 0;
var gravity:Number = 2;
var speed:Number = 8;
var maxJump:Number = -18;
var touchingGround:Boolean = false;
_root.dontMovePlayer = false;
}
onClipEvent (enterFrame) {
_y += grav;
grav += gravity;
while (ground.hitTest(_x, _y, true)) {
_y -= gravity;
grav = 0;
}
if (ground.hitTest(_x, _y+5, true)) {
touchingGround = true;
} else {
touchingGround = false;
}
if (_root.dontMovePlayer == false) {
if (Key.isDown(Key.RIGHT)) {
_x += speed;
}
if (Key.isDown(Key.LEFT)) {
_x -= speed;
}
if (Key.isDown(Key.UP) && touchingGround) {
grav = maxJump;
}
}
// this stops the player from walking up vertical walls
if (ground.hitTest(_x+(_width/2), _y-(_height/2), true)) {
_x -= speed;
}
if (ground.hitTest(_x-(_width/2), _y-(_height/2), true)) {
_x += speed;
}
if (ground.hitTest(_x, _y-(_height), true)) {
grav = 3;
}
}
[ground mc]
onClipEvent (load) {
amtOfTime = 5;
_root.rotateValue = 0;
}
onClipEvent (enterFrame) {
// gravity manipulation
if (Key.isDown(Key.SHIFT)) {
_root.dontMovePlayer = true;
//code for finding what rotation the level is currently at would go here
_root.rotateValue = 90;
_root.dontMovePlayer = false;
}
this._rotation += (_root.rotateValue-this._rotation)/amtOfTime;
}
So if ANYONE has ANY suggestions for a new hitTest engine for the player or a better way of rotating the world that I would love you forever :D
please please please try help! :'(
thanks
BUMP
Anyone?
If I could find a way of changing the maps point of rotation to the location of the player then it would work like a charm!
So does anyone know how to do that?
I think you might be over thinking this a bit.
In the example, it didn't seem that gravity was necessarily the big change, so much as rotating groundmc was. If that's the case, why would you really need to mess with your gravity variable. Also, I think whatever donotmove player is, might be causing some of the unusual behavior, (ie a logical conflict).
At 4/23/09 10:32 PM, doctormario wrote: I think you might be over thinking this a bit.
In the example, it didn't seem that gravity was necessarily the big change, so much as rotating groundmc was. If that's the case, why would you really need to mess with your gravity variable. Also, I think whatever donotmove player is, might be causing some of the unusual behavior, (ie a logical conflict).
Yes, rotating the ground mc *IS* the problem, the problem being that the ground rotates around a center point and thus the player gets shot out of the map- what i need is the map to rotate around the player but I have no idea how to do this :'(
Also, playerDontMove (or whatever it is) isn't the problem, it is just a variable that can stop the detecting of keypresses that allow movement
If you want the map to rotate around the player why dont you make a map holder movieclip with the map inside that. The map holder will be positioned exactly where the center of the player is at all times and the map within the map holder should move around as normal. When you rotate just rotate the map holder itself which will keep the rotation in the correct place.
At 4/24/09 07:37 AM, atomoxic wrote: If you want the map to rotate around the player why dont you make a map holder movieclip with the map inside that. The map holder will be positioned exactly where the center of the player is at all times and the map within the map holder should move around as normal. When you rotate just rotate the map holder itself which will keep the rotation in the correct place.
Nope, that doesn't seem to work- the player just falls down but it never hits the floor because the map is following the player :S
any other ideas?
First of all, I just want to double check, you are using Actionscript 2.0, yes?
Aside from what was already said. (Move the level, not the player)
My suggestions would be; to put this code in the _root frame of your game (INSIDE the .fla):
"ground_mc._rotation = 0"
(Not sure whether you've already done this or not, but if you haven't, you should, for some reason it lets flash work much better with rotations)
Count up to the spin, but make sure that you have code to make it stop.
Such that:
onClipEvent (load) {
var rotationvariable = 0
var counting = false
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.SHIFT)) {
counting = true
}
if (counting == true) {
rotationvariable += 15
_rotation = rotationvariable
}
if (rotationvariable >= 90) {
counting = false
}
}
(Or something to that effect) (also, how do you get those nice coding boxes in your posts?)(Yeah, I know, I put too many if()'s in my coding)(I tend to use variables for my movieclips properties that I change. It works better for me)
I'll try and think of other methods if you want.
Omit the "e" from my username if you wish... (I sometimes do... but only because I mispell it...)
Status: Ignoring Stupidity... (i.e. Ignoring myself.)
i have a hunch the problem is when the conversion from -180 to 0 takes place. run a trace
thanks for the help but it still doesn't work...
the map holder idea doesn't work, I've tried and rehashed and then retried again and It doesn't seem to work--
does anyone have any other ideas?? There must be a way to just change the point or rotation!!
Well, if you can manage to implement the code, there is a way to dynamically change the registration point (where it rotates around) using the stuff found here:
Dynamically change registration point
(I've never managed to do something like that, and so I've given up on trying to implement other peopls codes)
Omit the "e" from my username if you wish... (I sometimes do... but only because I mispell it...)
Status: Ignoring Stupidity... (i.e. Ignoring myself.)
wow that looks complexicated :S - i'll use that as a last resort...
anyway, I found some code on another forum that works!! well kinda works...
onEnterFrame = function () {
holder.ground._x -= holder._xmouse;
holder.ground._y -= holder._ymouse;
holder._x = _root._xmouse;
holder._y = _root._ymouse;
};
(on the main frame)
That code works off the x and y of the mouse, so when I put the mouse over the player mc and shift gravity- the map rotates around the player and everything goes 100% perfect :D
but I don't know how I can modify that code to work with the player mc's x,y rather than the mouse
I know this is probably a really stupid question but I can't figure out how to apply it - (how can _ymouse be inside an mc??)
So if anyone can help me out (for the last time hopefully) that would be great :)
That looks a lot like what atomoxic told you to do... (which, imo, makes the most sense)
Why didn't you say that you had a ground holder?
I don't know exactly how you have it set up, so I can't give you a code or anything, but there should be a way to have the
holder._x = player._x
While still moving the ground how far you wanted...
Omit the "e" from my username if you wish... (I sometimes do... but only because I mispell it...)
Status: Ignoring Stupidity... (i.e. Ignoring myself.)
At 4/25/09 12:51 AM, Multihunter wrote: Why didn't you say that you had a ground holder?
I don't know exactly how you have it set up, so I can't give you a code or anything, but there should be a way to have the
holder._x = player._x
While still moving the ground how far you wanted...
I just added the ground holder once I found this code- I really still have no idea why I couldn't get atomoxic's thing to work :/
Anyway, the level just fly's away when I just change the _root._xmouse and _root._ymouse to _root.player
and what makes it even more annoying is that the values are basically exactly the same
xmouse: 225.9
player x: 574.45
follow x: 574.45
I'm sure this is getting really annoying for everyone so here's the fla if it helps:
downloady (cs4 and cs3 versions)