PDA

View Full Version : The Game I Made


Pigbuster
31 Mar 2006, 19:01
I have a very bad track record of starting flash things and never finishing them. I really hope that I can make this into something big, though.
After playing Doukutsu Monogatari, (Normally I choose the American name over it's native one... but I think that title just sounds cool) I was inspired to make a similar engine in flash. Here's the rough little playroom type area.
http://img81.imageshack.us/my.php?image=gameimade2yy.swf
Left+right = move
Up = jump

This is the first engine I ever made that actually works well. I'm still working on getting scrolling right, but I think that just moving around giant jpegs works better than the tile-based thing I tried before.
I'm aware of the problem of jumping diagonally into a wall corner, but I think I might have a way to fix that. Heck, I might not even have to. Smashing your head into a corner SHOULD make you stop. And this is going to look much better when I use actual sprites.
How long this would take me to get it good, I don't know. I haven't worked on this in months, but I hope I can start up again soon and figure out how to make Doukutsu-style scrolling in actionscript.

worMatty
31 Mar 2006, 20:41
That's rate cool innit lolz!

Has quite a retro feel to it. 'cept the blocks. Nice smooth action.

MtlAngelus
31 Mar 2006, 21:36
I fell off the edge and died :p

Pickleworm
31 Mar 2006, 22:05
I fell off the edge and died :p

Really? I died of an extreme, sudden explosive heartattack.

Splapp
31 Mar 2006, 23:08
Wow, that's pretty damn good! Get this one finished, BOY

Pigbuster
1 Apr 2006, 01:23
I fell off the edge and died :p
There actually isn't an edge, the screen just doesn't show the rest of the level.
Well, actually there is a ledge. But you can't see it.
And mad props to Pickle, there.

SupSuper
1 Apr 2006, 01:28
Well, it's a nice... engine. Not much more I can say :p

Pigbuster
1 Apr 2006, 06:11
I have to make the engine before I make anything else. If I make the graphics more than big pixels, I'd get caught up in making the graphics and quit. If I can get the engine completely done, I'll be motivated to do everything else.
Scrolling is the next hurdle. I have it in a way, but it bobs back and forth wildly and makes me sick.

Xinos
1 Apr 2006, 11:22
using xmin,xmas,ymin & ymax is all fun and game untill someone looses and eye.

Zero72
1 Apr 2006, 12:14
That feels excellent. You're right, it definitely brings Cave Story to mind.

Pigbuster
2 Apr 2006, 04:38
using xmin,xmas,ymin & ymax is all fun and game untill someone looses and eye.
Err... yes.

Xinos
2 Apr 2006, 12:05
Err... yes.

Let me explain. Thoose functions work for simpler things, but if you want the player object to have any other shape than a box you will need some physics ;)

SupSuper
2 Apr 2006, 15:21
Usually to create smoother scrolling, you have another object follow the player, and scroll around that.

AndrewTaylor
2 Apr 2006, 23:44
Let me explain. Thoose functions work for simpler things, but if you want the player object to have any other shape than a box you will need some physics ;)
That doesn't explain why you're bad-mouthing Christmas.


And I think they're probably alright, surely? You don't want a player-shaped collision mask against the platforms, do you?

Pigbuster
3 Apr 2006, 05:18
Most 2D game characters could be simplified into squares. Right now I have the collision detection between the ground areas and the dots around the character. This is based on the Doukutsu engine, and Quote is a square.
Well, actually he slips and falls when his feet leave the platform, but the character I'm thinking of is more of a rectangle than a triangle.

Pigbuster
23 Jul 2006, 20:01
After a rather long hiatus, I've started work on this thing again.
This is the scrolling as I have it now.
http://img59.imageshack.us/img59/9493/gameimade2ed5.swf

I have a lot of problems with it. The player can get too far over to one side, for one thing. I can't figure out how to get it to work better. (And I'm aware that the scrolling messes the collision up.)

Here's the script as I have it now. Shouldn't the CODE tag allow spaces before the words?
onClipEvent (enterFrame) {
if (_parent.main.user.facer == true) {
_global.cxcent = _global.lxcent;
} else {
_global.cxcent = _global.rxcent;
}
//Scrolling the X axis
if ((_parent.main.user._x+_parent.main._x)<_global.cxcent) {
_global.userleft = true;
_global.userright = false;
if (_parent.main.xspeed<6 & _parent.main.user.facer == false) {
_parent.main.xspeed = (_parent.main.xspeed+.1*1.5);
//Math.pow(x, y)
//_parent.main.xspeed = Math.pow(.002, (_parent.main.xspeed+1));
}
} else if ((_parent.main.user._x+_parent.main._x)>_global.cxcent) {
_global.userleft = false;
_global.userright = true;
if (_parent.main.xspeed>-6 & _parent.main.user.facer == true) {
_parent.main.xspeed = (_parent.main.xspeed-.1*1.5);
//_parent.main.xspeed = Math.pow(-.002, (_parent.main.xspeed-1));
}
}
if (_parent.main.xspeed != 0) {
if (_parent.main.xspeed>0) {
_parent.main._x += _parent.main.xspeed;
if (_global.userleft == false) {
_parent.main.xspeed *= .85;
}
}
if (_parent.main.xspeed<0) {
_parent.main._x += _parent.main.xspeed;
if (_global.userright == false) {
_parent.main.xspeed *= .85;
}
}
}
}

Xinos
23 Jul 2006, 20:25
Why doesn't the game restart when you fall out of the level? And what's with all the text?

And the movement & collisions are very good.

MtlAngelus
23 Jul 2006, 21:16
Xinos: The collisions are buggy, I kept getting stuck in the walls :p
Porkbuster: Awesome stuff, even if a bit buggy :p

Blinx
23 Jul 2006, 21:36
Hmm...

Seems like some strange acid trip, involving cubes.

I like it. :D

Zero72
23 Jul 2006, 22:00
Once again, great job of bringing the feel of Cave Story to mind, although it feels a bit swimmier somehow. Can't quite put my finger on it.Why doesn't the game restart when you fall out of the level? And what's with all the text?Yeah, and where the hell are the bonus levels? And Andross?!

Pigbuster
24 Jul 2006, 04:16
Why doesn't the game restart when you fall out of the level? And what's with all the text?

And the movement & collisions are very good.
You actually can't fall off the level, it just doesn't scroll down yet. I want left and right to work first.
The text shows variables. The one above the player shows if they're facing right or not. The other one shows the stage's xspeed, and there are a bunch of other things that I'll get rid of when I can.
Seems like some strange acid trip, involving cubes.
Wait until I make the background move. Then it looks really nutty.
Andross?!
Oh, he's there, all right.

And here are some variables.
facer=Is the user facing right?
cxcent=The current X center. Changes depending on which direction they're looking.
lxcent=The left X center. When the user is facing right, the bullseye thing on the left becomes the point the camera has as the center.
userleft=is the user to the left of the bullseye?
userright=is the user to the right of the bullseye?

Xinos
24 Jul 2006, 11:19
Why doesn't the game restart when you fall out of the level? And what's with all the text?

And the movement & collisions are very good.
You actually can't fall off the level, it just doesn't scroll down yet. I want left and right to work first.
The text shows variables. The one above the player shows if they're facing right or not. The other one shows the stage's xspeed, and there are a bunch of other things that I'll get rid of when I can.

Yeah, but it's distracting. There is such a thing called trace() :p

SupSuper
24 Jul 2006, 14:11
Yeah, but it's distracting. There is such a thing called trace() :pThat's even more distracting since the Debug Window would keep changing every frame and you'd quickly lose track of which variable is which.

Error404
25 Jul 2006, 05:25
First: nice job... it looks really cool

Second: it got massively lagged when you introduced the scrolling :p

Xinos
25 Jul 2006, 14:19
That's even more distracting since the Debug Window would keep changing every frame and you'd quickly lose track of which variable is which.

Just put the game in 1 frame ;)

And then you can write the trace like:

trace("Player direction = " +playeDir);
trace("Movement speed = " +playerSpeed);
trace("Jump = "+playerIsJumping);

It's gotta be my way
My way is alwase better :cool:
j/k

Pigbuster
10 Aug 2006, 00:05
HAPPY UPDATESSSSSS.
I revamped the scrolling twice since last time. First try didn't work, but second try worked quite well.
Tell me what you don't like about the scrolling speed-wise. (Going too fast when you turn around, etc.) chances are I could change it.
Also note that I really recommend that you save this to your computer. It runs pretty slow on mine.
And it's currently doing an enterFrame that it doesn't have to do. It might speed up a bit if I do that.

http://img65.imageshack.us/img65/1927/pixeliciousbackupaugust9pv9.swf

Star Worms
10 Aug 2006, 00:16
I think the scrolling is still too quick:-/

Pigbuster
10 Aug 2006, 00:19
What's nice is that I can fix that somewhat easily now.
And I just got an idea to fix that that I probably should've thought of before I put this on the internet. :p

SupSuper
10 Aug 2006, 00:26
Yeah, it's still rather odd. All you have to do is tap the key in the opposite direction for it to scroll a whole damn lot.

Pigbuster
10 Aug 2006, 00:42
In my defense, that's sorta the way it works in the GBA port of Cave Story that I based it on.
http://community.livejournal.com/doukutsu/27249.html

SupSuper
10 Aug 2006, 00:48
Well it wouldn't be so bothersome if it instantly changed direction, instead of slowing down and reversing like an actual moving object.

Pigbuster
10 Aug 2006, 01:05
I could make it scroll only when the character moves in a direction.
That way, when you stop, the camera would too.

AndrewTaylor
10 Aug 2006, 10:18
Personally, I like the Worms Armageddon scrolling method, which I shamelessly stole for Gravity.

New camera position = Old camera poition * X + Character position * (1 - X)

They decreased X in the relpays as well, that was a stroke of genius.

SupSuper
10 Aug 2006, 15:35
Gravity has scrolling?

Pigbuster
10 Aug 2006, 16:47
Personally, I like the Worms Armageddon scrolling method, which I shamelessly stole for Gravity.

New camera position = Old camera poition * X + Character position * (1 - X)

They decreased X in the relpays as well, that was a stroke of genius.
onClipEvent (enterFrame) {
_parent.main._x = ((_parent.main._x*_parent.main._x)+((_parent.main. user._x)+(_parent.main._x)*(_parent.main._x-1)));
}
That code makes the game leap to 107374582 and stay there. Moving back and forth makes it increase and decrease normally, so it looks like it would work if only it didn't jump up there for some reason.
Using X as a number does the same thing.
Is the X in that code something else?

SupSuper
10 Aug 2006, 18:01
X is probably some number that controls the camera's speed. And I can't really see what's wrong, maybe you used a value too big for X?

AndrewTaylor
10 Aug 2006, 19:06
onClipEvent (enterFrame) {
_parent.main._x = ((_parent.main._x*_parent.main._x)+((_parent.main. user._x)+(_parent.main._x)*(_parent.main._x-1)));
}
That code makes the game leap to 107374582 and stay there. Moving back and forth makes it increase and decrease normally, so it looks like it would work if only it didn't jump up there for some reason.
Using X as a number does the same thing.
Is the X in that code something else?
Yes. X is a number between 0 and 1 (exclusive). 0.1 works pretty well, but it depends on your framerate (and how fast you want the camera to move). Use this:

onClipEvent (enterFrame) {
_parent.main._x = (_parent.main._x*0.2)+(_parent.main.user._x*0.8);
_parent.main._y = (_parent.main._y*0.2)+(_parent.main.user._y*0.8);
}

Change the numbers to taste, but they should always add up to one. Otherwise strange things will happen.
Gravity has scrolling?
The latest version does, yes. The game arena's the same size it always was, but you can track the camera about during shots now.

Pigbuster
11 Aug 2006, 19:52
Okay, here's the code I use now.

onClipEvent (enterFrame) {
_parent.main._x = (_parent.main._x*0.1)-((_parent.main.user._x-280)*0.9);
}

The "-280" is because the user is within the main clip that's being scrolled, and I have to tell it that the center is in the middle of the screen- not the very left side.

That worked pretty well. It makes me feel like a fool for working so hard on other really complex techniques when you come along with 3 lines of code that does it all. (And Y-scrolling, too.) Thanks a DILLION.
I want the player to look a little bit ahead in the direction they're facing, so I'll work on that now.

}EDIT{

Woo! Got it.
The Y square in the top left stops the y-scrolling. (As you can get stuck in the floor pretty easily.)
http://img82.imageshack.us/img82/2346/pixeliciousfinalyc1.swf

onClipEvent (enterFrame) {
if (_parent.main.user.facer == true && _root.xcenter>=210) {
_root.xcenter -= 2.5;
} else if (_parent.main.user.facer == false && _root.xcenter<=350) {
_root.xcenter += 2.5;
}
_parent.main._x = (_parent.main._x*0.1)-((_parent.main.user._x-_root.xcenter)*0.9);
if (_root.yscroll == true) {
_parent.main._y = (_parent.main._y*0.1)-((_parent.main.user._y-200)*0.9);
}
}

}EDIT #2{

Well, I worked on it a bunch. Now it has background scrolling, it stops at the edge of the screen, it goes back and forth smoothly, and it really works just like I want it to. YES!
I cleaned up the code, so it should run faster now. Next stop is fixing up the collision!

http://img160.imageshack.us/img160/2922/pixeliciousbackupaugust11gw1.swf

Final Code:


if (_parent.user.facer == true && _root.xcenter>=210) {
_root.xcenter -= 2.5;
} else if (_parent.user.facer == false && _root.xcenter<=350) {
_root.xcenter += 2.5;
}
if ((_parent._parent.main._x<_root.lxlimit && (_parent.user._x+_parent._parent.main._x)<_root.xcenter) || (_parent._parent.main._x>_root.rxlimit && (_parent.user._x+_parent._parent.main._x)>_root.xcenter)) {
_parent._parent.main._x = _parent._parent.main._x*0.8-(_parent.user._x-_root.xcenter)*0.2;
_parent._parent.bg1._x = _parent._parent.main._x*.1
}
if (_root.yscroll == true) {
if ((_parent._parent.main._y>_root.dylimit && (_parent.user._y+_parent._parent.main._y)>_root.ycenter) || (_parent._parent.main._y<_root.uylimit && (_parent.user._y+_parent._parent.main._y)<_root.ycenter)) {
_parent._parent.main._y = _parent._parent.main._y*0.9-(_parent.user._y-_root.ycenter)*0.1;
_parent._parent.bg1._y = _parent._parent.main._y*.1
}
}

FutureWorm
11 Aug 2006, 20:32
Am I supposed to stick to walls?

MtlAngelus
11 Aug 2006, 20:55
Yes, you're suposed to be spiderman!

Pigbuster
11 Aug 2006, 20:56
Am I supposed to stick to walls?
No .
Next stop is fixing up the collision!

SupSuper
12 Aug 2006, 19:52
Not to mention sticking to some of the floors. :p

But yes, I really like the scrolling now. :)

Vader
12 Aug 2006, 20:53
The scrolling is awesome.

The sticking is infuriating.

Pigbuster
14 Aug 2006, 06:27
Okay guys, improvement on the scrolling. I just have to post something.
I now have an affection for 'while' loops. They made me remove well over 300, maybe 400 lines of code from my old scrolling engine because of the long 'if' chains I used to use.
Right now there's no scrolling, and the only collision points are in the middle top, middle left, middle right, and middle bottom. (No corners.) It's like a big + running around.
But I'll get that done next, as well as try to figure out how to fit scrolling into this.
Hopefully by my next update this engine will be done, and THEN we'll be cooking.

http://img214.imageshack.us/img214/5742/pixeliciousmegafinalcl2.swf

MtlAngelus
14 Aug 2006, 08:02
Is this suposed to happen?(the square is stuck there, altough I can still move and set free)

Zero72
14 Aug 2006, 10:25
I figured that's probably because there are no collision points on the corners.

SupSuper
14 Aug 2006, 16:57
This better not become one of those "jump exactly right or you're dead" games.

Vader
14 Aug 2006, 21:41
I don't mind those sort of games - as long as the levels are short enough to balance the level of challenge then they can be fun.

Lex
14 Aug 2006, 21:45
The best platform game ever is Cave Story, in my opinion!

(Note: This only includes games I've played, though I have played tons and loads and bajillions of platform games. If you know one that's better, do tell.)

Pigbuster
14 Aug 2006, 22:02
It's going to be a cave story type. i.e, an emphasis on shooting things instead of jumping across pits. (Though there were some in that game.)
The best platform game ever is Cave Story, in my opinion!
I agree.

I'm very close, now. I just need to find a way to calculate an xspeed from the scrolling so I can subtract it from the collision.

Lex
14 Aug 2006, 22:22
Also, have you played Within A Deep Forest?

FutureWorm
14 Aug 2006, 22:23
The best platform game ever is Cave Story, in my opinion!

(Note: This only includes games I've played, though I have played tons and loads and bajillions of platform games. If you know one that's better, do tell.)
Have you played Super Metroid?

Lex
15 Aug 2006, 06:33
Yes. I don't like it nearly as much as Cave Story.

Vader
15 Aug 2006, 22:32
The best platform game ever is Cave Story, in my opinion!

Mega Man X is the best ever platformer, ever. It gets everything right. Everything.

SupSuper
16 Aug 2006, 00:17
The best PC platformer ever is Jazz Jackrabbit 2.

Lex
16 Aug 2006, 01:32
Mega Man X is the best ever platformer, ever. It gets everything right. Everything.Ooh! I haven't played that! I'll keep that in mind.The best PC platformer ever is Jazz Jackrabbit 2.I found Jazz Jackrabbit and Jazz Jackrabbit 2 good, but its storyline doesn't approach the emotional power of Cave Story's.

Vader
16 Aug 2006, 03:10
Ooh! I haven't played that! I'll keep that in mind.

It's on the SNES - it's a real gem. I've not played X2 onwards for fear of them diluting any one aspect of X and jading my view. I'm sure they're good but Mega Man X will always be my number one game, ever.

Pigbuster
16 Aug 2006, 05:02
Okay, I've got something.
It still isn't perfect, but I really don't know how to make it better. I think I need help, if not here, then at the flashkit forums.
Don't step on the light blue blocks. They aren't modified for the rectangular character.
http://img207.imageshack.us/img207/8161/pixelicioussuperdooperfinalfk1.swf

i also uploaded all of my code, in case anyone want's to look at it.

MtlAngelus
16 Aug 2006, 07:22
:O
I stepped on the light blue blocks and nothing happened... :(

Macobsession
16 Aug 2006, 08:22
Looks good so far.
I have plenty of ideas for games myself just absolutly no time to actually work on them.

SupSuper
16 Aug 2006, 15:48
I have plenty of ideas for games but no actual skill to put them together.


Anyways, now that the player isn't a perfect square anymore, there are some spots in which you can get permanently stuck.

Also, what's this?

Pigbuster
16 Aug 2006, 17:29
I was seeing what collision the planned character model would have. Can't see the parts that aren't on the red too well.
I thought he would be .5 - 1.5 blocks tall. That looked okay, but I thought that I'd make it a little wider.

Pigbuster
21 Aug 2006, 06:35
Well, I'm still going at it.
I revamped the scrolling again. It uses the same core equation, but now it's moving just one movie clip around, and whatever this movie clip covers, it rearranges the movies dimensions to it (The guy who makes the Brackenwood movies uses it).
Also, the collision works a little better, but it's still buggy. I really can't think of a way to fix it. I'll sign up at flashkit tomorrow, methinks.
And the stage is now a lot smaller, has larger pixels, and is green. I think I might stick to this size.

http://img207.imageshack.us/img207/921/pixeliciousbackupdrasticpz2.swf

Okay, I actually want you to post anything wrong you find. I know there's probably a lot, but I would love it if I could pinpoint what the exact problems are, especially if someone finds something bad that I don't know about.
Damn, art based engines are hard. I can't imagine everything else will take this long. (I have ideas for AI. I think that sin cos & tan will be my bestest buddies when I come to that.)

Zero72
21 Aug 2006, 06:47
I'm finding that collision detection with walls is still pretty sticky.

ie, try moving at a wall and jumping at it at an angle.

Pigbuster
21 Aug 2006, 06:53
The collision tests the outer four corners of the user, but the problem is that I can't make them perfectly on the corners. If I did, then the user could leap into a wall to the left and the game would say that they're on the ground, as the lower-left corner is also touching the wall.
The way I have it, there has to be a gap on the very corners of the guy, so corners don't work too well.

If the points were on the exact corners, the user could stick to walls, and they couldn't walk left or right.

This probably doesn't make too much sense, yeah...
Though I just remembered something that could help.
I'd bet money that it doesn't fix everything, though.
[EDIT]
I tried, and it didn't.

All of my problems would probably be solved if I knew of a way to tell the program which parts are walls and which parts are floors. I really can't think of a good way to do that, though.

bloopy
21 Aug 2006, 08:59
All of my problems would probably be solved if I knew of a way to tell the program which parts are walls and which parts are floors. I really can't think of a good way to do that, though.

Perhaps if your walls and floors are all movie clips, you could give them all a variable and set it to a different value depending on what part they are.

MtlAngelus
21 Aug 2006, 09:06
It crashed my opera :p

Plutonic
21 Aug 2006, 13:05
could you make floors and walls slightly different colours? then check the colour on collision. Or even have a version of the level that is not rendered. I dont know how the level is stored, so not sure if it can be done in flash but it works in other things. Once you have a second version you could use it to draw two types of stuff, floors and walls and use that as the collision mask and the main layer purely for cosmetics.

Pigbuster
21 Aug 2006, 16:48
Well, I know what to do in the case of making them separate walls and floors (Two movie clips with two instance names) but I don't know how I'd deal with corners.
I thought I'd make them a diagonal like this, but that might not work.

http://img211.imageshack.us/img211/1408/diagonalcollisionoo1.jpg

If you jump in which only the top-left corner will hit the wall, you might end up going through.
But maybe there's a way to do that right. I'll experiment with stuff.

[EDIT]

Plutonic, could you tell me how I could check the color on collision?
That would be a lot easier than having separate movie clips for walls, floors and ceilings.

Plutonic
21 Aug 2006, 17:16
well I don't know flash, so hard to say. Do you know how the level is currently stored? How do you write the data to it as well? I would have thought getting the colour data would be similar to setting the colour data in the first place.

edit:
I would have thought splitting walls and floors by colour would look something like this:

Pigbuster
21 Aug 2006, 17:24
The limit movieclip is inside the main movieclip, which is inside the main flash. (_root.)

And the color data is just drawn there. I didn't draw anything through scripting. I do know what the hexadecimal values are, but I'm not too sure how to check if the user is hitting that part of the limit.

I just seperated everything into different movieclips to try it out.
But now you can leap along the diagonal and move right through everything. :(

http://img64.imageshack.us/img64/3847/pixelicious21li3.swf

Plutonic
21 Aug 2006, 18:24
hmmmmm, not realy sure then, must be possible to get colour data some how though.

Zero72
28 Aug 2006, 10:06
That seems to be working great to me.

Pigbuster
29 Aug 2006, 06:11
I'm actually working this over AGAIN.
I've been busy recently, but I'll try to keep working on it.

Pigbuster
31 Aug 2006, 06:49
I now present this wonderful interactive diversion that goes by the name of
MAKE A NAME: THE GAME.
http://img208.imageshack.us/img208/6503/makeanamethegamelc3.swf

You give the smiley a name.
It tells you stuff about them.

If you have ideas for stuff then you can SUGGEST. This is a work in progress the whole family can enjoy.

Lex
31 Aug 2006, 11:26
That looks a lot like Googlism (http://www.googlism.com/index.htm?ism=Jack&type=1).

Apparently, you are a Toronto-based sculptor who works with clay, among many other silly things. ;D

MtlAngelus
31 Aug 2006, 18:55
http://www.googlism.com/index.htm?ism=MtlAngelus&type=1
HA!:p

FutureWorm
31 Aug 2006, 20:19
http://content.imagesocket.com/images/Harvey357.png (http://imagesocket.com/view/Harvey357.png)

This is very true.

MrBunsy
31 Aug 2006, 21:50
Bobby McBob lost their right leg in the great war.

Ha!

CyberShadow
1 Sep 2006, 00:59
I now present this wonderful interactive diversion that goes by the name of
MAKE A NAME: THE GAME.


Awesome man. I looked through the source and spoiled myself a bit though.

http://img171.imageshack.us/img171/4797/00000183sbm1.png
Close enough. I prefer high elves though :D

Hint: make it case, punctuation and whitespace-insensitive. Just lowercase everything and remove all symbols that aren't letters before checking. That should significantly raise the chance of matching those special cases.

To the public: there are 38 special cases with unique responses. Can you find them all? ;)

Pigbuster
1 Sep 2006, 05:40
Ooh you tricky devil.
Yes. Some special secret names, YES.
Hint: make it case, punctuation and whitespace-insensitive. Just lowercase everything and remove all symbols that aren't letters before checking. That should significantly raise the chance of matching those special cases.
I did want to do this, but I'm not too sure how to make flash disregard case, or how to remove symbols and spaces.

Ha!

CyberShadow
1 Sep 2006, 06:39
Flash script (ActionScript) = JavaScript (AKA ECMAScript) + Flash's extensions

thus, all JavaScript syntax also applies to ActionScript.

I find this page (http://javascript-reference.info/) quite useful for quick reference. Those guys also sell laminated versions of those cards and a lot of other stuff for web designers.

To answer your question, to get the lowercased contents of variable s, do s.toLowerCase().

Your script should be something like this:


on (release) {
var s = _root.name.toLowerCase();
var stripped = "";
for(i=0;i<s.length;i++)
if(s.charCodeAt(i)>=97 && s.charCodeAt(i)<=122) // between "a" and "z"
stripped = stripped + s.charAt(i);

if (stripped == "cybershadow") {
...
}
else if ...........
}

Pigbuster
2 Sep 2006, 06:08
I suppose that it would be worth mentioning...
What exactly does 'var' do?
How is it better than just declaring the variable on its own?

CyberShadow
2 Sep 2006, 13:23
Readability :)

Pigbuster
3 Sep 2006, 23:40
Ugh...
I'm just tired of this not working.

If I was able to get past this damn collision phase, I think I could handle everything else. I have ideas for that stuff.
But I've ran out of ideas for collision. No matter what I do, it never ends up right, and It just ****es me off.

http://img205.imageshack.us/img205/9727/pixeliciousbackupseptember3hq3.swf
And code is attached.
I can't do this myself anymore. I need to have help.

Plutonic
4 Sep 2006, 02:23
whats with all the slashes? is that some flash thing or my PC being weird on me?

Pigbuster
4 Sep 2006, 02:34
They make fun little boxes in the actionscript window.
With that format, though, they don't look like that.

I am assuming that I know what you're talking about.

Pigbuster
9 Oct 2006, 06:27
HELLO.

I made another game now.

Get Rid of Randall 2: THE RANDALLING (http://www.deviantart.com/deviation/41105557/).

It started as a simple "Hey, this ball can follow the cursor!"
But now, it's oh, so much more.

The presentation has to be better than everything else, I must say. I think that that's the way it'll always end up with my stuff.

bloopy
9 Oct 2006, 07:38
Very nice! I like the randomness of the enemies. That fat purple dude was hiding my score though. :p

SupSuper
9 Oct 2006, 10:56
Weird. It gets easy after a while, though like Bloopy says, the enemies cover up the score. And you should make the score in the final screen selectable.

Also, 5796.

philby4000
9 Oct 2006, 20:25
Greatest name ever.

Although I suck and only got a score of around 4000.

Pigbuster
6 Apr 2007, 00:48
GHRHGHRHGHHGHG. GH.

It figures. Spend a whole lot of time thinking of the math & trigonometry to make a Star Control-type engine, and it just goes WIGGY on you.
I had so many AHA moments, but then, when I put it into AS, Flash just says "I'M GOING TO BE A P!SSANT BWEEEEEREREEERERERE!"
http://img87.imageshack.us/my.php?image=gror3hm9.swf
Left+Right=Turn
Up=Thrust, or if not pointing straight up, spaz out.
I'm tired of this not working (I've been at it for a while, now.)
I'm going to have to give up on this one unless someone tells me what's wrong with this code.

Frame 1

RD.angd = 0;
RD.turn = 0;
RD.xs = 1;
RD.ys = 1;
RD.vel = 10;


Frame 2

stop();
onEnterFrame = function () {
RD.angr = RD.angd * Math.PI / 180;
RD.xs = Math.sin(180 / Math.PI * Math.atan(RD.xs + Math.sin(RD.angr) * RD.vel, RD.ys + Math.cos(RD.angr) * RD.vel)) * RD.vel;
RD.ys = Math.cos(180 / Math.PI * Math.atan(RD.xs + Math.sin(RD.angr) * RD.vel, RD.ys + Math.cos(RD.angr) * RD.vel)) * RD.vel;
RD._x += RD.xs;
RD._y -= RD.ys;
RD._rotation = RD.angd;
if (Key.isDown(39)) {
RD.angd += 2.5;
} else if (Key.isDown(37)) {
RD.angd -= 2.5;
}
if (Key.isDown(38)) {
RD.vel = 10;
} else {
RD.vel = 0;
}
if (RD._x >= 750.1) {
RD._x = 0;
} else if (RD._x <= -.1) {
RD._x = 750;
}
if (RD._y >= 750.1) {
RD._y = 0;
} else if (RD._y <= -.1) {
RD._y = 750;
}
};

Macobsession
6 Apr 2007, 01:22
Part of your problem may be that the Math.sin(), Math.cos(), etc.. methods i believe requires radians not degrees.
Your conversion of angd to angr is correct. However your next line i believe is wrong. Because you're adding all that stuff up and then converting it back to degrees and putting it in Math.sin(). Thus that Math.sin that encompases all of that is getting degrees instead of radians.

RD.angr = RD.angd * Math.PI / 180; //angr is now in radians
RD.xs = Math.sin(180 / Math.PI<-----wrong!!! * Math.atan(RD.xs + Math.sin(RD.angr) * RD.vel, RD.ys + Math.cos(RD.angr) * RD.vel)) * RD.vel;
RD.ys = Math.cos(180 / Math.PI<-----wrong!!! * Math.atan(RD.xs + Math.sin(RD.angr) * RD.vel, RD.ys + Math.cos(RD.angr) * RD.vel)) * RD.vel;


I had the same problem with my OpenGL project last semester. Get rid of that 180/PI and it should work better. To be honest its probably better to keep it all in radians and just figure out a small radian number to increment the turning angle by.
degrees=radians*180/PI
radians=degrees*PI/180

hope that helps.

Pigbuster
6 Apr 2007, 02:05
Getting rid of the 180 / Math.Pi keeps it from going all jerky, but it's still screwy.
http://img206.imageshack.us/my.php?image=gror3er1.swf

(Getting rid of the angr/angd conversion altogether didn't work, either.)

Macobsession
6 Apr 2007, 02:23
Well is better. I think your formulas are wrong. These should work better(just replace it with your variables)
x+=velocity*sin(heading angle)
y+=velocity*cos(heading angle)

Pigbuster
6 Apr 2007, 03:03
That can make a good engine for driving a car around.
http://img213.imageshack.us/my.php?image=gror3jl8.swf

Thing is, I want a game which will have the player continue at a constant velocity, and it will allow them to turn without changing direction until they press up, when it will change their velocity to the direction the player is pointing.
Like Star Control or Asteroids.

Macobsession
6 Apr 2007, 03:40
well then just make a conditional statment like this.

headingangle=0//where you're going
facingangle=0//where you're facing

if(up is pressed)//shift heading to facing
headingangle=facing angle//changed heading to facing
//otherwise heading is not modified

if(left pressed)
facingangle+=X
if(right pressed)
facingangle-=X
then rotate image by facing angle.

//if heading angle is constant it wont turn until you press up and change the constant heading
x+=velocity*sin(heading angle)
y+=velocity*cos(heading angle)

MtlAngelus
6 Apr 2007, 03:59
http://img87.imageshack.us/my.php?image=gror3hm9.swf

LOLOLOLOL wiggy face ftw!
You know you should use this one and make one of those "don't touch the lines" maze kind of thing. That'd be fun. :P

Pigbuster
6 Apr 2007, 04:39
well then just make a conditional statment like this.

headingangle=0//where you're going
facingangle=0//where you're facing

if(up is pressed)//shift heading to facing
headingangle=facing angle//changed heading to facing
//otherwise heading is not modified

if(left pressed)
facingangle+=X
if(right pressed)
facingangle-=X
then rotate image by facing angle.

//if heading angle is constant it wont turn until you press up and change the constant heading
x+=velocity*sin(heading angle)
y+=velocity*cos(heading angle)

http://img204.imageshack.us/my.php?image=gror3uw9.swf
Still not what I want.

I want it to change direction gradually.
For instance, if the player is heading straight east and they're pointing north, then when the ship is thrusted, I want it's angle to gradually change from 90 to 0 (So they're heading straight north).
Also, if the ship is pointing west and heading east, then if they thrust, I want it to gradually come to a stop, then reverse direction, so the ship would go west.

And I'm not sure how to do that easily.

Macobsession
6 Apr 2007, 05:28
k..then this may be what you want....
headingangle=0//where you're going, I'm assuming they're in radians
facingangle=0//where you're facing, I'm assuming they're in radians
X=small increment
velocity=0


if(left pressed)
facingangle+=X
if(right pressed)
facingangle-=X

//this bounds angle to 0 to +2PI aka 0 to +360
//just makes things easier for whats next
if(facing angle>2PI)
facing angle-=2PI
if(facing angle<0)
facing angle+=2PI
if(headingangle>2PI)
headingangle-=2PI
if(headingangle<0)
headingangle+=2PI

then rotate image by facing angle.

if(up is pressed)
if(heading==facing){//same direction then just speed up
if(velocity=<10)
velocity+=1
else
//do nothing, keep constant speed
}

elseif(heading-PI==facing or heading+PI==facing){//opposite direction
if(velocity=<0)
heading=facing //then heading becomes same as facing
else
velocity-=1//otherwise keep slowing slow down
}
else{//otherwise we're turning the object slowly
//velocity is not modified

if(heading<facing)//if heading is smaller than facing
heading+=X
else//if heading is larger than facing
heading-=X

}
x+=velocity*sin(heading angle)
y+=velocity*cos(heading angle)

Pigbuster
6 Apr 2007, 07:45
Hmm...

I really do think that doing this requires trigonometry and vectors and resultants and all that stuff...
I want to avoid code that gives specific instructions based on what angle it is. I want code that can do the right thing for any angle...

You've been helping and I appreciate that, but I really need to make a more physics-based engine.

[EDIT]
Ah! I think I just got it.
I have to go to bed now, but I'll work on it in the morning.
Don't help me again unless I find out if I'm wrong, please.

Macobsession
6 Apr 2007, 09:37
alright well good luck with that. I'm just trying to give you ideas.

SupSuper
7 Apr 2007, 00:02
You mean a standard spaceship movement like this (http://supsuper.10e.net/FOTE.html)? Just basic trignometry and physics, really. Let me know if you still have trouble.

Pigbuster
7 Apr 2007, 05:06
Well, I've gotten it to the closest it's been yet.
http://img172.imageshack.us/img172/963/gror3zm1.swf

But the problem is that the engine seems to always go toward 45-degree angles.
I could probably solve that eventually, but you obviously know just what I want, Supsuper, so if you can... please?

SupSuper
7 Apr 2007, 12:59
Ah yes, your problem is with this bit:

if (RD.velx > RD.velmax) {
RD.velx = RD.velmax;
} else if (RD.velx < -RD.velmax) {
RD.velx = -RD.velmax;
}
if (RD.vely > RD.velmax) {
RD.vely = RD.velmax;
} else if (RD.vely < -RD.velmax) {
RD.vely = -RD.velmax;
}

See, when one of the axis (X or Y) reaches the maximum and stops, the other one still keeps on going until it reaches the max and stops, thus always leading to the 45 degree angle. So, get rid of that bit.

What I use is a counter-velocity, a drag, which will always be in the opposite direction of the velocity and thus stop it from going too far. I dunno how to explain this properly so I apologize if it doesn't make sense, but it works. :p

So, where you have this:

//Determine new X&Y velocities.
RD.velxmod = Math.sin(RD.angr) * RD.frc;
RD.velymod = Math.cos(RD.angr) * RD.frc;

Put in this:

// Calculates the actual value of the velocity vector (module?)
RD.v = Math.sqrt(Math.pow(RD.velx, 2) + Math.pow(RD.vely, 2));

RD.drag = RD.velmax * RD.v;

//Determine new X&Y velocities.
RD.velxmod = ((RD.drag * RD.velx) * -1) + (Math.sin(RD.angr) * RD.frc);
RD.velymod = ((RD.drag * RD.vely) * -1) + (Math.cos(RD.angr) * RD.frc);
// The extra bit applies the drag to the velocity and makes it the opposite direction
// The bigger the velocity, the bigger the drag will be, eventually locking the velocity in its place


With my game, setting velmax to values between 0.01 and 0.001 works best, so experiment with it until it suits you.

Pigbuster
7 Apr 2007, 18:53
RD.velxmod = ((RD.drag * RD.velx) * -1 * RD.frc) + (Math.sin(RD.angr) * RD.frc);
RD.velymod = ((RD.drag * RD.vely) * -1 * RD.frc) + (Math.cos(RD.angr) * RD.frc);

I added that bit to your code, and then... it works! Woo!
Thank you, everyone who helped. :D

Pigbuster
10 Apr 2007, 00:40
http://img155.imageshack.us/img155/3112/gror3wh7.swf

GUESS WHICH GAME I'M SHAMELESSLY COPYING, GUYS!
Also, it's striking how much better the fps is when it's downloaded onto the computer.

SupSuper
10 Apr 2007, 11:20
Originality! :p

My only peeve is the turning. The thing can go around a whole 180º after I release the keys.

Pigbuster
23 Apr 2007, 03:24
Found a nice bit of code that can get the intersection point of 2 lines.
It's simple and shouldn't use too much power to run, quite the opposite of what ungodly equasion I was working out using angles and SOHCAHTOA and crepe. Total waste of paper and lead. Yay!

http://img204.imageshack.us/img204/5609/trigthingid6.swf

(Click on points to drag them. Try to rack up a lot of combo points. Collect eggs for powerups.)

This could quite easily be used to make a rather efficient platformer engine, seeing as I'm thinking of re-doing the one I had worked out earlier in this thread. THIS way will allow for physics, and everyone loves physics.
And it should be 10,000 times faster. No while loops or hittests here.

Funny how something much better looking would actually be more efficient than the complicated one.

FUNNY CODE LAUGHS.
onEnterFrame = function () {
m1 = (line1p1._y - line1p2._y)/(line1p1._x - line1p2._x);
m2 = (line2p1._y - line2p2._y)/(line2p1._x - line2p2._x);

x1 = line1p1._x;
y1 = line1p1._y;
x2 = line2p1._x;
y2 = line2p1._y;

x = ((-m2 * x2) + y2 + (m1 * x1) - y1)/(m1 - m2);
y = (m1 * (x - x1)) + y1;

rd._x = x;
rd._y = y;
//DRAW
removeMovieClip(line1);
removeMovieClip(line2);
createEmptyMovieClip("line1", -10);
line1.lineStyle(5, 0x007FBF, 100);
line1.moveTo(line1p1._x, line1p1._y);
line1.lineTo(line1p2._x, line1p2._y);
createEmptyMovieClip("line2", -11);
line2.lineStyle(5, 0xBF3F3F, 100);
line2.moveTo(line2p1._x, line2p1._y);
line2.lineTo(line2p2._x, line2p2._y);
};


Could anyone tell me how to test if the lines are actually intersecting? Right now this thing acts like they're intersecting even when they aren't (It's acting like the lines go on to infinity, rather than stopping at the points.

Nevermind. I knew the answer would be easy, and it is.
Just check to see if the intersecting point is between all of the points.

Pigbuster
25 Apr 2007, 03:16
GAGHG.

I am certain that this is the way to go, but I just cannot figure out how to do this dumb thing.

I'm trying to get it so the intercept dot turns green when intersecting, red when it isn't.

http://img403.imageshack.us/img403/2535/trigthinglu7.swf

If there is a slope of infinity (Give dots same _x values), then the dots can act weird. If the dots have a really high slope, it acts like it isn't intercepting (the intercept dot turns red, rather than green).

And I really hate that gigantic 'if' function. I just had no idea it would take that much code to figure out something as simple as "is the intersect point within the 2red+2blue dots?"

I just can't help but feel like there's a much easier and better way to do this.
I hate asking for help like this so many times, but this is a rather difficult concept to google an answer for.

onEnterFrame = function () {
x1 = line1p1._x;
y1 = line1p1._y;
x2 = line2p1._x;
y2 = line2p1._y;
m1 = (y1 - line1p2._y) / (x1 - line1p2._x);
m2 = (y2 - line2p2._y) / (x2 - line2p2._x);
x = ((-m2 * x2) + y2 + (m1 * x1) - y1) / (m1 - m2);
y = (m1 * (x - x1)) + y1;
rd._x = x;
rd._y = y;
//
if (((rd._x > Math.min(x1, line1p2._x) && rd._x < Math.max(x1, line1p2._x)) || (x1 == line1p2._x)) && ((rd._y > Math.min(y1, line1p2._y) && rd._y < Math.max(y1, line1p2._y)) || (y1 == line1p2._y)) && ((rd._x > Math.min(x2, line2p2._x) && rd._x < Math.max(x2, line2p2._x)) || (x2 == line2p2._x)) && ((rd._y > Math.min(y2, line2p2._y) && rd._y < Math.max(y2, line2p2._y)) || (y2 == line2p2._y))) {
rd.gotoAndStop(2);
} else {
rd.gotoAndStop(1);
}
//
//DRAW LINE//
//
removeMovieClip(line1);
removeMovieClip(line2);
createEmptyMovieClip("line1", -10);
line1.lineStyle(5, 0x007FBF, 100);
line1.moveTo(line1p1._x, line1p1._y);
line1.lineTo(line1p2._x, line1p2._y);
createEmptyMovieClip("line2", -11);
line2.lineStyle(5, 0xBF3F3F, 100);
line2.moveTo(line2p1._x, line2p1._y);
line2.lineTo(line2p2._x, line2p2._y);
};

SupSuper
25 Apr 2007, 03:57
I hate asking for help like this so many times, but this is a rather difficult concept to google an answer for.It is? Google churned out this instantly: http://www.swoon.com.au/2006/06/12/line-intersection-with-flash/

The code is similar to yours, though it has a hack to prevent the "infinite slope" issue.

Pigbuster
25 Apr 2007, 05:34
I was searching for the completely wrong thing, then.

// <HACK> Chuck in a little hack so that the line will never have an infinite slope, and will
// intersect with the Y-axis sometime. This would occur with a vertical line.
if(line.mc1._x == line.mc2._x) line.mc1._x += 0.1;
// </HACK>
I was honestly thinking of something like that, but I didn't try it for some reason.

Anyway... Woo. It works for real now.

I'm not uploading another version until I get something different going with this.

Pigbuster
27 May 2007, 06:55
I should be working on a movie about perpetual-motion-machines (And the lack thereof) for physics class, but instead I work on this old dinosaur a bit.

http://img213.imageshack.us/my.php?image=trigthingod4.swf

BLUE BALL+GREEN LINE=GREAT FUN

Revamped to actually use this technique as collision detection.
Next step- Bounce! Which should be pretty easy, really.

Pigbuster
7 Jun 2007, 01:04
WOO.

I have something that can be described as a "lame simple physics toy".
http://img221.imageshack.us/img221/5055/trigthingdw4.swf

The text boxes are input, so you can specify the respawn velocities[Err... harder to implement than I thought. IGNORE THIS MESSAGE], the line's friction (affects x velocity) and bounce (affects y velocity).
The green dots can be dragged, to change the collision line. The grey dot can be dragged to change the respawn point.

The bounce works by simply mirroring the angle of impact.

PROBLEMS: Many.
•The ball falls through the line after a bit. I'll fix it by adding code so the line can tell if it's a floor or a ceiling.
•Ceilings don't work. Wonder why.
•Friction/Bounce don't work that way. Friction wouldn't affect just the x velocity, but the y, too. I need to bring those into account for both axes. Don't know how yet, but I'll think of something.

CODE TIME FOR YALL.

user.xvel = 0;
user.yvel = 0;
user.ang = 0;
p1.frct = .9;
p1.bnce = .5;
s***x = 0;
s***y = 0;
onEnterFrame = function () {
if ((p1.bnce == "") || (p1.frct == "")) {
user._x = 123.5;
user._y = 700;
}
if (user.yvel < 10) {
user.yvel += .1;
}
user._x += user.xvel;
user._y += user.yvel;
if ((user._y > 600) || (user._y < -100) || (user._x < -500) || (user._x > 1000)) {
user._x = s***._x;
user._y = s***._y;
user.xvel = s***x;
user.yvel = -s***y;
}
rd._x = x;
rd._y = y;
/////////
user.vel = Math.sqrt(Math.pow(user.xvel, 2) + Math.pow(user.yvel, 2));
x1 = user._x + user.xvel;
y1 = user._y + user.yvel;
x2 = p1._x;
y2 = p1._y;
x2p2 = p2._x;
y2p2 = p2._y;
user.ang = Math.atan((user._x - x1) / (user._y - y1));
p1.ang = Math.atan((x2 - x2p2) / (y2p2 - y2));
thetad = user.ang / (Math.PI / 180);
m1 = (y1 - user._y) / (x1 - user._x);
m2 = (y2 - p2._y) / (x2 - p2._x);
if (x1 == user._x) {
user.xvel += 0.01;
}
if (x2 == p2._x) {
p1._x += 0.01;
}
x = ((-m2 * x2) + y2 + (m1 * x1) - y1) / (m1 - m2);
y = (m1 * (x - x1)) + y1;
rd._x = x;
rd._y = y;
//
intersect1 = false;
intersect2 = false;
if ((x > Math.min(x1, user._x) && x < Math.max(x1, user._x)) || (y < Math.min(y1, user._y) && y > Math.max(x1, user._y))) {
intersect1 = true;
}
if ((x > Math.min(x2, p2._x) && x < Math.max(x2, p2._x)) || (y < Math.min(y2, p2._y) && y > Math.max(x2, p2._y))) {
intersect2 = true;
rd.gotoAndStop(2);
} else {
rd.gotoAndStop(1);
}
if (intersect1 && intersect2 == true) {
//COLLISION, BOUNCE AND ANGLE REDIRECTION
user.ang = ((user.ang + p1.ang) * -1) - p1.ang;
user.xvel = Math.sin(user.ang) * user.vel * p1.frct;
user.yvel = Math.cos(user.ang) * user.vel * p1.bnce;
}
////////
////////
//DRAW
removeMovieClip(line3);
createEmptyMovieClip("line3", -29);
line3.lineStyle(5, 0x3FBF3F, 100);
line3.moveTo(p1._x, p1._y);
line3.lineTo(p2._x, p2._y);
};

MadEwokHerd
7 Jun 2007, 23:29
That's not a toy. It's a simulation.

Toys are things you play with, not enter numbers into.

Paul.Power
8 Jun 2007, 00:14
That's not a toy. It's a simulation.

Toys are things you play with, not enter numbers into.Some people play with things by entering numbers into them.

What does the small green dot do?

Pigbuster
8 Jun 2007, 05:45
It just shows where the intersection point is.

Paul.Power
8 Jun 2007, 10:36
And why does the small green dot like to shoot repeatedly off to the left when I tilt the thing to the right?

Pigbuster
8 Jun 2007, 17:11
It shows where the blue dot will collide with the line created by the 2 big green dots, if the blue dot continues to move in the exact same direction.

Since the blue dot's direction changes, the intersection point will change until it reaches the right area, where the blue dot will actually hit.

The thing is making 2 lines, one that starts where the user is and ends where the user will be in the next frame. One that starts on one green dot and ends on the other green dot.

If there is ever an intersection, the blue dot will collide and bounce off.

SupSuper
9 Jun 2007, 01:31
•The ball falls through the line after a bit. I'll fix it by adding code so the line can tell if it's a floor or a ceiling.This seems to be because the green circle (intersection point) always heads for the opposite side the ball is heading for until it loops back around to the new spot, which is too slow to update the collision point in time to tell the ball to bounce.

Pigbuster
9 Jun 2007, 03:46
Worked on it a bit in a platformer setting.
I'm having a problem with getting the points specified.

I have one point called "pt", and a second point called "ptt".
The code for "pt" has a "next" variable, which is meant to refer to "ptt". The reason I don't say that it is "ptt" outright is that I want this code to be applicable to "ptt" as well (it would look for the point "pttt").

Since "ptt" is the name of "pt", but with an added "t", I thought this code would work...
next = this._name + ["t"];
And it doesn't.
Even if I say
next = ptt
It still doesn't work.
It doesn't seem like flash can accept using a variable as a _name.

Is there actually a way I can have a code look for a certain point depending on what point the code is attached to?

SupSuper
9 Jun 2007, 04:31
Shouldn't it be?
next = this._name + "t";
And accessible with:
this[next]
?

Either that or you're not using the right hierarchy.

Pigbuster
9 Jun 2007, 06:20
That just returns a value of "undefined".

Here's the code I have on "pt".
onClipEvent (load) {
next = this._name + "t";
trace(this[next]);
}
onClipEvent (enterFrame) {
//
////
//////
//////// COLLISION ////////
//////
////
//
//user.vel = Math.sqrt(Math.pow(user.xvel, 2) + Math.pow(user.yvel, 2));
x21 = -(this._x - _parent.user._x);
y21 = -(this._y - _parent.user._y) + (_parent.user._height * .5);
x11 = x21 + _parent.user.xvel;
y11 = y21 - _parent.user.yvel;
x12 = 0;
y12 = 0;
x22 = -(this._x - _parent.next._x);
y22 = -(this._y - _parent.next._y);
//user.ang = Math.atan((user._x - x1) / (user._y - y1));
//this.ang = Math.atan((x2 - x22) / (y22 - y2));
//thetad = user.ang / (Math.PI / 180);
m1 = (y11 - y21) / (x11 - x21);
m2 = (y12 - y22) / (x12 - x22);
if (x11 == x21) {
_parent.user.xvel += 0.01;
}
if (x12 == x22) {
x12 += 0.01;
}
xxx = ((-m2 * x12) + y12 + (m1 * x11) - y11) / (m1 - m2);
yyy = (m1 * (xxx - x11)) + y11;
_parent.rd._x = xxx;
_parent.rd._y = yyy;
if ((xxx > Math.min(x11, x21) && xxx < Math.max(x11, x21)) || (yyy < Math.min(y11, y21) && yyy > Math.max(x11, y21))) {
intersect1 = true;
} else {
intersect1 = false;
}
if ((xxx > Math.min(x12, x22) && xxx < Math.max(x12, x22)) || (yyy < Math.min(y12, y22) && yyy > Math.max(x12, y22))) {
intersect2 = true;
} else {
intersect2 = false;
}
if (intersect1 && intersect2 == true) {
//COLLISION, BOUNCE AND ANGLE REDIRECTION
//if (user.air == true) {
_parent.user._y = (this._y + yyy) - (_parent.user._height * .5);
_parent.user.air = false;
_parent.user.yvel = 0;
//}
} else {
}
//DRAW
removeMovieClip(line3);
createEmptyMovieClip("line3", -29);
line3.lineStyle(5, 0x3FBF3F, 100);
line3.moveTo(0, 0);
line3.lineTo(x22, y22);
//
////
//////
////
//
}

Pigbuster
10 Jun 2007, 02:49
Here's what I got so far...
http://img53.imageshack.us/img53/5816/platformthing2op0.swf

Left=left
Right=right
Up=jump
Space=reset

He falls through the line sometimes. This worries me.

SupSuper
10 Jun 2007, 04:29
That just returns a value of "undefined".Figured it out:

onClipEvent (load) {
next = eval("_root." + this._name + "t");
trace(next);
}

You have to add _root. due to hierarchy, and eval() to convert the string to the respective... thing. From then on you can just use "next._x += next._y" and such.

Also, AS3.0 sure is different. You can't even click on a movieclip and add actions anymore!