Page 1 of 2 12 LastLast
Results 1 to 15 of 27

Thread: help with tis problem

  1. #1

    help with tis problem

    hi,i am doing a maze game. i am trying to make and enemy which will move randomly and when it touches/hits my hero it will go to another keyframe which says game over. i have tried a few times but my enemy could only move forward, can anyone help me with it??

    thx. i got the fla file attached.
    <!-- / message --><!-- attachments -->
    Attached Files Attached Files

  2. #2
    Quote Originally Posted by keller
    hi,i am doing a maze game. i am trying to make and enemy which will move randomly and when it touches/hits my hero it will go to another keyframe which says game over. i have tried a few times but my enemy could only move forward, can anyone help me with it??

    thx. i got the fla file attached.
    <!-- / message --><!-- attachments -->
    anyone can help

  3. #3
    Quote Originally Posted by keller
    anyone can help
    Really need ur help

  4. #4
    when i tried ur fla i couldn't get the enemy to move at all, also u seem to be using a tile based engine with art based buildings (did u get these ideas from tonypa or similar). the problem with ur enemy is that he can't tell if he's going to hit something.
    With art based there's not really anyway to do this easily, this is because u can't check in advanced if something is going to hitTest == true with something until it happens.
    The way to do this is to have four surrounding invisible squares around ur mc, have them called top, left, right and down. Then u have to go
    if(_root.ball.top.hitTest(wall._x, wall._y, true){//<-- sorry i can't remember how to do hitTest, because i don't use them
    //need to make new direction
    number = Math.ceiling(Math.random()*3);
    if(number == 1){
    //heads down
    _root.ball._y += 5;
    }
    if(number == 2){
    _root.ball._x -= 5;
    }
    if(number == 3){
    _root.ball._x += 5;
    }
    }

    do u get what i mean, and u'd have to do something like this for all four sides, it'll get kindof messy.

    What i'd recommend is going back to tonypa's tutes and just use the tile-based method, that he's already made and just 'borrow' his.


    BTW please put a better title for threads i had know idea what this was about, like 'help with AI for maze' or similar.
    And also many ppl don't have MX2004 so either save it in MX format or submit ur problem code and u (should) get quicker responses

  5. #5
    Quote Originally Posted by Dr Warm
    when i tried ur fla i couldn't get the enemy to move at all, also u seem to be using a tile based engine with art based buildings (did u get these ideas from tonypa or similar). the problem with ur enemy is that he can't tell if he's going to hit something.
    With art based there's not really anyway to do this easily, this is because u can't check in advanced if something is going to hitTest == true with something until it happens.
    The way to do this is to have four surrounding invisible squares around ur mc, have them called top, left, right and down. Then u have to go
    if(_root.ball.top.hitTest(wall._x, wall._y, true){//<-- sorry i can't remember how to do hitTest, because i don't use them
    //need to make new direction
    number = Math.ceiling(Math.random()*3);
    if(number == 1){
    //heads down
    _root.ball._y += 5;
    }
    if(number == 2){
    _root.ball._x -= 5;
    }
    if(number == 3){
    _root.ball._x += 5;
    }
    }

    do u get what i mean, and u'd have to do something like this for all four sides, it'll get kindof messy.

    What i'd recommend is going back to tonypa's tutes and just use the tile-based method, that he's already made and just 'borrow' his.


    BTW please put a better title for threads i had know idea what this was about, like 'help with AI for maze' or similar.
    And also many ppl don't have MX2004 so either save it in MX format or submit ur problem code and u (should) get quicker responses
    Ok,thank a lot.i try to use the tile-based method to do.if still can't,i will ask u ok?thanks..

  6. #6
    Quote Originally Posted by keller
    Ok,thank a lot.i try to use the tile-based method to do.if still can't,i will ask u ok?thanks..
    Anyone got another method to solve my problem....must tell me ok.

  7. #7
    Quote Originally Posted by keller
    Anyone got another method to solve my problem....must tell me ok.
    Sorry,i still can't understand the tile-based method,coz if i use tat method i wan change a lot of thing.Do u and ur have another method?

  8. #8
    yeah for the tile based method u will have to change a few of ur things, but once u've changed them, if u want to change other things, it's easier just change a 0 to a 1 in an array etc. that's why i prefer this method

    i think if u want to make AI with art based u'll have to devise your own method, because i can't think of any source that i have that will help you. But to start off with u'll need to do what i said before, with the four invisible boxes around the enemy for the hitTests.

  9. #9
    Quote Originally Posted by Dr Warm
    yeah for the tile based method u will have to change a few of ur things, but once u've changed them, if u want to change other things, it's easier just change a 0 to a 1 in an array etc. that's why i prefer this method

    i think if u want to make AI with art based u'll have to devise your own method, because i can't think of any source that i have that will help you. But to start off with u'll need to do what i said before, with the four invisible boxes around the enemy for the hitTests.
    ok thanks.i ll try my best.but if u or ur got another idea must tell me ok.thank a lot.

  10. #10
    i looked again at ur fla, but i don't really understand how it works, maybe there's a new function that i've not looked at thats in MX2004, but i don't understand it.

    in ur _root.onEnterFrame function for the character, when u have:
    if(Key.onDown(Key.RIGHT)){
    CheckXY(something);
    }
    i can't seem to work out how the checkXY works! could u explain it to me, cos u could probably use this function for the enemy as well

  11. #11
    Quote Originally Posted by Dr Warm
    i looked again at ur fla, but i don't really understand how it works, maybe there's a new function that i've not looked at thats in MX2004, but i don't understand it.

    in ur _root.onEnterFrame function for the character, when u have:
    if(Key.onDown(Key.RIGHT)){
    CheckXY(something);
    }
    i can't seem to work out how the checkXY works! could u explain it to me, cos u could probably use this function for the enemy as well
    em...1st i write a function call function CheckXY(x,y){},u can see in my fla file.After that,i write _root.onEnterFrame function,So we no need write
    if(Key.onDown(Key.RIGHT)){
    CheckXY(something);
    }
    in MC of red.
    So if(Key.onDown(Key.RIGHT)){CheckXY(1,0)},the 1 is x-axis,and is positive value,so the object will go right when i press the right arrow key.Can u understand?And When CheckXY(0,1),that mean y-axis is positive.

  12. #12
    no i get that bit, i just don't get how it see's what's to the left and right up and down, does it have something to do with u creating the tiles at the start, or is that only for the letters?

  13. #13
    Quote Originally Posted by Dr Warm
    no i get that bit, i just don't get how it see's what's to the left and right up and down, does it have something to do with u creating the tiles at the start, or is that only for the letters?
    left,right,up and down is for control my hero...So all i explain to u is only for my hero not the letter,Can get it?The purpose i write the function and the _root EnterFrame function is want use the arrow key to control my hero,so it will move around the maze when i press the up,dwon,left and rigth arrow key.Can get it?

  14. #14
    No that's not what i mean, i'll take another look at ur fla and see for myself (it's been about a week or two can't quite remember)

  15. #15
    Quote Originally Posted by Dr Warm
    No that's not what i mean, i'll take another look at ur fla and see for myself (it's been about a week or two can't quite remember)
    ok....but my game will pass to my lecturer after 2week.em....u knw how to use xml?Coz i never learn tis before.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012