View Full Version : Any Mac users out there?
wangbar
12-14-2001, 12:01 PM
Hi, I've just completed the rough outline for a site but the client can't get it to work. They're on Macs, I'm on PC - it works fine for me on several machines but they see nothing.
Can any mac users check this url and let me know if they have problems. I'm sure it's a configuration problem on the client's side because Flash is cross platform but they assure me that they're up to date with plug-ins etc. I'm baffled...
Please note that this is an early cut of the site, not the finished article: I know the code and graphics need optimisation and I'm on the case I just need to track down this mac issue and shoot it...
http://www.wangbar.co.uk/japIndex.html
MikkyDK
12-14-2001, 02:15 PM
I've just checked your site on a Mac and it's not working. Just kiding, it works, so it's probaly just your clients who hav'nt updated their FlashPlayer.
Mikky, themall
Billy T
12-14-2001, 02:26 PM
yep works fine for me too.
I was just thinking today that I would like to make a pac-man type game but I have no idea how to go about it - would you mind giving a brief run down on how you did the movement of the baddies etc?
are there any tuts on this?
thanks
wangbar
12-14-2001, 02:54 PM
Here's the run down...
The maze is built on a grid of 25 pixel squares, the "hero" moves in five pixel increments so what's happening is that a hitTest script is looking ahead 30 pixels to see if it's okay to go there.
Since the junctions are laid out on this grid then you can cut down on calculations by checking to see if the little guy is allowed to change direction (in other words if he's in a location where the _x or _y co-ordinates are divisible cleanly by 25). Add a keyDown detection script to this and you have all the code that controls the hero.
The bad guys use almost the same code with the keyDown bits replaced with some conditional stuff which compares their x and y positions to the hero's and adds or subtracts a value accordingly moving them closer all the time.
I've got everything wrapped up in functions, and external as files at the moment so it's hard to give you the exact code (plus I don't think the client would be too happy about me sending the .fla!) but here's the idea in a rough form...
"hero"
onClipEvent (keyDown) {
// detect key presses and check for collisions with walls
// (variable "d" is the distance needed to make a move)
if (Key.isDown(Key.RIGHT) && this._y%25 == 0 && !(_root.background.hitTest(this._x+d, this._y, true))) {
_x += speed;
} else if (Key.isDown(Key.LEFT) && this._y%25 == 0 && !(_root.background.hitTest(this._x-d, this._y, true))) {
_x -= speed;
} else if (Key.isDown(Key.DOWN) && this._x%25 == 0 && !(_root.background.hitTest(this._x, this._y+d, true))) {
_y += speed;
} else if (Key.isDown(Key.UP) && this._x%25 == 0 && !(_root.background.hitTest(this._x, this._y-d, true))) {
_y -= speed;
}
// check to see if player has exited stage and, if so, wrap around
if (_x<left) {
_x = right;
} else if (_x>right) {
_x = left;
}
// smooth action
updateAfterEvent();
}
add this for bad guy...
if (_x<_root.jap._x){
//run check to see if you're clear to go right
//if so _x+=giSpeed;
}
and so on...
Hope this helps.
Billy T
12-15-2001, 01:18 AM
thanks champ :D
Drewmutt
04-23-2002, 07:28 PM
The way I pulled Pacman off was by using a 2d array. Our clients are known to be indecisive, so I wanted as much flexablity and speed as I could get. The idea is that on a 2d array the 0's represent spaces, the 1's=blocks, 2's=dots, etc... My version had a twist is which the big dots were questions that we asked.. so I had 3=1st question, 4=2nd q.. etc. Here's a nutshell version of the move function.
PManMove()
{
OldX=PManX;
OldY=PManY;
//If his direction is east, increment his X.
if(PManDirection==1)
PManX++
...
//If where his new location is a block.
if(LevelMap1[PManY][PManX]==1)
{
//Go back to where he was.
PManX=OldX;
PManY=OldY;
}
}
I also had a PManUpdate(), which placed him in the correct place given his X, Y on the grid. He does make transitions to each block (half-steps), for instance his X could be 13.5, I would round up or down depending on what direction he was going.
Hope this gave you some insight, and you are more than welcome to email me. My client is not very techno-savey, so I could share some exerpts.
~Andrew
Drewmutt
04-23-2002, 07:42 PM
I almost forgot about the bad guys. In my game, the client didn't want them attacking you, but just wanted them going on their own little path. Here's what I did, and what you could do.
Every main loop cycle, it looks east, west, north, and south of the badguy locaiton in the array, and checks to see which way isn't a block. Then is made an array, and randomly picked one.
For instance, let's say that the array is looking like this.
0=space
1=block
x=where the evil guy is.
[
101111
1x0000
101111
]
In this situation he can move east, north, or south. Let's say he's moving north, currently, so we negate that, otherwise he would be back tracking.. etc..
So, the array is built:
1=east, 2=south, 3=west, 4=north
PossibleDir[0]=1
PossibleDir[1]=4
NewDirection=PossibleDir[int(Math.random(PossibleDir.length))]
Now, if you wanted the guys to chase you, you could use this:
I know it could be cleaned up, and more effient, btw ;)
//PacMan is to the right of the ghost.
if(PMan._x>Ghost._x)
{
for(i=0; i<=PossibleDir.length; i++)
{
//If east is a possiblity, do that.
if(PossibleDir[i]==1)
GhostDir=1;
}
}
//PacMan is to the left.
if(PMan._x<Ghost._x)
{
....
I really hoped I helped you out. Not saying this is the perfect way, but it's worked very well for me.
~Andrew
Billy T
04-23-2002, 09:08 PM
thanks for your time man - I appreciate it ;)
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.