Monster Racer Rush
Select between 5 monster racers, upgrade your monster skill and win the competition!
4.23 / 5.00 3,881 ViewsBuild and Base
Build most powerful forces, unleash hordes of monster and control your soldiers!
3.93 / 5.00 4,634 ViewsHello
as of right now my character can walk to the far enough right that you are no longer on the stage.
What is the most efficient way to establish a stage limit?
I understand this is something best applied to the Left and Right movement commands. If need be i would be willing to share my code.
Assuming your stage has a width of 550 for example, you could simply do:
if(player._x > 550) player._x = 550
if(player._x < 0) player._x = 0 At 3/8/13 02:46 AM, 4urentertainment wrote: Assuming your stage has a width of 550 for example, you could simply do:
if(player._x > 550) player._x = 550
if(player._x < 0) player._x = 0
not to sound stupid but is this its own event or is this applied to the left and right controls?
At 3/8/13 02:55 AM, BaronVonBroccoli wrote:At 3/8/13 02:46 AM, 4urentertainment wrote: Assuming your stage has a width of 550 for example, you could simply do:not to sound stupid but is this its own event or is this applied to the left and right controls?
if(player._x > 550) player._x = 550
if(player._x < 0) player._x = 0
I'm not exactly sure you would "apply it to left and right controls", but you could add it after your movement code, so that the player moves, and then you check if he is within bounds, and if not, bring him back.
Feel free to post your code if you're still having doubts, or just want to make sure you're doing it right.
At 3/8/13 04:01 AM, 4urentertainment wrote:At 3/8/13 02:55 AM, BaronVonBroccoli wrote:I'm not exactly sure you would "apply it to left and right controls", but you could add it after your movement code, so that the player moves, and then you check if he is within bounds, and if not, bring him back.At 3/8/13 02:46 AM, 4urentertainment wrote: Assuming your stage has a width of 550 for example, you could simply do:not to sound stupid but is this its own event or is this applied to the left and right controls?
if(player._x > 550) player._x = 550
if(player._x < 0) player._x = 0
Feel free to post your code if you're still having doubts, or just want to make sure you're doing it right.
absolutely. thank you
I am trying to be as non reliant as possible on this whole project, but this is literally my last code based hurdle and i just want to be done so i can move onto the aesthetic/thematic end
heres my mov clips movement script
if (Key.isDown(Key.LEFT)) {
if (speed>-maxmove) {
speed--;
if (char._x > 800) char._x = 800;
if (char._x < 0) char._x=0;
}
this.gotoAndStop("run");
this._xscale = -100;
} else if (Key.isDown(Key.RIGHT)) {
if (speed<maxmove) {
speed++;
if (char._x > 800) char._x = 800;
if (char._x < 0) char._x=0;
}
this._xscale = 100;
this.gotoAndStop("run");
} else if (Key.isDown(65)) {
this.gotoAndStop("attack");
attacking = true;
speed = 0;
} else if (speed<1 && speed>-1 && !attacking) {
speed = 0;
this.gotoAndStop("idle");
}
In the code you posted, you never actually move the player. All you do is change the speed. I'm guessing you have another part of the code where you do:
char._x += speed;
That's where you move the player. So you need to add the if statements after this, to make sure the character remains within bounds.
Also, if you want to use code tags, just do:
<code*>
Your code here
</code*>
But remove the *.
At 3/8/13 06:29 AM, 4urentertainment wrote: In the code you posted, you never actually move the player. All you do is change the speed. I'm guessing you have another part of the code where you do:
char._x += speed;
That's where you move the player. So you need to add the if statements after this, to make sure the character remains within bounds.
Also, if you want to use code tags, just do:
<code*>
Your code here
</code*>
But remove the *.
you know what your right, thats what i get for copyand pasting at 4am. I was attempting to spare you the groundhit test/score/health and all that other stuff, must have cut off a bit too much.
thank you
At 3/8/13 08:50 AM, BaronVonBroccoli wrote:At 3/8/13 06:29 AM, 4urentertainment wrote: In the code you posted, you never actually move the player. All you do is change the speed. I'm guessing you have another part of the code where you do:you know what your right, thats what i get for copyand pasting at 4am. I was attempting to spare you the groundhit test/score/health and all that other stuff, must have cut off a bit too much.
char._x += speed;
That's where you move the player. So you need to add the if statements after this, to make sure the character remains within bounds.
Also, if you want to use code tags, just do:
<code*>
Your code here
</code*>
But remove the *.
thank you
For what ever reason it is still not working.... see below also if anyone has an easier way to achieve most of whats below please let me know, this is a montage of a college text book from 2004 & 2 internet tutorials so most likely its redundant or there is an easier way to achieve the same goal
onClipEvent (load) {
jumping = false;
speed = 0;
Xpos = this._x;
Ypos = this._y;
maxmove = 15;
}
onClipEvent (enterFrame) {
_x = Xpos-_root._x;
if (!_root.ground.hitTest(this._x, this._y, true) && !jumping) {
this._y += 55;
}
if (_root.dead) {
this.gotoAndStop("dead");
} else {
speed *= .85;
//left walls
if (dir == "right" && !_root.leftblock.hitTest(this._x+20, this._y, true)) {
_root.health._x += speed;
_root.score._x += speed;
this._x += speed;
_root._x -= speed;
}
if (speed>0) {
dir = "right";
} else if (speed<0) {
dir = "left";
}
//right walls
if (dir == "left" && !_root.rightblock.hitTest(this._x-20, this._y, true)) {
_root.health._x += speed;
_root.score._x += speed;
this._x += speed;
}
if (Key.isDown(Key.LEFT)) {
if (speed>-maxmove) {
speed--;
}
this.gotoAndStop("run");
this._xscale = -100;
} else if (Key.isDown(Key.RIGHT)) {
if (speed<maxmove) {
speed++;
if(this._x > 800) this._x = 800
if(this._x < 0) this._x=0;
}
this._xscale = 100;
this.gotoAndStop("run");
//punch
} else if (Key.isDown(65)) {
this.gotoAndStop("attack");
attacking = true;
speed = 0;
//punch
} else if (speed<1 && speed>-1 && !attacking) {
speed = 0;
this.gotoAndStop("idle");
}
if (Key.isDown(Key.UP) && !jumping) {
jumping = true;
}
if (jumping) {
this.gotoAndStop("jump");
this._y -= jump;
jump -= .5;
if (jump<0) {
falling = true;
}
if (jump<-15) {
jump = -8;
}
}
//ground
if (_root.ground.hitTest(this._x, this._y, true) && falling) {
jump = 12;
jumping = false;
falling = false;
}
//end ground
}
}
//punch 2
onClipEvent (keyUp) {
if (Key.getCode() == 65) {
attacking = false;
}
}
//punch 2 At 3/8/13 09:37 AM, BaronVonBroccoli wrote: For what ever reason it is still not working.... see below also if anyone has an easier way to achieve most of whats below please let me know
Apply the movement, then just run the tests mentioned by 4urentertainment
this is a montage of a college text book from 2004 & 2 internet tutorials so most likely its redundant or there is an easier way to achieve the same goal
As said before: Stop copy&pasting code, especially if it's as old as this code.
At 3/8/13 10:20 AM, milchreis wrote:At 3/8/13 09:37 AM, BaronVonBroccoli wrote: For what ever reason it is still not working.... see below also if anyone has an easier way to achieve most of whats below please let me knowApply the movement, then just run the tests mentioned by 4urentertainment
this is a montage of a college text book from 2004 & 2 internet tutorials so most likely its redundant or there is an easier way to achieve the same goalAs said before: Stop copy&pasting code, especially if it's as old as this code.
crap i copied the script without the newcode.
and i know your right, but until I can get either comfortable with another flash editor or the cash to shell out for a non student copy/newer version i'm stuck with this.
At 3/8/13 10:31 AM, BaronVonBroccoli wrote: and i know your right, but until I can get either comfortable with another flash editor or the cash to shell out for a non student copy/newer version i'm stuck with this.
Nobody forces you to write code on symbols.
A code editor is as complicated as a text editor.
What you're not comfortable with is learning how to code and writing it yourself. If you're going to steal other peoples code and not bother to take advice when people offer it don't bring your problems here.
At 3/8/13 10:47 AM, MintPaw wrote: What you're not comfortable with is learning how to code and writing it yourself. If you're going to steal other peoples code and not bother to take advice when people offer it don't bring your problems here.
what i was referencing by not being comfortable with was the layout of programs like flash developer vs adobe flash
specifically the ability to visually associate everything right then and there, and then define it as a mov and then apply code.
and no one is ignoring anyones advice, I took it into consideration, and if i do anything else outside of this one game, yes i will focus more on as3. For the simple project I am doing i am sticking with what i have, especially considering i am the only one who will ever play it.
At 3/8/13 10:47 AM, MintPaw wrote: What you're not comfortable with is learning how to code and writing it yourself. If you're going to steal other peoples code and not bother to take advice when people offer it don't bring your problems here.
hey i wanted to apologize if thats even needed, you were right I was wrong.
I scrapped my whole game starting from scratch and ensuring that everything is of my own doing.
i'll bug you guys in a month or so if i have any issues when (hopefully) get everything back up to where it currently is with the copy and paste amalgamation of doom.
well you are starting again so here is some useful stuff:
please dont code in symbols, just code in the first frame.
when coding in the 1st frame you can use onEnterFrame = function(){
You can refer to movie clips via their instance names
try to learn about arrays, it shortens your code
try to learn about functions too, it shortens your code
At 3/9/13 04:27 PM, flashMan wrote: You can refer to movie clips via their instance names
This. I advise against.
Although it's all about how much you care, like, if it's just a school project and you don't really care about Flash or programming then you can do it how you want, but the more you actually care about programming the more strict you can be.
at this point this project is to prove to my self that i can do it. nothing more no end game outside of that.
I am just getting overwhelmingly frustrated because i built a couple games back in college (1 platformer 1 trivia 1 space invaders/defender clone) in college and was fine, that was 7 years ago though and its irritatingly rough to get back into this
i didnt think this was worth starting a new thread over, and i promise this is the last post in this thread from me
how reliable do these tutorials look
http://www.makeflashgames.com/gamedesign/replayability.php
i like the idea that each tutorial gets progressively more complicated while still working off of reoccuring concepts.
In addition to flashMan's advice, don't use _root. Also, always declare variables. I couldn't see any var statements, so I guess you either put them somewhere else or didn't use them.
var myVariable:Type;
By the way, Stage.width and Stage.height are the stage width and stage height in AS2.
Hope this helps. ;)