SlideShare a Scribd company logo
1 of 16
SlingShot/._slingShot.swf
SlingShot/accelerometer.as
import flash.sensors.Accelerometer;
var theAcc:Accelerometer = new Accelerometer();
theAcc.setRequestedUpdateInterval(50);
if (Accelerometer.isSupported == true)
{
trace("is supported");
}
else
{
//do something if its not
//instructions.visible = flase
}
theAcc.addEventListener(AccelerometerEvent.UPDATE,
onAccUpdate);
function onAccUpdate(event:AccelerometerEvent):void
{
if (ball.x > point2.x)
{
vel.x -= (event.accelerationX * 1);
}
}
SlingShot/clockTimer.as
SlingShot/collisions.as
function detectCollisions()
{
//block collision
if (blockOutline.hitTestPoint(ball.x,ball.y,true))
{
hitblockOutline = true;
vel.x = vel.x * -1;
}
//box collision
if (outline.hitTestPoint(ball.x,ball.y,true) && hitOutline
== false)
{
hitOutline = true;
vel.x = vel.x * -1;
}
//the target
if (theTarget.hitTestPoint(ball.x,ball.y,true) &&
ball.visible == true)
{
ball.visible = false;
acc.x = 0;
acc.y = 0;
vel.x = 0;
vel.y = 0;
trace ("you win");
resetPlay();
}
}
SlingShot/doConstantly.as
import flash.events.Event;
addEventListener(Event.ENTER_FRAME, doConstantly);
function doConstantly(event:Event):void
{
//main code for gravity affect ball and other stuff...
acc.x = 0;
acc.y = gravity;
if (released == true)
{
//if you have let go of ball
/*vel.x += acc.x;
vel.y += acc.y;*/
ball.x += vel.x;
ball.y += vel.y;
//ball.rotation += vel.x;
}
//this will make sure the ball doesnt dissappear off stage
if (ball.x > stage.stageWidth || ball.x < 0 || ball.y < -500 ||
ball.y > stage.stageHeight + 100)
{
resetPlay();
}
//below draw elastic string
elastic.graphics.clear();
elastic.graphics.lineStyle(0.5, 0x9999999);
if (ball.y > point1.y && ball.x < point2.x)
{// the ball falls within range of bending the string
forced = true;
var x1:Number = ball.x - point1.x;
var y1:Number = ball.y - point1.y;
var x2:Number = point2.x - ball.x;
var y2:Number = point2.y - ball.y;
var distance1:Number = Math.sqrt(x1*x1+y1*y1);
var distance2:Number = Math.sqrt(x2*x2+y2*y2);
angle1 = Math.atan2(y1,x1);
angle2 = Math.atan2(y2,x2);
var xOffset:Number =
Math.cos(angle1+Math.PI/2)*radius;
var yOffset:Number =
Math.sin(angle1+Math.PI/2)*radius;
var xOffset2:Number =
Math.cos(angle2+Math.PI/2)*radius;
var yOffset2:Number =
Math.sin(angle2+Math.PI/2)*radius;
angle1 += Math.sin(radius/distance1);
angle2 += Math.sin(radius/distance2)*-1;
elastic.graphics.moveTo(point1.x, point1.y);
elastic.graphics.lineTo(ball.x+xOffset,
ball.y+yOffset);
elastic.graphics.moveTo(point2.x, point2.y);
elastic.graphics.lineTo(ball.x+xOffset2,
ball.y+yOffset2);
}
else
{
// the ball falls out of range of bending the string;
forced = false;
elastic.graphics.moveTo(point1.x, point1.y);
elastic.graphics.lineTo(point2.x, point2.y);
}
// makes the ball bounce back up;
if (released == true && forced == true)
{
acc.x += distance1 * Math.sin(angle2) *
elasticCoefficient;
acc.y += - distance1 * Math.cos(angle1) *
elasticCoefficient;
acc.x += distance2 * Math.sin(angle1) *
elasticCoefficient;
acc.y += - distance2 * Math.cos(angle2) *
elasticCoefficient;
}
if (released)
{
vel.x += acc.x;
vel.y += acc.y;
}
//prevent you from moving can over the target
if (released == false && ball.x >point2.x) {
ball.stopDrag();
released = true;
resetPlay();
}
//calling collision functions
detectCollisions();
}
SlingShot/initials.as
import flash.display.MovieClip;
import flash.events.Event;
import flash.sensors.Accelerometer;
import flash.events.AccelerometerEvent;
stop();
var blockStarting:Object = {x:block.x , y:block.y};
var ballStarting:Object = {x:ball.x , y:ball.y};
trace (ballStarting.x, ballStarting.y);
var stick1Starting:Object = {x:stick1.x, y:stick1.y};
var stick2Starting:Object = {x:stick2.x, y:stick2.y};
var point1Starting:Object = {x:point1.x, y:point1.y};
var point2Starting:Object = {x:point2.x, y:point2.y};
var boxStarting:Object ={x:box.x, y:box.y};
//trace (boxStarting.x, boxStarting.y);
var theTargetStarting:Object = {x:theTarget.x, y:theTarget.y};
//trace (theTargetStarting.x, theTargetStarting.y);
var gravity = 0.15;
var angle1:Number = 0;
var angle2:Number = 0;
var radius:Number = 1;
var elasticCoefficient:Number = 0.0045;
var released:Boolean = true;
var forced:Boolean = false; //whether or not it is being pulled
down between the sticks
var acc:Object = {x:0, y:0};
var vel:Object = {x:0, y:0};
var hitOutline:Boolean = false;
var hitblockOutline:Boolean = false;
var hittheTarget:Boolean = false;
var elastic:MovieClip = new MovieClip();
addChild (elastic);
SlingShot/mouseEvents.as
import flash.events.MouseEvent;
ball.addEventListener (MouseEvent.MOUSE_DOWN,
ballDown);
function ballDown(event:MouseEvent)
{
resetPlay();
ball.x = mouseX;
ball.y = mouseY;
ball.startDrag();
released = false;//gravity will not affect ball when false
}
stage.addEventListener (MouseEvent.MOUSE_UP, ballUp);
function ballUp(event:MouseEvent)
{
ball.stopDrag();
released = true;// gravity will affect can
}
SlingShot/resetPlay.as
function resetPlay() {
hitblockOutline = false;
hitOutline = false;
hittheTarget = true;
ball.x = 89.5;
ball.y = 170.05;
vel.x = 0;
vel.y = 0;
acc.x = 0;
acc.y = gravity;
block.x = blockStarting.x;
block.y = blockStarting.y;
point1.x = point1Starting.x;
point1.y = point1Starting.y;
point2.x = point2Starting.x;
point2.y = point2Starting.y;
stick1.x = stick1Starting.x;
stick1.y = stick1Starting.y;
stick2.x = stick2Starting.x;
stick2.y = stick2Starting.y;
box.x = boxStarting.x;
box.y = boxStarting.y;
theTarget.x = theTargetStarting.x;
theTarget.y = theTargetStarting.y;
}
SlingShot/slingShot.fla
SlingShot/slingShot.png
SlingShot/slingShot.swf
SlingShot/slingShot.xml

More Related Content

Similar to SlingShot._slingShot.swfSlingShotaccelerometer.asimport .docx

Creating an Uber Clone - Part XIX.pdf
Creating an Uber Clone - Part XIX.pdfCreating an Uber Clone - Part XIX.pdf
Creating an Uber Clone - Part XIX.pdfShaiAlmog1
 
The Ring programming language version 1.5.1 book - Part 64 of 180
The Ring programming language version 1.5.1 book - Part 64 of 180The Ring programming language version 1.5.1 book - Part 64 of 180
The Ring programming language version 1.5.1 book - Part 64 of 180Mahmoud Samir Fayed
 
Intro to Game Programming
Intro to Game ProgrammingIntro to Game Programming
Intro to Game ProgrammingRichard Jones
 
Testing a 2D Platformer with Spock
Testing a 2D Platformer with SpockTesting a 2D Platformer with Spock
Testing a 2D Platformer with SpockAlexander Tarlinder
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesAnkit Rastogi
 
Simple_Movement_Class
Simple_Movement_ClassSimple_Movement_Class
Simple_Movement_ClassDavid Harris
 
2020 Droid Knights CustomLint 적용기
2020 Droid Knights CustomLint 적용기2020 Droid Knights CustomLint 적용기
2020 Droid Knights CustomLint 적용기Insung Hwang
 
I wanted to change the cloudsrectangles into an actuall image it do.pdf
I wanted to change the cloudsrectangles into an actuall image it do.pdfI wanted to change the cloudsrectangles into an actuall image it do.pdf
I wanted to change the cloudsrectangles into an actuall image it do.pdffeelinggifts
 
Os Practical Assignment 1
Os Practical Assignment 1Os Practical Assignment 1
Os Practical Assignment 1Emmanuel Garcia
 
The Ring programming language version 1.6 book - Part 62 of 189
The Ring programming language version 1.6 book - Part 62 of 189The Ring programming language version 1.6 book - Part 62 of 189
The Ring programming language version 1.6 book - Part 62 of 189Mahmoud Samir Fayed
 
-- USING UNITY TRYING TO CREATE A CLICK TO PATH- THAT YOU CLICK ON AND.pdf
-- USING UNITY TRYING TO CREATE A CLICK TO PATH- THAT YOU CLICK ON AND.pdf-- USING UNITY TRYING TO CREATE A CLICK TO PATH- THAT YOU CLICK ON AND.pdf
-- USING UNITY TRYING TO CREATE A CLICK TO PATH- THAT YOU CLICK ON AND.pdfganisyedtrd
 
The Ring programming language version 1.6 book - Part 70 of 189
The Ring programming language version 1.6 book - Part 70 of 189The Ring programming language version 1.6 book - Part 70 of 189
The Ring programming language version 1.6 book - Part 70 of 189Mahmoud Samir Fayed
 
ARTDM 170, Week 11: User Interaction
ARTDM 170, Week 11: User InteractionARTDM 170, Week 11: User Interaction
ARTDM 170, Week 11: User InteractionGilbert Guerrero
 
The Ring programming language version 1.4 book - Part 16 of 30
The Ring programming language version 1.4 book - Part 16 of 30The Ring programming language version 1.4 book - Part 16 of 30
The Ring programming language version 1.4 book - Part 16 of 30Mahmoud Samir Fayed
 
Async Testing giving you a sinking feeling
Async Testing giving you a sinking feelingAsync Testing giving you a sinking feeling
Async Testing giving you a sinking feelingErin Zimmer
 
Introduction to Game Programming Tutorial
Introduction to Game Programming TutorialIntroduction to Game Programming Tutorial
Introduction to Game Programming TutorialRichard Jones
 

Similar to SlingShot._slingShot.swfSlingShotaccelerometer.asimport .docx (20)

Angular2 rxjs
Angular2 rxjsAngular2 rxjs
Angular2 rxjs
 
Creating an Uber Clone - Part XIX.pdf
Creating an Uber Clone - Part XIX.pdfCreating an Uber Clone - Part XIX.pdf
Creating an Uber Clone - Part XIX.pdf
 
The Ring programming language version 1.5.1 book - Part 64 of 180
The Ring programming language version 1.5.1 book - Part 64 of 180The Ring programming language version 1.5.1 book - Part 64 of 180
The Ring programming language version 1.5.1 book - Part 64 of 180
 
Intro to Game Programming
Intro to Game ProgrammingIntro to Game Programming
Intro to Game Programming
 
Testing a 2D Platformer with Spock
Testing a 2D Platformer with SpockTesting a 2D Platformer with Spock
Testing a 2D Platformer with Spock
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practices
 
Simple_Movement_Class
Simple_Movement_ClassSimple_Movement_Class
Simple_Movement_Class
 
2020 Droid Knights CustomLint 적용기
2020 Droid Knights CustomLint 적용기2020 Droid Knights CustomLint 적용기
2020 Droid Knights CustomLint 적용기
 
I wanted to change the cloudsrectangles into an actuall image it do.pdf
I wanted to change the cloudsrectangles into an actuall image it do.pdfI wanted to change the cloudsrectangles into an actuall image it do.pdf
I wanted to change the cloudsrectangles into an actuall image it do.pdf
 
Os Practical Assignment 1
Os Practical Assignment 1Os Practical Assignment 1
Os Practical Assignment 1
 
The Ring programming language version 1.6 book - Part 62 of 189
The Ring programming language version 1.6 book - Part 62 of 189The Ring programming language version 1.6 book - Part 62 of 189
The Ring programming language version 1.6 book - Part 62 of 189
 
-- USING UNITY TRYING TO CREATE A CLICK TO PATH- THAT YOU CLICK ON AND.pdf
-- USING UNITY TRYING TO CREATE A CLICK TO PATH- THAT YOU CLICK ON AND.pdf-- USING UNITY TRYING TO CREATE A CLICK TO PATH- THAT YOU CLICK ON AND.pdf
-- USING UNITY TRYING TO CREATE A CLICK TO PATH- THAT YOU CLICK ON AND.pdf
 
Sequence diagrams
Sequence diagramsSequence diagrams
Sequence diagrams
 
Flare3d jiglib.as
Flare3d jiglib.asFlare3d jiglib.as
Flare3d jiglib.as
 
The Ring programming language version 1.6 book - Part 70 of 189
The Ring programming language version 1.6 book - Part 70 of 189The Ring programming language version 1.6 book - Part 70 of 189
The Ring programming language version 1.6 book - Part 70 of 189
 
Player x 0 y ga.docx
Player x 0 y ga.docxPlayer x 0 y ga.docx
Player x 0 y ga.docx
 
ARTDM 170, Week 11: User Interaction
ARTDM 170, Week 11: User InteractionARTDM 170, Week 11: User Interaction
ARTDM 170, Week 11: User Interaction
 
The Ring programming language version 1.4 book - Part 16 of 30
The Ring programming language version 1.4 book - Part 16 of 30The Ring programming language version 1.4 book - Part 16 of 30
The Ring programming language version 1.4 book - Part 16 of 30
 
Async Testing giving you a sinking feeling
Async Testing giving you a sinking feelingAsync Testing giving you a sinking feeling
Async Testing giving you a sinking feeling
 
Introduction to Game Programming Tutorial
Introduction to Game Programming TutorialIntroduction to Game Programming Tutorial
Introduction to Game Programming Tutorial
 

More from budabrooks46239

Enterprise Key Management Plan An eight- to 10-page  double.docx
Enterprise Key Management Plan An eight- to 10-page  double.docxEnterprise Key Management Plan An eight- to 10-page  double.docx
Enterprise Key Management Plan An eight- to 10-page  double.docxbudabrooks46239
 
English IV Research PaperMrs. MantineoObjective  To adher.docx
English IV Research PaperMrs. MantineoObjective  To adher.docxEnglish IV Research PaperMrs. MantineoObjective  To adher.docx
English IV Research PaperMrs. MantineoObjective  To adher.docxbudabrooks46239
 
Enter in conversation with other writers by writing a thesis-dri.docx
Enter in conversation with other writers by writing a thesis-dri.docxEnter in conversation with other writers by writing a thesis-dri.docx
Enter in conversation with other writers by writing a thesis-dri.docxbudabrooks46239
 
English II – Touchstone 3.2 Draft an Argumentative Research Essay.docx
English II – Touchstone 3.2 Draft an Argumentative Research Essay.docxEnglish II – Touchstone 3.2 Draft an Argumentative Research Essay.docx
English II – Touchstone 3.2 Draft an Argumentative Research Essay.docxbudabrooks46239
 
English 3060Spring 2021Group Summary ofReinhardP.docx
English 3060Spring 2021Group Summary ofReinhardP.docxEnglish 3060Spring 2021Group Summary ofReinhardP.docx
English 3060Spring 2021Group Summary ofReinhardP.docxbudabrooks46239
 
English 102 Essay 2 First Draft Assignment Feminism and Hubris.docx
English 102 Essay 2 First Draft Assignment Feminism and Hubris.docxEnglish 102 Essay 2 First Draft Assignment Feminism and Hubris.docx
English 102 Essay 2 First Draft Assignment Feminism and Hubris.docxbudabrooks46239
 
English 102 Essay 2 Assignment Feminism and Hubris”Write a.docx
English 102 Essay 2 Assignment Feminism and Hubris”Write a.docxEnglish 102 Essay 2 Assignment Feminism and Hubris”Write a.docx
English 102 Essay 2 Assignment Feminism and Hubris”Write a.docxbudabrooks46239
 
ENGL112 WednesdayDr. Jason StarnesMarch 9, 2020Human Respo.docx
ENGL112 WednesdayDr. Jason StarnesMarch 9, 2020Human Respo.docxENGL112 WednesdayDr. Jason StarnesMarch 9, 2020Human Respo.docx
ENGL112 WednesdayDr. Jason StarnesMarch 9, 2020Human Respo.docxbudabrooks46239
 
English 101 - Reminders and Help for Rhetorical Analysis Paragraph.docx
English 101 - Reminders and Help for Rhetorical Analysis Paragraph.docxEnglish 101 - Reminders and Help for Rhetorical Analysis Paragraph.docx
English 101 - Reminders and Help for Rhetorical Analysis Paragraph.docxbudabrooks46239
 
ENGL 301BSections 12 & 15Prof. GuzikSpring 2020Assignment .docx
ENGL 301BSections 12 & 15Prof. GuzikSpring 2020Assignment .docxENGL 301BSections 12 & 15Prof. GuzikSpring 2020Assignment .docx
ENGL 301BSections 12 & 15Prof. GuzikSpring 2020Assignment .docxbudabrooks46239
 
ENGL 102Use the following template as a cover page for each writ.docx
ENGL 102Use the following template as a cover page for each writ.docxENGL 102Use the following template as a cover page for each writ.docx
ENGL 102Use the following template as a cover page for each writ.docxbudabrooks46239
 
ENGL2310 Essay 2 Assignment Due by Saturday, June 13, a.docx
ENGL2310 Essay 2 Assignment          Due by Saturday, June 13, a.docxENGL2310 Essay 2 Assignment          Due by Saturday, June 13, a.docx
ENGL2310 Essay 2 Assignment Due by Saturday, June 13, a.docxbudabrooks46239
 
ENGL 151 Research EssayAssignment DetailsValue 25 (additio.docx
ENGL 151 Research EssayAssignment DetailsValue 25 (additio.docxENGL 151 Research EssayAssignment DetailsValue 25 (additio.docx
ENGL 151 Research EssayAssignment DetailsValue 25 (additio.docxbudabrooks46239
 
ENGL 140 Signature Essay Peer Review WorksheetAssignmentDirectio.docx
ENGL 140 Signature Essay Peer Review WorksheetAssignmentDirectio.docxENGL 140 Signature Essay Peer Review WorksheetAssignmentDirectio.docx
ENGL 140 Signature Essay Peer Review WorksheetAssignmentDirectio.docxbudabrooks46239
 
ENGINEERING ETHICSThe Space Shuttle Challenger Disaster.docx
ENGINEERING ETHICSThe Space Shuttle Challenger Disaster.docxENGINEERING ETHICSThe Space Shuttle Challenger Disaster.docx
ENGINEERING ETHICSThe Space Shuttle Challenger Disaster.docxbudabrooks46239
 
Engaging Youth Experiencing Homelessness Core Practi.docx
Engaging Youth Experiencing Homelessness Core Practi.docxEngaging Youth Experiencing Homelessness Core Practi.docx
Engaging Youth Experiencing Homelessness Core Practi.docxbudabrooks46239
 
Engaging Families to Support Indigenous Students’ Numeracy Devel.docx
Engaging Families to Support Indigenous Students’ Numeracy Devel.docxEngaging Families to Support Indigenous Students’ Numeracy Devel.docx
Engaging Families to Support Indigenous Students’ Numeracy Devel.docxbudabrooks46239
 
Endocrine Attendance QuestionsWhat is hypopituitarism and how .docx
Endocrine Attendance QuestionsWhat is hypopituitarism and how .docxEndocrine Attendance QuestionsWhat is hypopituitarism and how .docx
Endocrine Attendance QuestionsWhat is hypopituitarism and how .docxbudabrooks46239
 
ENG 130 Literature and Comp ENG 130 Research Essay E.docx
ENG 130 Literature and Comp ENG 130 Research Essay E.docxENG 130 Literature and Comp ENG 130 Research Essay E.docx
ENG 130 Literature and Comp ENG 130 Research Essay E.docxbudabrooks46239
 
ENG 201 01 Summer I Presentation Assignment· Due , June 7, .docx
ENG 201 01 Summer I Presentation Assignment· Due , June 7, .docxENG 201 01 Summer I Presentation Assignment· Due , June 7, .docx
ENG 201 01 Summer I Presentation Assignment· Due , June 7, .docxbudabrooks46239
 

More from budabrooks46239 (20)

Enterprise Key Management Plan An eight- to 10-page  double.docx
Enterprise Key Management Plan An eight- to 10-page  double.docxEnterprise Key Management Plan An eight- to 10-page  double.docx
Enterprise Key Management Plan An eight- to 10-page  double.docx
 
English IV Research PaperMrs. MantineoObjective  To adher.docx
English IV Research PaperMrs. MantineoObjective  To adher.docxEnglish IV Research PaperMrs. MantineoObjective  To adher.docx
English IV Research PaperMrs. MantineoObjective  To adher.docx
 
Enter in conversation with other writers by writing a thesis-dri.docx
Enter in conversation with other writers by writing a thesis-dri.docxEnter in conversation with other writers by writing a thesis-dri.docx
Enter in conversation with other writers by writing a thesis-dri.docx
 
English II – Touchstone 3.2 Draft an Argumentative Research Essay.docx
English II – Touchstone 3.2 Draft an Argumentative Research Essay.docxEnglish II – Touchstone 3.2 Draft an Argumentative Research Essay.docx
English II – Touchstone 3.2 Draft an Argumentative Research Essay.docx
 
English 3060Spring 2021Group Summary ofReinhardP.docx
English 3060Spring 2021Group Summary ofReinhardP.docxEnglish 3060Spring 2021Group Summary ofReinhardP.docx
English 3060Spring 2021Group Summary ofReinhardP.docx
 
English 102 Essay 2 First Draft Assignment Feminism and Hubris.docx
English 102 Essay 2 First Draft Assignment Feminism and Hubris.docxEnglish 102 Essay 2 First Draft Assignment Feminism and Hubris.docx
English 102 Essay 2 First Draft Assignment Feminism and Hubris.docx
 
English 102 Essay 2 Assignment Feminism and Hubris”Write a.docx
English 102 Essay 2 Assignment Feminism and Hubris”Write a.docxEnglish 102 Essay 2 Assignment Feminism and Hubris”Write a.docx
English 102 Essay 2 Assignment Feminism and Hubris”Write a.docx
 
ENGL112 WednesdayDr. Jason StarnesMarch 9, 2020Human Respo.docx
ENGL112 WednesdayDr. Jason StarnesMarch 9, 2020Human Respo.docxENGL112 WednesdayDr. Jason StarnesMarch 9, 2020Human Respo.docx
ENGL112 WednesdayDr. Jason StarnesMarch 9, 2020Human Respo.docx
 
English 101 - Reminders and Help for Rhetorical Analysis Paragraph.docx
English 101 - Reminders and Help for Rhetorical Analysis Paragraph.docxEnglish 101 - Reminders and Help for Rhetorical Analysis Paragraph.docx
English 101 - Reminders and Help for Rhetorical Analysis Paragraph.docx
 
ENGL 301BSections 12 & 15Prof. GuzikSpring 2020Assignment .docx
ENGL 301BSections 12 & 15Prof. GuzikSpring 2020Assignment .docxENGL 301BSections 12 & 15Prof. GuzikSpring 2020Assignment .docx
ENGL 301BSections 12 & 15Prof. GuzikSpring 2020Assignment .docx
 
ENGL 102Use the following template as a cover page for each writ.docx
ENGL 102Use the following template as a cover page for each writ.docxENGL 102Use the following template as a cover page for each writ.docx
ENGL 102Use the following template as a cover page for each writ.docx
 
ENGL2310 Essay 2 Assignment Due by Saturday, June 13, a.docx
ENGL2310 Essay 2 Assignment          Due by Saturday, June 13, a.docxENGL2310 Essay 2 Assignment          Due by Saturday, June 13, a.docx
ENGL2310 Essay 2 Assignment Due by Saturday, June 13, a.docx
 
ENGL 151 Research EssayAssignment DetailsValue 25 (additio.docx
ENGL 151 Research EssayAssignment DetailsValue 25 (additio.docxENGL 151 Research EssayAssignment DetailsValue 25 (additio.docx
ENGL 151 Research EssayAssignment DetailsValue 25 (additio.docx
 
ENGL 140 Signature Essay Peer Review WorksheetAssignmentDirectio.docx
ENGL 140 Signature Essay Peer Review WorksheetAssignmentDirectio.docxENGL 140 Signature Essay Peer Review WorksheetAssignmentDirectio.docx
ENGL 140 Signature Essay Peer Review WorksheetAssignmentDirectio.docx
 
ENGINEERING ETHICSThe Space Shuttle Challenger Disaster.docx
ENGINEERING ETHICSThe Space Shuttle Challenger Disaster.docxENGINEERING ETHICSThe Space Shuttle Challenger Disaster.docx
ENGINEERING ETHICSThe Space Shuttle Challenger Disaster.docx
 
Engaging Youth Experiencing Homelessness Core Practi.docx
Engaging Youth Experiencing Homelessness Core Practi.docxEngaging Youth Experiencing Homelessness Core Practi.docx
Engaging Youth Experiencing Homelessness Core Practi.docx
 
Engaging Families to Support Indigenous Students’ Numeracy Devel.docx
Engaging Families to Support Indigenous Students’ Numeracy Devel.docxEngaging Families to Support Indigenous Students’ Numeracy Devel.docx
Engaging Families to Support Indigenous Students’ Numeracy Devel.docx
 
Endocrine Attendance QuestionsWhat is hypopituitarism and how .docx
Endocrine Attendance QuestionsWhat is hypopituitarism and how .docxEndocrine Attendance QuestionsWhat is hypopituitarism and how .docx
Endocrine Attendance QuestionsWhat is hypopituitarism and how .docx
 
ENG 130 Literature and Comp ENG 130 Research Essay E.docx
ENG 130 Literature and Comp ENG 130 Research Essay E.docxENG 130 Literature and Comp ENG 130 Research Essay E.docx
ENG 130 Literature and Comp ENG 130 Research Essay E.docx
 
ENG 201 01 Summer I Presentation Assignment· Due , June 7, .docx
ENG 201 01 Summer I Presentation Assignment· Due , June 7, .docxENG 201 01 Summer I Presentation Assignment· Due , June 7, .docx
ENG 201 01 Summer I Presentation Assignment· Due , June 7, .docx
 

Recently uploaded

Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 

Recently uploaded (20)

Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 

SlingShot._slingShot.swfSlingShotaccelerometer.asimport .docx

  • 1. SlingShot/._slingShot.swf SlingShot/accelerometer.as import flash.sensors.Accelerometer; var theAcc:Accelerometer = new Accelerometer(); theAcc.setRequestedUpdateInterval(50); if (Accelerometer.isSupported == true) { trace("is supported"); } else { //do something if its not //instructions.visible = flase }
  • 2. theAcc.addEventListener(AccelerometerEvent.UPDATE, onAccUpdate); function onAccUpdate(event:AccelerometerEvent):void { if (ball.x > point2.x) { vel.x -= (event.accelerationX * 1); } } SlingShot/clockTimer.as SlingShot/collisions.as function detectCollisions() { //block collision if (blockOutline.hitTestPoint(ball.x,ball.y,true)) {
  • 3. hitblockOutline = true; vel.x = vel.x * -1; } //box collision if (outline.hitTestPoint(ball.x,ball.y,true) && hitOutline == false) { hitOutline = true; vel.x = vel.x * -1; } //the target
  • 4. if (theTarget.hitTestPoint(ball.x,ball.y,true) && ball.visible == true) { ball.visible = false; acc.x = 0; acc.y = 0; vel.x = 0; vel.y = 0; trace ("you win"); resetPlay(); } } SlingShot/doConstantly.as
  • 5. import flash.events.Event; addEventListener(Event.ENTER_FRAME, doConstantly); function doConstantly(event:Event):void { //main code for gravity affect ball and other stuff... acc.x = 0; acc.y = gravity; if (released == true) { //if you have let go of ball /*vel.x += acc.x; vel.y += acc.y;*/
  • 6. ball.x += vel.x; ball.y += vel.y; //ball.rotation += vel.x; } //this will make sure the ball doesnt dissappear off stage if (ball.x > stage.stageWidth || ball.x < 0 || ball.y < -500 || ball.y > stage.stageHeight + 100) { resetPlay(); } //below draw elastic string elastic.graphics.clear(); elastic.graphics.lineStyle(0.5, 0x9999999); if (ball.y > point1.y && ball.x < point2.x)
  • 7. {// the ball falls within range of bending the string forced = true; var x1:Number = ball.x - point1.x; var y1:Number = ball.y - point1.y; var x2:Number = point2.x - ball.x; var y2:Number = point2.y - ball.y; var distance1:Number = Math.sqrt(x1*x1+y1*y1); var distance2:Number = Math.sqrt(x2*x2+y2*y2); angle1 = Math.atan2(y1,x1); angle2 = Math.atan2(y2,x2); var xOffset:Number = Math.cos(angle1+Math.PI/2)*radius; var yOffset:Number = Math.sin(angle1+Math.PI/2)*radius; var xOffset2:Number = Math.cos(angle2+Math.PI/2)*radius; var yOffset2:Number = Math.sin(angle2+Math.PI/2)*radius;
  • 8. angle1 += Math.sin(radius/distance1); angle2 += Math.sin(radius/distance2)*-1; elastic.graphics.moveTo(point1.x, point1.y); elastic.graphics.lineTo(ball.x+xOffset, ball.y+yOffset); elastic.graphics.moveTo(point2.x, point2.y); elastic.graphics.lineTo(ball.x+xOffset2, ball.y+yOffset2); } else { // the ball falls out of range of bending the string; forced = false; elastic.graphics.moveTo(point1.x, point1.y); elastic.graphics.lineTo(point2.x, point2.y);
  • 9. } // makes the ball bounce back up; if (released == true && forced == true) { acc.x += distance1 * Math.sin(angle2) * elasticCoefficient; acc.y += - distance1 * Math.cos(angle1) * elasticCoefficient; acc.x += distance2 * Math.sin(angle1) * elasticCoefficient; acc.y += - distance2 * Math.cos(angle2) * elasticCoefficient; } if (released) { vel.x += acc.x; vel.y += acc.y;
  • 10. } //prevent you from moving can over the target if (released == false && ball.x >point2.x) { ball.stopDrag(); released = true; resetPlay(); } //calling collision functions detectCollisions(); } SlingShot/initials.as import flash.display.MovieClip; import flash.events.Event;
  • 11. import flash.sensors.Accelerometer; import flash.events.AccelerometerEvent; stop(); var blockStarting:Object = {x:block.x , y:block.y}; var ballStarting:Object = {x:ball.x , y:ball.y}; trace (ballStarting.x, ballStarting.y); var stick1Starting:Object = {x:stick1.x, y:stick1.y}; var stick2Starting:Object = {x:stick2.x, y:stick2.y}; var point1Starting:Object = {x:point1.x, y:point1.y}; var point2Starting:Object = {x:point2.x, y:point2.y};
  • 12. var boxStarting:Object ={x:box.x, y:box.y}; //trace (boxStarting.x, boxStarting.y); var theTargetStarting:Object = {x:theTarget.x, y:theTarget.y}; //trace (theTargetStarting.x, theTargetStarting.y); var gravity = 0.15; var angle1:Number = 0; var angle2:Number = 0; var radius:Number = 1; var elasticCoefficient:Number = 0.0045; var released:Boolean = true; var forced:Boolean = false; //whether or not it is being pulled down between the sticks var acc:Object = {x:0, y:0}; var vel:Object = {x:0, y:0}; var hitOutline:Boolean = false;
  • 13. var hitblockOutline:Boolean = false; var hittheTarget:Boolean = false; var elastic:MovieClip = new MovieClip(); addChild (elastic); SlingShot/mouseEvents.as import flash.events.MouseEvent; ball.addEventListener (MouseEvent.MOUSE_DOWN, ballDown); function ballDown(event:MouseEvent) { resetPlay(); ball.x = mouseX; ball.y = mouseY; ball.startDrag(); released = false;//gravity will not affect ball when false } stage.addEventListener (MouseEvent.MOUSE_UP, ballUp); function ballUp(event:MouseEvent) { ball.stopDrag(); released = true;// gravity will affect can }
  • 14. SlingShot/resetPlay.as function resetPlay() { hitblockOutline = false; hitOutline = false; hittheTarget = true; ball.x = 89.5; ball.y = 170.05; vel.x = 0; vel.y = 0; acc.x = 0; acc.y = gravity; block.x = blockStarting.x; block.y = blockStarting.y; point1.x = point1Starting.x;
  • 15. point1.y = point1Starting.y; point2.x = point2Starting.x; point2.y = point2Starting.y; stick1.x = stick1Starting.x; stick1.y = stick1Starting.y; stick2.x = stick2Starting.x; stick2.y = stick2Starting.y; box.x = boxStarting.x; box.y = boxStarting.y; theTarget.x = theTargetStarting.x; theTarget.y = theTargetStarting.y; }