AmirOssanloo

Members
  • Content count

    4
  • Joined

  • Last visited

Community Reputation

128 Neutral

About AmirOssanloo

  • Rank
    Newbie
  1. Projectile hitTestObject bugg?

    Is it possible to delete a post? I think the problem was simply that my break; is in the wrong place. I always break on the first loop, it should be inside the if-statement.
  2. Projectile hitTestObject bugg?

    Hi,   Actionscript 3 problem incoming!   I have some problems with my projectiles. It seems like my hitTestObject sometimes fires more then once... I don't understand why since I destroy the projectile once it has reached it's target.   The projectile state is updated in the gameloop once it has been created. And is removed (from the vector) once it is destroyed. /** * Update projectile state. */ public function update():void { // If projectile do not have a target. if (target == null) { destroy(); return; } // Calculate movement and rotation. var dx:Number = target.x - x; var dy:Number = target.y - y; var radians:Number = Math.atan2(dy, dx); var degrees:Number = Math.round((radians * 180 / Math.PI)); // Set movement and rotation. this.x += Math.cos(radians) * _speed; this.y += Math.sin(radians) * _speed; this.rotation = degrees; // Check collosion towards target. if (this.hitTestObject(target)) { target.onHit(this); destroy(); } } /** * Destroy projectile. */ public function destroy():void { for (var i:int = 0; i < _projectileManager.projectiles.length; i++) { if (_projectileManager.projectiles[i] == this) { _projectileManager.projectiles.splice(i, 1); this.parent.removeChild(this); target = null; } break; } } If I put a trace inside the if collision statement I can see that it is fired a lof of times (sometimes)... How can this not be reliable? If it checks for collision and then is destroyed once the collision has occured - then why would the if statement go trough more then once.   Thanks!   Edit: Topic should be with one g in bugg!
  3. How to manage controls?

    To answer my own question I found a very good article on exactly what I needed: http://www.gamasutra.com/view/feature/2280/the_guerrilla_guide_to_game_code.php
  4. An Open Letter to Young Programmers

    This morning I received sourcefiles for a project that needs to be finished before friday. There are some objects named "F", "h", "g", "D". And I have no idea why :'(. Half the variable and method names are in Dutch while half are English... I have 3 functions named "move1", "move2", "move3". But "move1" has no indication for movement of any object what-so-ever. Then I have other stuff named "something", "Something1", "SomethingNew". And there isn't a single line of comments.   I will deliver the project together with a link to this article.   F*** my life :'(.
  5. How to manage controls?

    Hi,   I am creating this game in AS3 (I know) in MVC and I bumped into a bit problems with understanding how to structure my entities.   So I have my EntityModel, EntityView and EntityController that will be the parent classes for all my entities. Then I have my Enemies and lets call them Allies classes that extend the Entity classes.   My EntityModel class is currently quite empty. I assume that this is where I will have functions such as attack(), move() and such. My EntityView displays the graphics and I have added event listeners here that checks if the mouse button is clicked or not. _stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDownHandler); private function onMouseDownHandler(e:MouseEvent):void { _controller.processMouseDown(e); } In my EntityController class I have prepared to process the mouse down button. But this is where things get confusing for me because when I try in EnemyGruntController extend EntityController to override this processMouseDown. I get an error "Method marked override must override another method. override internal function processKeyDown(e:KeyboardEvent):void"". It seems like I can't override this function, but I want to give different units different commands on MouseDown. internal function processMouseDown(e:MouseEvent):void { // Process mouse down commands. } I've spent a few days googling on MVC and what class should do what, but it is very hard to comprehend in the beginning. So is there anyone that have a good example of a simple game or class structure that resembles this:   [attachment=18268:structure.jpg]   Thanks and sorry for the vauge post.