Best viewed in Firefox

Awesty Productions

Using hitTests Part 2

December 17th, 2006 by awesty

In this tutorial, you will learn how to use a different kind of hitTest to the one I used in the other tutorial. This one can save alot of time if you want to make something like a maze.
I am using Flash 8, but Flash MX 2004 will work fine. Any version previous to that won’t.

Here is an example of what we will be making: Link

First of all, open a new flash document. You need to draw a simple maze type thing, for your character to try and get through. Here is what mine looks like:

Now make it a Movie Clip and give it an instance name of ‘maze’.

Making it a MovieClip:

Giving it an Instance Name:

Make a character that will be moving through the maze. Make it a movieclip and give it an instance name of ‘man’. (See above for examples.)

Put this code on it:

onClipEvent(enterFrame){
	if(Key.isDown(Key.UP)){
		this._y -= 3;
	}else if(Key.isDown(Key.DOWN)){
		this._y += 3;
	}
	if(Key.isDown(Key.LEFT)){
		this._x -= 3;
	}else if(Key.isDown(Key.RIGHT)){
		this._x += 3;
	}
	if(_root.maze.hitTest(_x+(_width/2),_y,true)){
		this._x -= 3;
	}
	if(_root.maze.hitTest(_x-(_width/2),_y,true)){
		this._x += 3;
	}
	if(_root.maze.hitTest(_x,_y+(_height/2),true)){
		this._y -= 3;
	}
	if(_root.maze.hitTest(_x,_y-(_height/2),true)){
		this._y += 3;
	}
}

That looks longer than it actually is. It is all just repeated though, with a few numbers changed around.
The first part you should already know, but if not, you can find an explanation on it in this tutorial. LINK.
The part I will be explaining in this tutorial is this part:

if(_root.maze.hitTest(_x+(_width/2),_y,true)){
		this._x -= 3;
}

That is just a if statement. What it does it is checks if _root.maze (the MC with an instance name ‘maze’) is hitting this movieclip. This hitTest is more precise than the other one though. There are 3 parameters. target.hitTest(_x,_y,shapeFlag). Target, is obviously the movieclip the hitTest is for, which in this case is ‘maze’. The first parameter is the _x coordinate of the other MC. In this case, it is ‘man’s’ _x coordinate, + half its width. Since the registration point is in the center of the MC, that is where the _x coordinate is. But if you add half its width/2, it is going to be on the right side of the MC. So then the hitTest only counts of the ‘maze’ hits the right side of ‘man’.
That was hard to explain, so sorry if you didn’t catch all of it. It’s the same for the rest, but with some numbers changed around so it is a different side.

That is all for this tutorial. You can download the .fla here: LINK

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • del.icio.us
  • digg
  • Furl
  • MyShare
  • NewsVine
  • Netscape
  • Reddit
  • Simpy
  • Slashdot
  • StumbleUpon
  • Technorati
  • YahooMyWeb

RSS feed

131 Comments »

Comment by mart
2006-12-17 12:30:45

this helpped me sooooooooooooo much thx.

 
Comment by awesty
2006-12-17 13:31:15

Good to hear :D

 
Comment by Oakheart
2006-12-17 18:01:56

cool tut, just one question how do you make a win feature?

 
Comment by RDB2006
2006-12-17 23:04:08

yep a gd tutorial, but just one problem. Most of it works, and in different areas the man goes into it a little bit, and at a certian point it wont go through. It might be because my edges are a bit thick or too smooth? any help?

 
Comment by RDB2006
2006-12-17 23:12:20

i just tried it agen with straight lines, but it goes through more of them, right out into the other side :S

 
Comment by awesty
2006-12-18 10:56:33

@Oakhart:

You could have a movieclip at the end and put this code on it.

onClipEvent(enterFrame){
if(this.hitTest(_root.man)){
_root.gotoAndStop(2);
}
}

And on the second frame have a win screen.

@RDB2006: Make sure the lines aren’t to thin and the ‘man’ MC’s registration point is in the center.

 
Comment by Bulletluigi
2006-12-18 11:40:28

First off i wanted to say that you truely are gifted and have helped me very much in this and the other tutorials of yours i have read.

I was wondering though if you could explain how to make a controlable symbol(using up,down,left,right) where each time you change directions your symbol is animated, and he is in just a standing position when a key isn’t being pushed.

Comment by jULIAN
2008-03-12 14:30:42

what i did to that in my games is i made q movie clip inside it of what the arms do and the ationscript is stop(); FOR EVERY frame of the arms moving. now make 4 framews in the character’s movieclip each with him and the arms facing a different direction. make the arms movie clip instance name “arms”.
Last of all, in the Key.(whatever)part after the brackets do this.gotoAndStop(the frame you want it to go to inside the frame); and this.arms.play();
sorry if it doesn’t make sense but don’t thank me if you do understand.
follow this! http://www.bounceboy100.deviantart.com/
look ’round there and you might see!

 
 
Comment by Oakheart
2006-12-18 14:36:54

i second that, this is the best tut site iv ever ben to, unsted of just copy pasting info you teach this info. and answer our quest, weather theve ben asked 1 or 5 times. and your are nice and smart- AWSOME SITE!

 
 
Comment by Bob
2006-12-18 21:47:41

Wow you really helped me alot on this one Awesty. I’ve made two levels so far, both with patrolling gaurds, that if you touch you go to an interactive maze game over screen. I can’t wait to finish it and publish it to my dA.
I also can’t wait to see what else you’ve got up your sleeves!

 
Comment by RDB2006
2006-12-18 22:22:49

Ty for your tutorials awesty, ive read them all and theyve helped me a lot progress in flash. Ive made a cave raiding game with lava, traps, walls, treasure etc. So ty nd i’ll publish it soon on my site when ive finished :)

 
Comment by Bulletluigi
2006-12-19 06:49:49

Well.. how do you make 1 frame be animated?
I understand that i need to do the gotoAndStop(FRAME), but i dont know how i can have an animation of walking in 1 frame. To make something animated i thought you had to have multiple frames..?
Please help me if you understand what i have asked now.

 
Comment by Blizzard
2006-12-19 13:09:58

I have a question i sent to your mail, but since is not working…

can i do this:
_root.XX_mc.gotoAndStop (var)

i think it’s pretty clear, but what i want to do is to, at some point send a movie clip to the frame equal to a variable, i also tried:

_root.XX_mc._currentframe = var

but none of them worked, i’d apreciate any help, thanks in advance

 
Comment by Bulletluigi
2006-12-19 14:21:29

**Error** Scene=Scene 1, layer=button, frame=1:Line 1: Statement must appear within on handler
if(lvl.Boolean = true){

Total ActionScript Errors: 1 Reported Errors: 1

What is wrong with this? lvl is a variable

Comment by Julian Subscribed to comments via email
2008-08-07 20:50:21

shouldn’t it be == instead of = so that it checks if it is equal instead of making it equal? i know nothin about booleans but i wanted to point that out!

 
 
Comment by awesty
2006-12-19 17:18:15

@Bob: I don’t know about you, but I have arms up my sleeves. ;)
@RDB2006: Sounds cool. Can’t wait to see it ;)
@BulletLuigi: You need to make a MC (Movie Clip). Hit Ctrl F8 to make a blank one. To edit it, open the library panel (Windows>Library I think, if not try Ctrl L) and double click it.

Now you should see a blank timeline. Make you animation there, and then go back to scene 1 (above the timeline). Now, drag your MC onto the frame. Now when you play the movie, on that frame, the MC will play, even if the movie is not. It is kind of like a movie inside a movie.

With the error, is that inbetween onClipEvent(enterFrame){}?. If not it needs to be. Also you don’t need the .Boolean on the end of that variable. You can just use lvl.w

@Blizzard: Here is a copy of the email I tried to reply back to you.

Instead of doing _root.bzzd._currentframe = percentage, you could do
something like _root.bzzd.gotoAndStop(percentage). But here is a good
tutorial for preloaders, and it is easier than making 100 framed MC’s. It
only has 3 frames I think.

http://www.graphicaddicts.net/.....425.0.html

Hope that helps,
Awesty.

 
Comment by Bulletluigi
2006-12-19 18:55:26

Wow.. thanks a lot man you truely are the best.. lol but its like 3 am here.. what country do you live in? (if you don’t want to say just ignore this post)

 
Comment by Bulletluigi
2006-12-19 19:51:00

onClipEvent (enterFrame) {
facing = this._xscale;
if (Key.isDown(Key.RIGHT)) {
_x = 5;
gotoAndStop(2);
facing = 100;
}
if (Key.isDown(Key.LEFT)) {
this._x -= 5;
gotoAndStop(2);
facing = -100;
} else if (!Key.isDown(Key.LEFT) &&
!Key.isDown(Key.RIGHT)) {
gotoAndStop(1);
}
}

I was really proud of myself for thinking of this script on my own but then.. I tested it and when I press left the Hero’s _xscale doesn’t make him reverse direction to face left.. What did I do wrong?

 
Comment by Bulletluigi
2006-12-19 19:54:23

Well.. i got it to work right, but i still dont know why the script that i posted didn’t work.. all i did to fix it was change where i put facing = (percentage) into this._xscale = (percentage) , but i thought it would be the same thing because it was a variable that meant this._xscale. Please help me understand this.

 
Comment by Blizzard
2006-12-20 03:50:50

Awesty,
i know that doing 100 framed mc’s may not the best way, but i have an animated logo, and the thing i want to do is to animate it as the movie is loaded, if the percentage loaded is 15%, i want the clip to go to frame 15, that way, the the clip would be advancing as the movie is loaded, i’ll try the code u gave me, i had think about it but i wasn’t sure if you could put a variable there…

Thanks

 
Comment by Blizzard
2006-12-20 04:01:07

2 more things:
-I’ve managed to do what i wanted =D, shall i send u the .fla file?

-No signs of your mail, maybe i screwed up, i don’t know if the “.mx” matters at yahoo, i just keep forgeting to write it… =/

thanks a lot =)

 
Comment by awesty
2006-12-20 09:20:31

@Bulletluigi: It is 10:15am here now, I am not sure what time it was when I posted that though.

With the variable thing… Try not to use variables for functions or properties, just use there real names ;) .

@Blizzard: Do it which ever you think will work best for you, I just like the other way better. Many people will like your way better.

Are you using Flash MX?

Btw my mail isn’t working at the moment, but it should be fixed soon.

 
Comment by Bulletluigi
2006-12-21 06:19:21

Yea, I just like to trial and error and learn new ways of doing different tasks.

 
Comment by Bulletluigi
2006-12-21 06:26:40

Oh yea I meant to ask this before, because its too late now, but did you enter a game into the Armor games contest? If not why don’t you? You would have a good chance to place.. and though it isn’t much to offer. If you decide to do a contest in the future i would be more than happy to help you out(even though the main reason that I want to do something like this with you is so that I can learn from watching you script and if at all possible I could help you). I can do animation alright I guess if you needed that. Well just send me an e-mail explaining your answer to this message. Bulletluigi@hotmail.com

 
Comment by awesty
2006-12-21 11:44:16

No, I didn’t enter into it.

I started a game. Set out the map basically and every thing. Just needed to code it, then put in the good graphics. But I started to late, on the 10th of December about so I didn’t have the time or motivation.

 
Comment by Bulletluigi
2006-12-21 15:15:37

Yea I understand man, but they do these contests often I have been told, so if you ever need help with graphics or animations then i’ll be more than happy to help. I’ll start working on a few animations and characters and such to help you decide if you’d want my help or not.

 
Comment by Bulletluigi
2006-12-21 15:19:17

(I don’t know where to post this because it is off subject for like everything, but .. )
For Christmas I might be getting one of those drawing pads that you hook into your computer. I am also getting a Wii!! WOOT! Twilight Princess FTW!

 
Comment by KIM
2006-12-21 22:44:28

yey!, i know how to make a maze game!

Great tute
THNX!

 
Comment by awestyfan
2006-12-22 03:22:56

hey

how do are I make an enemy, who follow the man in the maze game?

 
Comment by Bulletluigi
2006-12-22 05:43:42

OH yea awesty if were anywhere close to done with that game i’m sure everyone would want you to finish it. =^.^=

 
Comment by KIM
2006-12-22 09:44:58

oh yeah, never thought of it, how can i make an enemy in this game… or should i just look at ur A.I. tute?

 
Comment by awesty
2006-12-22 10:59:45

@Bulletluigi: You mean a tablet? Btw I really want a wii and TP, it looks so good.
Newgrounds usually have a contest on at least every 2 months, or more often.
Armor game don’t have them as often, but if you can make a good game they will sponsor it and you get paid good $$.
And no, I am nowhere near finished.

@KIM & awestyfan:

http://www.awestyproductions.com/tutorials/flash-tutorials/basic-artificial-intelligence/
http://www.awestyproductions.c.....ce-part-2/

 
Comment by KIM
2006-12-26 17:26:12

i need help (i need an ans ASAP(i dont know why))

how can i make my man mc unable to go to the finish line without a key?

 
Comment by KIM
2006-12-27 11:22:47

sorry about that, but i figured it out

where can i put my game for every one to play?

 
Comment by Shabith
2006-12-28 16:39:08

Thanks dude! this is wat i look for get start my game design..thanks again..:)

 
Comment by awesty
2006-12-28 17:40:01

@KIM: Try

http://www.newgrounds.com - Your game might get blammed if its not good enough.

http://www.deviantart.com - All art/animations/games get accepted.

 
Comment by kindred
2006-12-28 23:46:43

tnx!!!

 
Comment by eblup
2006-12-29 00:38:44

this is also good for ground and walls like in mario thanks

 
Comment by paruchuri vamshi
2006-12-29 17:29:06

nice this helped me to understand something new

 
Comment by rasha
2006-12-31 08:30:30

is there a way to make it go to a different frame when it hits the walls

 
Comment by awesty
2006-12-31 13:10:44

if(this.hitTest(_root.wall)){
_root.gotoAndStop(FRAME);
}

 
Comment by bruno
2006-12-31 23:24:28

i need help creating a footbal game.
i cant do the goals
if(this._y > 385){
_root.lose();
}
if(this._y

 
Comment by awesty
2007-01-01 12:08:45

The code gets cut of. Just replace the < with LESSTHAN. Since only I can use <

 
Comment by Calum
2007-01-02 01:01:53

hiya awesty I am VERY VERY new to flash and i am trying to make my own rpg game, and ive read all of your tutorials but i dont understand how to make an animation of him walking, jumping or kicking or hiting or anything like that. could you please tell me how to do it please cause I just can’t do it. But ive seen how smart you are so I thought you would be able to help me.

Hope you help

Thanks

Calum :)

 
Comment by Calum
2007-01-02 02:17:58

oh and how do i make an enemy move up, down, left and right.

I got the message on your tutorial saying use this for up and down:

onClipEvent(enterFrame){
this._xscale = _root.hp;
if(_root.hp

 
Comment by Calum
2007-01-02 03:39:22

? ok thats weird it deleted some of my message, well what iw as gonna say is could you put the full code here and that be great thanks :)

 
Comment by awesty
2007-01-02 10:35:49

To make the animations you just have to practice. You aren’t going to be good at it straight away.

Your code got cut off but you have a < sign. It gets taken out because of strip_tags function.

For up and down, this code will work:

onClipEvent(enterFrame){
if(this._y < (_root.man._y - 25)){
this._y = 3;
}
if(this._y < (_root.man._y 25)){
this._y -= 3;
}
}

For left and right try these tutorials:

http://www.awestyproductions.com/tutorials/flash-tutorials/basic-artificial-intelligence/
http://www.awestyproductions.c.....ce-part-2/

 
Comment by Calum
2007-01-03 00:26:34

ok but where do i put that code in here:

onClipEvent(enterFrame){
tx = this._x;
mx = _root.man._x;
rx = tx - mx;
if(this.hitTest(_root.man)){
this.gotoAndStop(2);
}else{
if(rx >= 1 && rx-300){
this._x = 1;
}
this.gotoAndStop(1);
}
}

thanks :)

 
Comment by Calum
2007-01-03 00:29:33

oh and about the animations, i can draw them fine but im wondering how to make them show the walking left picture when i make them move left and the walking right picture, and the jumping picture etc?

 
Comment by awesty
2007-01-03 11:31:52

onClipEvent(enterFrame){
tx = this._x;
mx = _root.man._x;
rx = tx - mx;
if(this.hitTest(_root.man)){
this.gotoAndStop(2);
}else{
if(rx >= 1 && rx-300){
this._x = 1;
}
this.gotoAndStop(1);
}
if(this._y < (_root.man._y - 25)){
this._y = 3;
}
if(this._y < (_root.man._y 25)){
this._y -= 3;
}

For the animation, this should help:

http://www.awestyproductions.c.....ight-game/
}

 
Comment by ALEX
2007-01-04 08:52:28

thanx man thats helped me so much i have been looking evry where so u cant go through the wall thanx so much ur a legend :)

 
Comment by dave
2007-01-06 09:00:54

**Error** Scene=Scene 1, layer=Layer 3, frame=1:Line 1: Clip events are permitted only for movie clip instances
onClipEvent(enterFrame){

Total ActionScript Errors: 1 Reported Errors: 1

 
Comment by awesty
2007-01-06 11:29:05

You need to put the code on a MC, not the frame.

 
Comment by dave
2007-01-07 21:34:36

you mean in the movie clip

 
Comment by Daniel
2007-01-08 02:13:01

Wow, i just realised i could use apply this tut to making a wall in my fight game. GREAT TUTS AND GREAT WEBSITE.
Tyvm

 
Comment by Tamar
2007-01-11 03:32:39

thanks it helped me out alot although i dont know why but when i play my maze game i made my person can go right through the walls can anyone help me out?

 
Comment by Tamar
2007-01-11 03:34:03

this really helped me out alot although for some reason when i play my game my person can go right through the walls can anyone help me?

 
Comment by ahhhh
2007-01-12 06:05:37

ahhhhh

 
Comment by ahhhh
2007-01-12 06:07:04

dude i like kool games gimme one now!!!

 
Comment by Nick
2007-01-12 23:39:20

Tyus hlped meu sooooee muh. Tyhank yew alyot syr. eye luvvvv donut’s and iahve ai mustache

 
Comment by awesty
2007-01-13 16:06:33

@Tamar: Make sure the instance names are right.

 
Comment by djodin
2007-01-14 04:52:59

Thank you!
Now I finaly understand hitTest!! :D

 
Comment by Mr.Pmorski
2007-01-16 00:35:47

just stop, settle down, calm down please

 
Comment by AceDecade
2007-01-16 15:14:43

Awesome tutorial! I needed this soooooo much!!

 
Comment by Justin Hrndriks
2007-01-17 23:42:55

i am slow

 
Comment by pip
2007-01-19 08:56:19

hi i was wondering how if u move an mc into a certain place that it will open a new screen???

 
Comment by awesty
2007-01-19 14:33:10

Do you want it to launch another screen, seperate from the flash movie?

 
Comment by pip
2007-01-19 19:16:15

ooooh yes please

 
Comment by awesty
2007-01-20 11:52:40

I actually dont know how to do that sorry. :\

 
Comment by pip
2007-01-20 19:21:38

k all gud

 
Comment by Syrona
2007-01-24 02:58:32

Great tutorial!!! Great Website!!!

 
Comment by Carborundum
2007-01-26 09:54:26

I have a different type of movement system which I am using shown below but i am adding a wall in with I have drawn same method as the maze but I can’t get it to work in line tith what i have done hope you can help

if (Key.isDown(Key.UP)) {
xSpeed = thrust*xThrustPercent;
ySpeed = thrust*yThrustPercent;
flames._visible = 0;
} else {
xSpeed *= decay;
ySpeed *= decay;
flames._visible = 0;
thrustSound.stop();
soundStartable = true;
}
//
if (Key.isDown(Key.RIGHT)) {
_rotation = 10;
}
//
if (Key.isDown(Key.LEFT)) {
_rotation -= 10;
}
}

 
Comment by awesty
2007-01-26 11:17:00

Can you please paste the whole code you were using?

 
Comment by Carborundum
2007-01-27 04:22:23

Theres a fair chunk but here goes for the whole code

onClipEvent (load) {
// Start up
_root.explosion.stop()
_root.cell._visible = 0;
_root.ship._alpha = 0;
_root.amoeba._visible = 0;
_root.circle.ring._visible = 0;
_root.ship.body.body2._visible = 0;
_root.mask.label._visible = 0;
_root.texts.whiteText._visible = 0;
_root.startButton.blackButton._visible = 0;
_root.shipShadow._alpha = 0;
_root.circle.swapdepths(4000000);
_root.mask.swapdepths(4000001);
_root.texts.swapdepths(4000002);
_root.startButton.swapdepths(4000003);
radius = _root.ship.body._height/2;
radius2 = _root.circle._width/2;
centerx = _root.circle._x;
centery = _root.circle._y;
bonusLifeScore = 500;
score = 0;
lives = 0;
level = 2;
totalcells = 0;
cellNumber = 1;
explosionNumber = 1000000;
shotNumber = 1000;
totalShots = 1;
maxShots = 10;
shotSpeed = 20;
thrust = .6;
decay = .98;
maxSpeed = 8;
//
// initiate sounds
shotSound = new Sound(this);
shotSound.attachSound(”shoot”);
soundStartabe = true;
//
// functions (named accoding to what they do)
function initiate() {
_root.startButton.enabled = false;
_root.ship._rotation = 0;
if (started) {
buttonFadeOut = true;
}
for (i=cellNumber; i>0; i–) {
removeMovieClip(”_root.cell” i);
}
death(_root.amoeba);
score = 0;
level = 2;
lives = 7;
dead = false;
fadeIn = true;
}
soScores = SharedObject.getLocal(”flashcookie”);
mListener = new Object();
var score = 0;
if (soScores.data.highScore != null)
{
highScore = soScores.data.highScore;
}
Mouse.addListener(mListener);
mListener.onMouseDown = function()
{
score ;
if (score > highScore)
{
highScore = score;
soScores.data.highScore = highScore;
}
};
//
function wraparound(whichObject) {
with (whichObject) {
delta_x = _root.circle._x-_x;
delta_y = _root.circle._y-_y;
angle = Math.atan2(delta_y, delta_x);
distance = Math.sqrt((delta_x*delta_x) (delta_y*delta_y));
if (distance>radius2) {
_x = (Math.cos(angle)*(radius2)) centerx;
_y = (Math.sin(angle)*(radius2)) centery;
}
}
}
//
function collisions(whichObject) {
for (a=1; a90) {
whichObject.hit(0);
}
death(_root.ship);
}
}
for (b=1000; b90) {
explosion(whichShip);
}
if (whichShip == _root.ship) {
deathTime = getTimer();
if (!dead) {
lives–;
}
dead = true;
thrustSound.stop();
soundStartable = true;
whichShip._alpha = 0;
_root.shipShadow._alpha = 0;
whichShip._x = 302;
whichShip._y = 295;
} else {
whichship.appearTime = getTimer();
whichship.pauseTime = (Math.random()*7000) 7000;
whichship._visible = 0;
}
}
//
// toggle buttons
_root.mask.backgroundButton.onRelease = function() {
_root.circle.drop._visible = !_root.circle.drop._visible;
_root.circle.ring._visible = !_root.circle.ring._visible;
_root.mask.dropShadow._visible = !_root.mask.dropShadow._visible;
_root.background._visible = !_root.background._visible;
_root.ship.body.body2._visible = !_root.ship.body.body2._visible;
_root.mask.label._visible = !_root.mask.label._visible;
_root.mask.maskedArea._visible = !_root.mask.maskedArea._visible;
_root.texts.whiteText._visible = !_root.texts.whiteText._visible;
_root.startButton.blackButton._visible = !_root.startButton.blackButton._visible;
_root.startButton.colorButton._visible = !_root.startButton.colorButton._visible;
};
//
_root.mask.qualityButton.onRelease = function() {
toggleHighQuality();
};
}
//
onClipEvent (enterFrame) {
_root.startButton.onRelease = initiate;
// Adds new cells when all die and extra
if (totalcells == 0 && started) {
level ;
cellNumber = 1;
}
if (cellNumber0) {
pauseTime = getTimer()-deathTime;
if (pauseTime>2000 && lives>0) {
dead = false;
fadeIn = true;
}
}
//
// extra lifes
if (score>bonusLifeScore) {
bonusLifeScore = 500;
lives = 1;
}
//
// Button fading
with (_root.startButton) {
if (lives == 0) {
_root.startButton.enabled = true;
if (_alpha0 && buttonFadeOut) {
_alpha -= 10;
} else {
buttonFadeOut = false;
}
}
//
// map loop
wrapAround(_root.ship);
//
// Shotting
if (Key.isDown(Key.SPACE)) {
if (!spacekeydown && !dead && totalshotsmaxshots) {
shotnumber = 1000;
}
shotyspeed = shotspeed*yThrustPercent;
shotxspeed = shotspeed*xThrustPercent;
spacekeydown = true;
}
} else {
spacekeydown = false;
}
//
with (_root.ship) {
// Fading in
if (_alphamaxSpeed) {
xSpeed *= maxSpeed/speed;
ySpeed *= maxSpeed/speed;
}
//
// move ship based on calculations above if ship is visible
_y -= ySpeed;
_x = xSpeed;
if (dead) {
xSpeed = 0;
ySpeed = 0;
}
//
// collision points
angle1 = (_rotation-90)*(Math.PI/180);
tipy1 = (Math.sin(angle1)*radius) _y;
tipx1 = (Math.cos(angle1)*radius) _x;
angle2 = (_rotation 57)*(Math.PI/180);
tipy2 = (Math.sin(angle2)*radius) _y;
tipx2 = (Math.cos(angle2)*radius) _x;
angle3 = (_rotation-237)*(Math.PI/180);
tipy3 = (Math.sin(angle3)*radius) _y;
tipx3 = (Math.cos(angle3)*radius) _x;
_root.shipShadow._x = _x 4;
_root.shipShadow._y = _y 4;
_root.shipShadow._rotation = _rotation;
}
}

 
Comment by awesty
2007-01-27 12:25:49

Fuck…

lol im not going to be able to do that without flash, which I dont have at the moment because my computer crashed. :(

 
Comment by awesty
2007-01-27 12:28:03

Actually just email it to:

awestyproductions@gmail.com

And I will try and fix it as soon as I has access to flash. (I do have a copy of flash, but it is on a laptop with 64mb of RAM :\).

 
2007-02-01 16:21:57

[…] That is so ‘man’ can’t walk over the other guy. For an explanation on that code take this tutorial: http://www.awestyproductions.c.....ts-part-2/ […]

 
Comment by Bryce K
2007-02-03 09:38:16

OMG!! Awesty used a cuss word NOOOO! What has this world come to?!???!!? Nah, just joking :P

 
Comment by awesty
2007-02-03 10:55:59

@Bryce K: I swear all the time :P

 
Comment by Jenny
2007-02-16 06:42:37

Hello,

Thanks for your wonderful MAZE tutorial. One problem though. I am loading the maze .swf file into another .swf using and empty movie clip to load the .swf into. When I test the maze in the parent .swf file, my little “man” in the maze walks straight through the walls. It works fine when I test the maze.swf alone.

Any help would be greatly appreciated!

Thanks — Jenny

 
Comment by Firebelly
2007-02-16 07:21:07

Hi Awesty

Your tutorials are dam good and I’m really starting to get the hang of flash. Your explanations of the coding are very detailed and relatively easy to understand.

so thanks :)

Firebelly

P.S if your Wii’s online can I have your friend code :P

 
Comment by Grifo
2007-02-16 08:22:37

@Jenny I’m not sure I understood what you mean, but I believe maybe some of your _root.man commands may have to change a bit. What I mean is that now you’re man isn’t in the root anymore, he is inside an “empty movie clip” as you said, so it would e something like _root.mymc.man hitTest etc…
I’m not sure tho.
Hope this helps.

 
Comment by Jenny
2007-02-16 10:47:21

Hi Grifo,

Thanks for trying. Well, I tried that. I tried just about everything, but when I test the “parent” swf, the man walks straight through the walls, not matter what. Tried to put the _lockroot command in the main .swf, the script on the man, even on the load button, but nothing worked. Thanks again.

Jenny

 
Comment by awesty
2007-02-16 16:00:46

@Jenny: Is the maze game coded in the parent .swf, or the child .swf?

@FireBelly: I havented got it online yet, I am havings problems with it trying to update. It goes extremely slow.

 
Comment by Firebelly
2007-02-16 19:44:06

try going onto the nintendo wifi forums for help - I had to install a patch for my ninty wifi usb thing. It’d be cool to see your mii and play you online when wii games eventually go online. Woo smash bros brawl :)