Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 3 of 3

Thread: Actionscript help on creating random pixels..

  1. #1

    Actionscript help on creating random pixels..

    I would like to create a test game which would show a simple sketch image of say a circle, or any other simple geometric shape. The user would then use his cursor to trace over the sketch. How would I tell if the user is tracing it and how could I measure the users accuracy (because invariably you wont trace it exactly correct).

    Thanks in advance.

  2. #2
    Quote Originally Posted by TitusRevised View Post
    I would like to create a test game which would show a simple sketch image of say a circle, or any other simple geometric shape. The user would then use his cursor to trace over the sketch. How would I tell if the user is tracing it and how could I measure the users accuracy (because invariably you wont trace it exactly correct).

    Thanks in advance.


    Once you have the forumla to draw the circle, you can get any one of (X,Y) coordinates.

    But what you should remember is that all the points in the circle are 'r' (radius) distance from the origin. So if the circle orginates from (0,0), a unit circle will have radius of 1 and all the points along the line will be 1 away from the origin.

    So when user's mouse is pressed down and on the canvas, you can check the _mousex and _mousey and calculate the distance from your origin.

    ie) If your circle orginates from (200, 200) and radius is 50... then at any given time, you can calculate where the user's mouse is, and use the distnace formula: ( http://www.purplemath.com/modules/distform.htm )

    Math.sqrt( (200 - _mousex )^2 + (200 - _mousey) ^2 )

    And if you want to give error margin of 5, then as long as the distance is between 45 and 55, you let it pass.

    I am sure above math needs some more work.

    [Added]

    For other shapes, I believe you will have to keep major vertices and somehow keep formulas that you used to draw out the geometric shapes so that you can set boundary lines.

    For some reason I keep thinking integral but I am sure it's cuz I am still in sleep mode...
    Last edited by misterooga; May 5th, 2008 at 11:01 AM.

  3. #3
    I bet you could make a "no-draw" zone, which could be a series of movieclips surrounding the shape the user has to draw. When the user is finished drawing their line, somehow break the line up into smaller segments, and check for collisions between the no-draw zone shapes and each line segment. X number of collisions would determine their accuracy.

    I don't think this would be very fast (run-time & development) or dynamic, but it's a pretty straight-forward code-lite model to start working with.
    you = function(){
    setEnabled( true );
    live();
    setEnabled( false );
    }

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