Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: Collision Problem in My game? (action script)  (Read 1994 times)

0 Members and 1 Guest are viewing this topic.
Collision Problem in My game? (action script)
« on: June 07, 2008, 01:43:59 am »
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 101
--------------------------------------------------------------------------------
I am having some issues with collision detection in my upcoming game "The Guardian" and I was hoping someone here could help me out?

Sometimes the main char can get stuck in the walls and the collision isnt as accurate as I wanted. If anyone can help please reply here.

Here is the code for the collision. It is on the main character and everything that we are hitTesting is withing the walls movie clip.

onClipEvent (load) {
   this._name = "hiro";
   _root.RUN = 6;
}
onClipEvent (enterFrame) {
   if (Key.isDown(Key.RIGHT)) {
      if (_root.Walls.hitTest(getBounds(_root).xMax, _y, true)&&_root.hiroalive && !_root.hirohurt) {
         _root.pushes = true;
      } else {
         if (_root.pause == false and _root.attack == false &&_root.hiroalive && !_root.hirohurt) {
            this._x += _root.RUN;
            _root.pushes = false;
         }
      }
   } else if (Key.isDown(Key.LEFT)) {
      if (_root.Walls.hitTest(getBounds(_root).xMin, _y, true) &&_root.hiroalive && !_root.hirohurt) {
      _root.pushes = true;
      } else {
         if (_root.pause == false and _root.attack == false &&_root.hiroalive && !_root.hirohurt) {
            _root.pushes = false;
            this._x -= _root.RUN;
         }
      }
   }
   if (Key.isDown(Key.DOWN)) {
      if (_root.Walls.hitTest(_x, getBounds(_root).yMax, true) &&_root.hiroalive && !_root.hirohurt) {
      _root.pushes = true;
      } else {
         if (_root.pause == false and _root.attack == false &&_root.hiroalive && !_root.hirohurt) {
            _root.pushes = false;
            this._y += _root.RUN;
         }
      }
   } else if (Key.isDown(Key.UP)) {
      if (_root.Walls.hitTest(_x, getBounds(_root).yMin, true) &&_root.hiroalive && !_root.hirohurt) {
      _root.pushes = true;
      } else {
         if (_root.pause == false and _root.attack == false &&_root.hiroalive && !_root.hirohurt) {
            _root.pushes = false;
            this._y -= _root.RUN;
         }
      }
   }
}
 
Logged


  • The Untold Legacy
Re: Collision Problem in My game? (action script...
« Reply #1 on: June 07, 2008, 02:11:20 am »
  • :'O
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 929
Your using action script? Not many people here are skilled with Flash and action script. I don't think anybody is.

Except for akim but he doesn't come on much.
« Last Edit: June 07, 2008, 02:16:11 am by Ali »
Logged
Re: Collision Problem in My game? (action script...
« Reply #2 on: June 07, 2008, 02:41:47 am »
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 101
Yea, its what I know. I just know a little basic and such besides that. But all my games are made in flash up to this point, but if he gets on hopefully he can help. It should be a fixable problem. I just dont know how to fix it.
Logged


  • The Untold Legacy
Re: Collision Problem in My game? (action script...
« Reply #3 on: June 07, 2008, 02:47:57 am »
  • :'O
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 929
Mit, and Atrius from KousouGames come here. I know they made this kickass flash game with awesome collision tracking.

http://kousougames.com/

Ask them there
Logged

CrystalAngel04

Resident ZFGC female
Re: Collision Problem in My game? (action script...
« Reply #4 on: June 07, 2008, 02:51:37 am »
  • \\*Caution*\\ The Internets: May contain Women
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Female
  • Posts: 1323
I'm gonna move this to Discussion then delete the other topic... there really is no need for duplicate topics, k?
Logged
  • -= Crystal Angel Creations =-
Re: Collision Problem in My game? (action script...
« Reply #5 on: June 07, 2008, 03:39:35 am »
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 101
Okay ill give em a try.
Logged


  • The Untold Legacy
Re: Collision Problem in My game? (action script...
« Reply #6 on: June 07, 2008, 03:45:51 am »
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 101
Okay I dont really know what im looking for here. What was the game called they made?
Logged


  • The Untold Legacy
Re: Collision Problem in My game? (action script...
« Reply #7 on: June 07, 2008, 02:31:14 pm »
  • Fear my Blades
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 562
It was just a walking demo with graphics borrowed from Golden Sun (for now).  Flash version 9 or later required.

That demo uses a mathematical method to check for collisions since they're incredibly tile based.


I believe hitTest only checks a single pixel for a collision.  You should at least check both corners of the side in the direction your object is moving, that could still miss some collisions though so you may need to check more pixels along the side.  You shouldn't need to check every single one though, unless you have pixel thin walls.
Logged

I've done it (sorta)!  Bloom Lighting in GameMaker, and 3D mode too!  Check out the awesome Screen Saver.
  • Kousou Games
Re: Collision Problem in My game? (action script...
« Reply #8 on: June 07, 2008, 03:06:23 pm »
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 101
Im using hitTest with shapeflags. But I need something more accurate though.
Logged


  • The Untold Legacy
Re: Collision Problem in My game? (action script...
« Reply #9 on: June 07, 2008, 03:28:05 pm »
  • Fear my Blades
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 562
Hmm... Actually come to think of it, the arguments you gave to your hitTest function aren't at all what the one I'm thinking of should take.  Is it your own custom function, what does it look like?  It still looks like you're only passing a single point for the player though, if that's the case what I said still applies.
Logged

I've done it (sorta)!  Bloom Lighting in GameMaker, and 3D mode too!  Check out the awesome Screen Saver.
  • Kousou Games
Re: Collision Problem in My game? (action script...
« Reply #10 on: June 07, 2008, 03:37:59 pm »
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 101
 This is suppose to find the x and y shape of everything in the walls movie clip, it works, but not all the time. =( I can get stuck in walls and walk over things sometimes. So I need a better method or something. Do you think you could possibly lend a hand for help? All the code is on the main char and its refering to one movie clip called "Walls"
Logged


  • The Untold Legacy
Re: Collision Problem in My game? (action script...
« Reply #11 on: June 07, 2008, 03:47:04 pm »
  • Fear my Blades
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 562
I doubt it...  I don't actually have a Flash editor, I did all my coding in notepad, and used a command line compiler.  Also I'm going to be really busy the next couple of weeks.  My little brother is graduating from high school in a couple days, and I'm moving out of town soon after that.  I might be able to help after I get settled, but it'll be a while...
Logged

I've done it (sorta)!  Bloom Lighting in GameMaker, and 3D mode too!  Check out the awesome Screen Saver.
  • Kousou Games
Re: Collision Problem in My game? (action script...
« Reply #12 on: June 07, 2008, 04:06:19 pm »
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 101
A line compliler? You mean you wrote the code in a different language and it was changed to action script? Or am I wrong?
Logged


  • The Untold Legacy
Re: Collision Problem in My game? (action script...
« Reply #13 on: June 07, 2008, 04:09:10 pm »
  • Fear my Blades
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 562
Command line compiler, like a DOS program that compiled the actionscript code into a .swf file.
Logged

I've done it (sorta)!  Bloom Lighting in GameMaker, and 3D mode too!  Check out the awesome Screen Saver.
  • Kousou Games
Re: Collision Problem in My game? (action script...
« Reply #14 on: June 07, 2008, 04:22:19 pm »
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 101
 So that was all coded? Interesting. That must have been difficult without being able to see everything. But yea ive seen it done before, but not on notepad. lol How did you learn action script without ever getting flash. Maybe a class. Everything I know is self taught. Its been 3 years since I started so i guess im doing pretty good. Still havent mastered collisions yet.
Logged


  • The Untold Legacy
Re: Collision Problem in My game? (action script...
« Reply #15 on: June 07, 2008, 04:43:28 pm »
  • Fear my Blades
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 562
I'm self taught too, though I have a book on it.  I've only been working in AS3 for about 6 months.  I already have a lot of experience with other programming languages though, and most of the concepts transfer over pretty easily once you have a grasp of the basics.


Edit:
Also, I check the official language reference a lot.
« Last Edit: June 07, 2008, 04:50:56 pm by Atrius »
Logged

I've done it (sorta)!  Bloom Lighting in GameMaker, and 3D mode too!  Check out the awesome Screen Saver.
  • Kousou Games
Re: Collision Problem in My game? (action script...
« Reply #16 on: June 07, 2008, 05:20:45 pm »
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 101
 Yea I noticed that while looking over other languages. I just use AS2 I have never had a book. lol
I wish I did. I started wanting to make cartoons in flash, but I wanted to make it interactive using buttons and thats how it all began, but I plan on starting college soon ( for game programming ) so that probably will help too.
Logged


  • The Untold Legacy
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.064 seconds with 72 queries.