View Full Version : HElp with shooter.
Stilianos
June 22nd, 2006, 10:25 PM
I have a question that involves an incredibly bright person withACTIONSCRIPT.
My question is : If anyone has ever played stickman sam (www.crazymonkeygames.com/Stickman-Sam-2.html (http://www.crazymonkeygames.com/Stickman-Sam-2.html))
you will notice that you can move through parts of the level. I assume it is using coordinates. Can anyone help me with this?
:h:
SacrificialLamb
June 22nd, 2006, 11:13 PM
do you have anything to work from or do you want people just to try to code it from scratch.
i could probably do the moving around bit but i don't know (off the top of my head) how to keep the zombies in the same place every time you enter the map
Stilianos
June 23rd, 2006, 12:01 AM
if i can repeat. The zombies dont stay dead because of the actionscript its because the whole level is one whole map, and when you reach a border the coordinates change from lets say 1,1 to 1,2 do u get what im saying?
Reply soon.:)
SacrificialLamb
June 23rd, 2006, 01:02 AM
oh i could do that.
some thing like
if (man_mc._x<0){map._x+=stageWith}
if (man_mc._x>stageWith){map._x-=stageWith}
if (man_mc._y<0){map._y-=stageHight}
if (man_mc._y>stageHight){map._y+=stageHight}
you might want to make the man_mc._y in to some thing like (man_mc._y+man_mc.hight)
but soem thing like that should work
Stilianos
June 23rd, 2006, 01:05 AM
i kind of get it. But were deos the code go?
SacrificialLamb
June 23rd, 2006, 01:21 AM
on a enterframe, where the movement is. you might be able to get it on a key Listener, but I don’t see how that would work on jumping but if you only had side to side (it would save on CPU usage)
Stilianos
June 23rd, 2006, 01:38 AM
Sorry I dont think it will work. I think il have to try another way.
Also if you could help with my reaserch on finding how to do the stickman sam map switch maps it would be great.
Thanx in advance:)
Stilianos
June 23rd, 2006, 04:43 AM
grrr need help! can anyone help me?
:(
Joppe
June 23rd, 2006, 05:17 AM
Probably something like
if(this._x > Stage.width){nextFrame();} like sacrificial said :/
SacrificialLamb
June 23rd, 2006, 05:19 AM
it dose work
"wasd" controles you go right throw the walls coz i just showign that the map thing works
if (this._x<0){//left
_root.map._x+=Stage.width-10
this._x+=Stage.width-10
}
if (this._x>Stage.width){//right
_root.map._x-=Stage.width-10
this._x-=Stage.width-10
}
if (this._y<0){//up
_root.map._y+=Stage.height-10
this._y+=Stage.height-10
}
if (this._y>Stage.height){//down
_root.map._y-=Stage.height-10
this._y-=Stage.height-10
}
Stilianos
June 23rd, 2006, 06:51 AM
Ok im thankful that you are tolerating my persistance but i need to know in more detail ie more script were the script goes?
This is my script
onClipEvent (load) {
y = jump=0;
speed = 5;
}
onClipEvent (enterFrame) {
xmax = this.legs.getBounds(_root).xMax;
xmin = this.legs.getBounds(_root).xMin;
ymax = this.legs.getBounds(_root).yMax;
if (Key.isDown(68) && !_root.ground.hitTest(xmax+speed, _y, true)) {
_x += speed;
this._xscale = 180;
this.legs.play(2);
}
if (Key.isDown(65) && !_root.ground.hitTest(xmin-speed, _y, true)) {
_x -= speed;
this._xscale = -180;
this.legs.play(2);
}
if (_root.ground.hitTest(_x, ymax-(y/2), true)) {
jump = true;
y = 0;
} else {
y -= 2;
jump = false;
}
if (jump && Key.isDown(87)) {
y = 18;
}
_y -= y;
}
Copy paste from this script, add the code. This will expand my knowlege of were it "goes".
Thank you for not giving up on me:)
Thanx in advance.
Stilianos
June 23rd, 2006, 09:13 PM
Please dont ignore me:(
If you arent ignoring me well im sorry for saying you are ignoring me:)
Now can anyone help me with puttin the cod in the above script?
Joppe
June 24th, 2006, 06:57 AM
onClipEvent (enterFrame) {
xmax = this.legs.getBounds(_root).xMax;
xmin = this.legs.getBounds(_root).xMin;
ymax = this.legs.getBounds(_root).yMax;
if (Key.isDown(68) && !_root.ground.hitTest(xmax+speed, _y, true)) {
_x += speed;
this._xscale = 180;
this.legs.play(2);
}
if (Key.isDown(65) && !_root.ground.hitTest(xmin-speed, _y, true)) {
_x -= speed;
this._xscale = -180;
this.legs.play(2);
}
if (this._x<0){//left
_root.map._x+=Stage.width-10
this._x+=Stage.width-10
}
if (this._x>Stage.width){//right
_root.map._x-=Stage.width-10
this._x-=Stage.width-10
}
if (this._y<0){//up
_root.map._y+=Stage.height-10
this._y+=Stage.height-10
}
if (this._y>Stage.height){//down
_root.map._y-=Stage.height-10
this._y-=Stage.height-10
}
if (_root.ground.hitTest(_x, ymax-(y/2), true)) {
jump = true;
y = 0;
} else {
y -= 2;
jump = false;
}
if (jump && Key.isDown(87)) {
y = 18;
}
_y -= y;
}
Stilianos
June 24th, 2006, 09:43 PM
Thanx Joppe your a life saver!:)
If u ever need help just send me a message and il be happy to help.
InfestedDemon
June 24th, 2006, 09:51 PM
but like didn't he just help you, the noob, joppe is a master of AS :rambo: ??? dudes, my minds blown stop confusing me!
Stilianos
June 24th, 2006, 10:15 PM
Well this is kind of embarasing but...
It deosent change it jus t respawns from the top :(
Check it out.
nathan99
June 24th, 2006, 10:40 PM
@ryan, everyone has diff strengths a weaknesses
and Re the code, play(2) "/ play() has no parameters
also, i would use frame-based codes over the MC method your using, but its your choice.
MC based:
onClipEvent (load) {
var speed:Number = 5;
var y:Number = 0;
var jump:Boolean;
function setMove(to:Number) {
_x += speed*to;
this._xscale = 180*to;
this.legs.play();
}
function moveMap(effect:String, targ:String, dist:Number) {
_root.map[targ] += (Stage[effect]-dist)*(arguments[3] ? -1 : 1);
this[targ] += (Stage[effect]-dist)*(arguments[3] ? -1 : 1);
}
}
onClipEvent (enterFrame) {
xmax = this.legs.getBounds(_root).xMax;
xmin = this.legs.getBounds(_root).xMin;
ymax = this.legs.getBounds(_root).yMax;
setMove(Key.isDown(68) && !_root.ground.hitTest(xmax+speed, _y, true) ? 1 : Key.isDown(65) && !_root.ground.hitTest(xmin-speed, _y, true) ? -1 : null);
this._x<0 ? moveMap("width", "_x", 10) : this._x>Stage.width ? moveMap("width", "_x", 10, 1) : null;
this._y<0 ? moveMap("height", "_y", 10) : this._y>Stage.height ? moveMap("height", "_y", 10, 1) : null;
jump = _root.ground.hitTest(_x, ymax, true) ? true : false;
y = _root.ground.hitTest(_x, ymax, true) ? 0 : y-2;
if (jump && Key.isDown(87)) {
y = 18;
}
_y -= y;
}
or frame based:
var speed:Number = 5;
var y:Number = 0;
var jump:Boolean;
MovieClip.prototype.setMove = function(to:Number) {
this._x += speed*to;
this._xscale = 180*to;
this.legs.play();
}
MovieClip.prototype.moveMap = function(effect:String, targ:String, dist:Number) {
map[targ] += (Stage[effect]-dist)*(arguments[3] ? -1 : 1);
this[targ] += (Stage[effect]-dist)*(arguments[3] ? -1 : 1);
}
char.onEnterFrame = function() {
xmax = this.legs.getBounds(_root).xMax;
xmin = this.legs.getBounds(_root).xMin;
ymax = this.legs.getBounds(_root).yMax;
setMove(Key.isDown(68) && !_root.ground.hitTest(xmax+speed, this._y, true) ? 1 : Key.isDown(65) && !_root.ground.hitTest(xmin-speed, this._y, true) ? -1 : null);
this._x<0 ? moveMap("width", "_x", 10) : this._x>Stage.width ? moveMap("width", "_x", 10, 1) : null;
this._y<0 ? moveMap("height", "_y", 10) : this._y>Stage.height ? moveMap("height", "_y", 10, 1) : null;
jump = _root.ground.hitTest(this._x, ymax, true) ? true : false;
y = _root.ground.hitTest(this._x, ymax, true) ? 0 : y-2;
if (jump && Key.isDown(87)) {
y = 18;
}
this._y -= y;
};
try them ;) I couldnt try em out coz you provided no fla
nathan99
June 24th, 2006, 11:03 PM
ahhh, use
onClipEvent (load) {
var speed:Number = 5;
var y:Number = 0;
var jump:Boolean;
function setMove(to:Number) {
_x += speed*to;
this._xscale = 180*to;
}
function moveMap(effect:String, targ:String, dist:Number) {
_root.ground[targ] += (Stage[effect]-dist)*(arguments[3] ? -1 : 1);
this[targ] += (Stage[effect]-dist)*(arguments[3] ? -1 : 1);
}
}
onClipEvent (enterFrame) {
xmax = this.getBounds(_root).xMax;
xmin = this.getBounds(_root).xMin;
ymax = this.getBounds(_root).yMax;
setMove(Key.isDown(68) && !_root.ground.hitTest(xmax+speed, _y, true) ? 1 : Key.isDown(65) && !_root.ground.hitTest(xmin-speed, _y, true) ? -1 : null);
this._x<0 ? moveMap("width", "_x", 10) : this._x>Stage.width ? moveMap("width", "_x", 10, 1) : null;
this._y<0 ? moveMap("height", "_y", 10) : this._y>Stage.height ? moveMap("height", "_y", 10, 1) : null;
_root.ground.hitTest(this._x, ymax, true) && y<=0 ? (jump=false, y=0) : (jump=true);
while (_root.ground.hitTest(this._x, (this._y+(this._height/2))-1, true) && !jump) {
this._y--;
}
_y -= !jump ? 0 : y -= 2;
Key.isDown(87) && !jump ? (jump=true, _y -= y=18) : null;
}
Stilianos
June 25th, 2006, 12:03 AM
@ryan, everyone has diff strengths a weaknesses
and Re the code, play(2) "/ play() has no parameters
also, i would use frame-based codes over the MC method your using, but its your choice.
MC based:
ActionScript Code:
onClipEvent (load) {</p>
<p> var speed:Number = 5;</p>
<p> var y:Number = 0;</p>
<p> var jump:Boolean;</p>
<p> function setMove(to:Number) {</p>
<p> _x += speed*to;</p>
<p> this._xscale = 180*to;</p>
<p> this.legs.play();</p>
<p> }</p>
<p> function moveMap(effect:String, targ:String, dist:Number) {</p>
<p> _root.map[targ] += (Stage[effect]-dist)*(arguments[3] ? -1 : 1);</p>
<p> this[targ] += (Stage[effect]-dist)*(arguments[3] ? -1 : 1);</p>
<p> }</p>
<p>}</p>
<p>onClipEvent (enterFrame) {</p>
<p> xmax = this.legs.getBounds(_root).xMax;</p>
<p> xmin = this.legs.getBounds(_root).xMin;</p>
<p> ymax = this.legs.getBounds(_root).yMax;</p>
<p> setMove(Key.isDown(68) && !_root.ground.hitTest(xmax+speed, _y, true) ? 1 : Key.isDown(65) && !_root.ground.hitTest(xmin-speed, _y, true) ? -1 : null);</p>
<p> this._x<0 ? moveMap("width", "_x", 10) : this._x>Stage.width ? moveMap("width", "_x", 10, 1) : null;</p>
<p> this._y<0 ? moveMap("height", "_y", 10) : this._y>Stage.height ? moveMap("height", "_y", 10, 1) : null;</p>
<p> jump = _root.ground.hitTest(_x, ymax, true) ? true : false;</p>
<p> y = _root.ground.hitTest(_x, ymax, true) ? 0 : y-2;</p>
<p> if (jump && Key.isDown(87)) {</p>
<p> y = 18;</p>
<p> }</p>
<p> _y -= y;</p>
<p>}
or frame based:
ActionScript Code:
</p>
<p>var speed:Number = 5;</p>
<p>var y:Number = 0;</p>
<p>var jump:Boolean;</p>
<p>MovieClip.prototype.setMove = function(to:Number) {</p>
<p> this._x += speed*to;</p>
<p> this._xscale = 180*to;</p>
<p> this.legs.play();</p>
<p>}</p>
<p>MovieClip.prototype.moveMap = function(effect:String, targ:String, dist:Number) {</p>
<p> map[targ] += (Stage[effect]-dist)*(arguments[3] ? -1 : 1);</p>
<p> this[targ] += (Stage[effect]-dist)*(arguments[3] ? -1 : 1);</p>
<p>}</p>
<p>char.onEnterFrame = function() {</p>
<p> xmax = this.legs.getBounds(_root).xMax;</p>
<p> xmin = this.legs.getBounds(_root).xMin;</p>
<p> ymax = this.legs.getBounds(_root).yMax;</p>
<p> setMove(Key.isDown(68) && !_root.ground.hitTest(xmax+speed, this._y, true) ? 1 : Key.isDown(65) && !_root.ground.hitTest(xmin-speed, this._y, true) ? -1 : null);</p>
<p> this._x<0 ? moveMap("width", "_x", 10) : this._x>Stage.width ? moveMap("width", "_x", 10, 1) : null;</p>
<p> this._y<0 ? moveMap("height", "_y", 10) : this._y>Stage.height ? moveMap("height", "_y", 10, 1) : null;</p>
<p> jump = _root.ground.hitTest(this._x, ymax, true) ? true : false;</p>
<p> y = _root.ground.hitTest(this._x, ymax, true) ? 0 : y-2;</p>
<p> if (jump && Key.isDown(87)) {</p>
<p> y = 18;</p>
<p> }</p>
<p> this._y -= y;</p>
<p>};
try them ;) I couldnt try em out coz you provided no fla
But i did provide a fla even check my post.
nathan99
June 25th, 2006, 12:14 AM
check muy second post :D
Stilianos
June 25th, 2006, 12:24 AM
oops:) Sorry.
Your code is effective, but iv come over some problems with the switch.
How ds i set it so that when you reachh the end of the area it goes to a different area.
Because it changes area but not at the end of the area do you get what im saying?
Please send a fla. of the correct way to do this with 8 areas if it's no trouble to you:)
Thanx in advance!
nathan99
June 25th, 2006, 12:39 AM
uhhh... what? :P
Stilianos
June 25th, 2006, 12:50 AM
To be quick lets just say i want you to post a fla with every thing working perfectly:)
(8 sections of switching) eg my character moves to the edge of the screen and switches section, character moves to the edge of the screen and switches section. for eight times.
If you dont get what im saying just do what i said in the first line:)
THANX IN ADVANCE
Stilianos
June 25th, 2006, 08:03 PM
NATHAN99 umm can you still help me on the obove?
nathan99
June 26th, 2006, 06:14 AM
haha, still dont get ya
Stilianos
June 26th, 2006, 06:19 AM
A while back you submitted a swf. of your coordinates working properly.
Can you send me the fla so a can study the way you did it:)
Thanx in advance:}
SacrificialLamb
June 26th, 2006, 07:50 AM
here is a FLA with the code i made working
And yes I was ignoring you because I thought it was simple enough that you should be able to work it out yourself
What joppe had done would not have been working because you named the map “ground” and I named it “map” but it was in the right place.
If you could not work that out by your self I seriously doubt your ability to make this game
I have not been able to get the code nathan99 provided to work it will not move to the right or left with out jumping up in the _y I think it has some thing to do with the “arguments[3]” or that changes on the _x send both _x and _y info to the moveMap function but his script is beyond me.
Stilianos
June 26th, 2006, 07:53 AM
O..k
Thanx anyways:)
Stilianos
June 26th, 2006, 08:01 AM
Dude you are the coolest it works great n every thing.
And thanx for not giving up on me these past few dayz:)
nathan99
June 26th, 2006, 10:06 AM
uhhh :look:
SacrificialLamb
June 26th, 2006, 06:07 PM
nathan99: will if that was meant to fix it, it dose not work for me, the exact same problem occurs. it is likely to be a Flash player problem then.
nathan99
June 26th, 2006, 08:31 PM
haha, what IS the problem ? :lol:
SacrificialLamb
June 26th, 2006, 10:20 PM
when i try to go to the left i end up on the left but on top of the left side and when I move from left to right I end up on the top of the right side and entire Stage.height to high
Stilianos
June 29th, 2006, 10:58 PM
I have come back with a very wierd problem.
You will understand with the swf.
Why doesent the mc follow me properly?
Dont worry about them being in the air i can fix that myself.
Thanx in advance.
Stilianos
June 29th, 2006, 10:59 PM
Here it is.
SacrificialLamb
June 29th, 2006, 11:18 PM
I have come back with a very wierd problem.
You will understand with the swf.
Why doesent the mc follow me properly?
Dont worry about them being in the air i can fix that myself.
Thanx in advance.
I am interested in knowing with no code or fla file how are you expecting anyone to be able to help you
Stilianos
June 30th, 2006, 10:05 PM
It is hard to explain but the code works perfectly if the mc's are on the same level but not on a different level.
EG: I have an mc(1) on the stage. i have another mc(2) on the stage and mc(2) has the rotation code. rotaion works.
EG2: I have one mc(1) on the stage and another mc(2) on the stage.
instead of putting the code in mc(2) i put it in an mc in mc(2). the code doesn't work
SacrificialLamb
June 30th, 2006, 11:11 PM
It’ll probably have some thing to do with linking the MC’s. But I can’t tell because I can’t see your code.
Did you not get the not so subtle hint in the post before that to help you, you will need to post the code that need’s to be fixed/inspected
Stilianos
June 30th, 2006, 11:47 PM
Im sorry but i cant post a fla. not even a zipped fla. because it is .6 kb over
woad
July 1st, 2006, 12:02 AM
Use savefile.com or your favorite file hoster
INSANE SYTH
July 1st, 2006, 12:19 AM
i think i know what your problem is...
does your code look somthing like this:
dx = _x - _root.character._x;
dy = _y - _root.character._y;
_rotation = -Math.atan2(dy, dx);
you may have the dy and dx in the wrong order, contrary to what the little flash help thing says.
try swapping them.
also make sure that dx, dy have the right values.
Stilianos
July 1st, 2006, 10:28 PM
Ok here it is. http://www.savefile.com/files/4095727
Thanx for the savefile tip WOAD:)
Hope you can all help.
Thanx in advance.
woad
July 2nd, 2006, 02:45 PM
Np :player:
Stilianos
July 2nd, 2006, 11:14 PM
Umm.. can any one help with my problem i uploaded the link!
Thanx in advance!
SacrificialLamb
July 3rd, 2006, 03:58 AM
it's the arem thing right
onClipEvent(enterFrame)
{
var myPoint:Object = {x:_root.peer.peerA._x, y:_root.peer.peerA._y}
rx = _root.man._x
ry = _root.man._y
this.localToGlobal (myPoint)
this._rotation = (Math.atan2((rx-myPoint.x),(ry-myPoint.y))*180/Math.PI)+90
}
the problim was it was useing local x and y not Global so just changed that.
Stilianos
July 3rd, 2006, 06:12 AM
Whew that was realy good.
But as always i have another question.
The script ws soo great that i used it on my man.
but when my character turns to the right the rotation script is backwards check it out.
Stilianos
July 4th, 2006, 04:52 AM
Sacrifitiallamb can u fix my problem?
If not is there anyone out there?
Thanx in advance:)
SacrificialLamb
July 4th, 2006, 07:58 AM
Other than you’re code on the man was working, why would you change it to some thing nearly identical? I based my code on what you had, that need I remind you worked.
When dealing with math I like the educated guess method combined with brute strength. To work out how to fix this I did not work out WTF was going on I started but adding a “-“ in front, that looks to have helped to work and because that look’s ugly in the code and I know from experience I switched the x and y values and took the “-“ away. Then there was a spiel angle problem so I just added 180 at the end and :o it worked. My point being; did you even try to work this out by your self?
Stilianos
July 5th, 2006, 02:12 AM
no:)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.