Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

118 Neutral

About cagdassalur

  • Rank
  1. cagdassalur

    [as3] Trigonometry is confusing

      What in/out behavior? That stopped with the last piece of code. And yeah since that controls somehow close to working i can see how its strange and confusing for the player. I'll stick with the other controls. Thanks for all the help, at least trigonometry is kinda less confusing for me now.    Oh and that's just temporary testing speed i'm gonna nerf it after adding some enemies.
  2. cagdassalur

    [as3] Trigonometry is confusing

    I did this after you wrote the calculations;       starttrx=x-mouse.x; starttry=mouse.y-y; angle=Math.atan2(starttry,starttrx); angle+=vo; newtrx=Math.cos(angle); newtry=Math.sin(angle); uzaklik=Math.sqrt(starttrx*starttrx+starttry*starttry); newtrx*=uzaklik; newtry*=uzaklik; x=mouse.x+newtrx; y=mouse.y-newtry;     And i set the angular velocity(vo) to change when pressed a button, but it's moving crazy fast and still closing in to the cursor after some time. However when i adopted these stuff from another sample angular motion tutorial, the rotation and movement with W/S buttons works. But the ship is moves with cursor. If cursor moves 5 pixels to the right ship moves with it. And the further the ship is to the cursor it moves faster.       var angle:Number=0; var r:int=50; var rad:Number = angle * (Math.PI / 180); x = mouse.x + r * Math.cos(rad); y = mouse.y + r * Math.sin(rad); if(A.pressed) angle-=3; if(W.pressed) r-=5;     here's the updated swf with the code above.   Why this is so hard to achieve? Am i too strange for trying to make this kind of controls? Should i change the mechanics to something a bit easier to do?   edit: I tried another control system you can try it by pressing "4" and it swictches to "control 1". How is that for example?
  3. cagdassalur

    [as3] Trigonometry is confusing

      Exactly. I think im starting the figure out the problem here. Now it doesn't sound much like gibberish when i read something about trigonometry in english.     Surely i can do that, But im having problems with which variable i use are fixed at that frame and which i can change(and how). For example i calculate theta but you are saying i need to change that directly. And for the theta calculation part why you didn't used the mouse locations with ship coordinates? or did you and i missed it because they were (0,0)? From what i understand theta is the angle of the ship from origin, shouldn't i somehow include mouse coordinates too?   Oh and in as3 origin is at top-left.     By the way thanks for all the answers you guys keep posting i haven't got any help from forums in my country. You guys are the best! 
  4. cagdassalur

    [as3] Trigonometry is confusing

    I updated the part to look like this;     vx+= mouse.x+Math.cos(rotation)*distance; vy+= mouse.y+Math.sin(rotation)*distance;   But it's doing that strange thing getting closer and moving away from the mouse afterwards. Couldn't i calculate how much it'll move away and add that to the velocity?   When i use just update x,y coordinates its moving very fast while still closing in to the cursor. So i used vx and vy.
  5. cagdassalur

    [as3] Trigonometry is confusing

      Dont i know the angle already? From the rotation variable?
  6. cagdassalur

    [as3] Trigonometry is confusing

        I updated it yesterday but its still broken. I don't want the ship to move away from the mouse when i'm only pressing "a" or "d" buttons.         I'ts seems nice and cheap gonna check it out thanks!         Uhm.. I'm not very good at english and when its combined with trigonometry it makes no sense to me. I cant understand the last sentence. I can calculate the distance between two points but i dont know what should i do with it.     Edit: By the way sorry for the late response i was waiting to get a mail from gamedev.net informing me when i got some answers, it didnt happen.   Edit2: I uploaded the source here if it helps. Some parts are in turkish but i can translate the source if needed.
  7. cagdassalur

    tic tac toe AI

    You dont necessarily need to use Minimax. Here's the xkcd's optimal tic-tac-toe moves for each player.   And this is the list of rules you need to check if you choose to implement this kind of method(from tic-tac-toe page on wikipedia); Win: If the player has two in a row, they can place a third to get three in a row. Block: If the [opponent] has two in a row, the player must play the third themself to block the opponent. Fork: Creation of an opportunity where the player has two threats to win (two non-blocked lines of 2). Blocking an opponent's fork: Option 1: The player should create two in a row to force the opponent into defending, as long as it doesn't result in them creating a fork. For example, if "X" has a corner, "O" has the center, and "X" has the opposite corner as well, "O" must not play a corner in order to win. (Playing a corner in this scenario creates a fork for "X" to win.) Option 2: If there is a configuration where the opponent can fork, the player should block that fork. Center: A player marks the center. (If it is the first move of the game, playing on a corner gives "O" more opportunities to make a mistake and may therefore be the better choice; however, it makes no difference between perfect players.) Opposite corner: If the opponent is in the corner, the player plays the opposite corner. Empty corner: The player plays in a corner square. Empty side: The player plays in a middle square on any of the 4 sides
  8. Hi, first time posting here. I'm having problems with some trigonometry calculations in as3. Here's the swf file, i can move the ship forwards and backwards but things get weird when i try to move it sideways.   Here's the code; //this moves the ship forward vx += Math.cos(rotation* Math.PI / 180) * 3; vy += Math.sin(rotation* Math.PI / 180) * 3; //and this should move the ship to its right vx += Math.cos((rotation+90)* Math.PI / 180) * 3; vy += Math.sin((rotation+90)* Math.PI / 180) * 3;   I have no idea what i'm doing with these stuff i just took the calculations from a tutorial. Why this isnt working?   Thanks in advance!   ps: Here's some additional info; //ship's location is updated like this in every tick x+=vx; y+=vy; //and i calculate the angle of the ship like this; rotation = (Math.atan2(y-stageRef.mouseY,x-stageRef.mouseX)*180/Math.PI)+180;    
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!