Mouse game Ivan's Beta Game 5000

15 posts

Flag Post

onClipEvent (enterFrame) {
if (root.dude, hitTest(root.end)) {
_root.gotoAndPlay(5);
} else {
play();
}
}

here is the basic code im using, my porblem is where you open my maze editor section and create it, but the problem is when you tocuh the walls, all the maze dissapears and you have to start again. how can i make a position reset command so that when you touch the wall it wont dissapear and just reset the “dude” position.
the url of my game : http://www.kongregate.com/games/ivanmalo/ivans-beta-game-5000

 
Flag Post

That code basically is saying. If you touch a wall, goto frame 5, which i’m guessing is the main menu? Otherwise keep playing (which is something you don’t need btw, it will automatically keep playing unless you call stop() ). What you want is to set two variables in the beginning of the frame (or wherever you’re doing this, looks like some movieclip) called xStart and yStart. Make these variables the x and y of where the guy starts. Then replace the bad code with:

if(_root.dude.hitTest(_root.end)) 
{
_root.dude._x = xStart;
_root.dude._y = yStart;
}

That should fix it.

 
Flag Post

how do i set those variables?

 
Flag Post

I told you this in chat. But I’ll say it again and give you exact code.

onClipEvent(load)
{
xStart = 139; //139 is just a number I made up, replace it .
yStart = 139; //Again a number I made up
}
onClipEvent(enterFrame)
{
if(_root.dude.hitTest(_root.end)) 
{ 
_root.dude._x = xStart; _root.dude._y = yStart; 
}
}

Hah, pre is good. But they definately need to add it to the formatting help at right.

 
Flag Post

Thanks, but i tried and it doesnt;t work, here is it how it works, i made a mclip which contained the animation the converted it to a button which said that on press the guy shoulf follow on(press) {
this.onEnterFrame = function () {
dude._x = xmouse ;
dude.
y = _ymouse ;
}
}

and then converted it on a movie vlip which said this code *
onClipEvent (enterFrame)
if(root.dude.hitTest(root.end))
{
_root.gotoAndPlay(5);
}else {
play();
}
} *
so if i use what us said it wont go there because even if it went to that position it would quickly go back to follow the mouse, so what i need is to make the following to stop and position it.

 
Flag Post

Stop the drag. I forgot about that in my last posts. But yeah. You started the drag. Now stop it. On probably want to turn the mouse back on (visibility).

 
Flag Post

bow do i stop drag?

 
Flag Post

stopDrag();
That’s all.

 
Flag Post

how* and woad i can send you a .fla file so you looke how im working, it wont be the actual game but a replic…

 
Flag Post

Making games takes a lot of work and skill, but also some knowledge about ActionScript. It’s only my opinion, but it would be good for you to at least learn the basic ActionScript stuff (things like MovieClip.stopDrag(), for instance) before attempting something as complex as a game. My philosophy is, get a good book, and start simple. That’s how I learned.

 
Flag Post

I agree with Indie, in that you need to look into stuff like dragging yourself and not keep asking how to do it. Go online and search up flash custom cursor tutorial or something. But you should definately keep working on the game.

 
Flag Post

I know i must learn actionscript, thats why im making this game, a way less boring to learn, and im learning fast.

 
Flag Post

That’s good, Ivan. =P It’s good to have a project to work on.

You asked me a few days ago in chat how you would implement a key control of your game. Here is some generic actionscript that you can plug into your game’s onEnterFrame handler (of course, you will need to scope it correctly):

if(Key.isDown(Key.LEFT))
{
  dude._x -= speed;
}
else if(Key.isDown(Key.RIGHT))
{
  dude._x += speed;
}
if(Key.isDown(Key.UP))
{
  dude._y -= speed;
}
else if(Key.isDown(Key.DOWN))
{
  dude._y += speed;
}
 
Flag Post

thanks man im adding it to my game, i got another question…. a circle will have a squar hit area how do i make it so it takes the borders in thecircle and not the square?

 
Flag Post

Well, you will need to know how to calculate the distance of your colliding object from the center of the circle, and then you can use the radius of the circle as a basis for hit testing using distance.

I may write up a tutorial on this in the future…