Skip to content

Commit

Permalink
Cleaning up color themes for samples to match logo etc
Browse files Browse the repository at this point in the history
  • Loading branch information
ruby0x1 committed Jun 7, 2014
1 parent 337f793 commit b6d955e
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 51 deletions.
43 changes: 17 additions & 26 deletions hxcollision/tests/usage1/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class Main extends Sprite {
var visualise : Sprite;

//for viewing when collisions happen, we change colors
var normal_color : Int = 0x757161;
var collide_color : Int = 0x6dc2ca;
var separation_color : Int = 0xd27d2c;
var normal_color : Int = 0x72846c;
var collide_color : Int = 0x62ea93;
var separation_color : Int = 0xff4b03;

//the mouse position
var mouse_pos : Point;
Expand Down Expand Up @@ -103,15 +103,15 @@ class Main extends Sprite {

//caption
var inputFormat = new flash.text.TextFormat();
inputFormat.font = "Helvetica, sans-serif";
inputFormat.color = 0xd04648;
inputFormat.font = "Helvetica, sans-serif";
inputFormat.color = separation_color;
var textField = new flash.text.TextField();
textField.defaultTextFormat = inputFormat;
textField.autoSize = flash.text.TextFieldAutoSize.LEFT;
textField.mouseEnabled = false;
textField.width = stage.stageWidth;
textField.text = " CLICK TO SWITCH MOUSE SHAPE";
stage.addChild(textField);
textField.defaultTextFormat = inputFormat;
textField.autoSize = flash.text.TextFieldAutoSize.LEFT;
textField.mouseEnabled = false;
textField.width = stage.stageWidth;
textField.text = " CLICK TO SWITCH MOUSE SHAPE";
stage.addChild(textField);

//Listen for the changes in mouse movement
stage.addEventListener( flash.events.MouseEvent.MOUSE_MOVE, mousemove );
Expand Down Expand Up @@ -147,20 +147,11 @@ class Main extends Sprite {

public function update_line() {

//move the line up or down based on direction
line_y += 50 * line_dir * dt;
line_start.x = circle_mouse.x;
line_start.y = circle_mouse.y;

//going down and hit the bottom?
if(line_dir == 1 && line_y >= 500) {
line_dir = -1;
} else //going up and hit the top?
if(line_dir == -1 && line_y <= 0) {
line_dir = 1;
}


line_start.y = line_y;
line_end.y = line_y;
line_end.x = hexagon_mouse.x;
line_end.y = hexagon_mouse.y;

} //update_line

Expand Down Expand Up @@ -298,8 +289,8 @@ class Main extends Sprite {

//Test the line and all the shapes

line_collide = Collision.ray( line_start, line_end, [ box_static, hexagon_mouse, circle_static, circle_mouse,
oct_static, triangle_static, custom_static ]);
line_collide = Collision.ray( line_start, line_end,
[ box_static, circle_static, oct_static, triangle_static, custom_static ]);

//Now draw them

Expand Down
2 changes: 1 addition & 1 deletion hxcollision/tests/usage1/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<window
width="500"
height="500"
background="#140c1c"
background="#232921"
fps="60"
orientation="landscape"
resizable="false"
Expand Down
38 changes: 24 additions & 14 deletions hxcollision/tests/usage2/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ class Main extends Sprite {
//For viewing the collision states
var drawer : OpenFLDrawer;
var visualise : Sprite;
var collide_color : Int = 0x11CC88;
var separation_color : Int = 0xF2903A;

var collide_color : Int = 0x62ea93;
var separation_color : Int = 0xff4b03;
var normal_color : Int = 0x72846c;
var player_color : Int = 0x72846c;

//A few static shapes to test against
var box_static : Polygon;
Expand Down Expand Up @@ -73,16 +76,17 @@ class Main extends Sprite {

//caption
var inputFormat = new flash.text.TextFormat();
inputFormat.font = "Helvetica, sans-serif";
inputFormat.color = 0xd04648;
inputFormat.font = "Helvetica, sans-serif";
inputFormat.color = separation_color;
var textField = new flash.text.TextField();
textField.defaultTextFormat = inputFormat;
textField.autoSize = flash.text.TextFieldAutoSize.LEFT;
textField.mouseEnabled = false;
textField.width = stage.stageWidth;
textField.text = "[ENTER] TO SWITCH PLAYER SHAPE\n" +
"[SPACE] TO RESET PLAYER POSITION\n" +
"[ARROWS] TO MOVE THE PLAYER";
textField.defaultTextFormat = inputFormat;
textField.autoSize = flash.text.TextFieldAutoSize.LEFT;
textField.mouseEnabled = false;
textField.width = stage.stageWidth;
textField.text = "[ENTER] TO SWITCH PLAYER SHAPE\n" +
"[SPACE] TO RESET PLAYER POSITION\n" +
"[ARROWS] TO MOVE THE PLAYER";

stage.addChild(textField);

//Listen for the changes in mouse movement
Expand Down Expand Up @@ -164,10 +168,14 @@ class Main extends Sprite {
next_pos_x += player_vel.x;
next_pos_y += player_vel.y;

//start at normal color
player_color = separation_color;

//now check for collisions against the static items
var results = Collision.testShapes(player_collider, static_list);
//handle any potential collisions by separating the items
for(_result in results) {
player_color = collide_color;
next_pos_x += _result.separation.x;
next_pos_y += _result.separation.y;
}
Expand All @@ -179,18 +187,20 @@ class Main extends Sprite {

//Draw everything

visualise.graphics.beginFill(0x6daa2c);
visualise.graphics.lineStyle( 1, normal_color );

drawer.drawCircle( circle_static );
drawer.drawPolygon( box_static );
drawer.drawPolygon( hexagon_static );
drawer.drawPolygon( oct_static );
drawer.drawPolygon( triangle_static );
visualise.graphics.endFill();

visualise.graphics.lineStyle();


//draw where the player is right now

visualise.graphics.beginFill(0xd27d2c);
visualise.graphics.beginFill(player_color);
if( Std.is(player_collider, Circle) )
drawer.drawCircle( cast (player_collider, Circle) );
else
Expand Down
2 changes: 1 addition & 1 deletion hxcollision/tests/usage2/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<window
width="500"
height="500"
background="#140c1c"
background="#232921"
fps="60"
orientation="landscape"
resizable="false"
Expand Down
16 changes: 8 additions & 8 deletions hxcollision/tests/usage3/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ class Main extends Sprite {

//caption
var inputFormat = new flash.text.TextFormat();
inputFormat.font = "Helvetica, sans-serif";
inputFormat.color = 0xd04648;
inputFormat.font = "Helvetica, sans-serif";
inputFormat.color = 0xff4b03;
caption = new flash.text.TextField();
caption.defaultTextFormat = inputFormat;
caption.autoSize = flash.text.TextFieldAutoSize.LEFT;
caption.mouseEnabled = false;
caption.width = stage.stageWidth;
caption.text = "COLLISION RESOLUTION STRESS TEST";
caption.defaultTextFormat = inputFormat;
caption.autoSize = flash.text.TextFieldAutoSize.LEFT;
caption.mouseEnabled = false;
caption.width = stage.stageWidth;
caption.text = "COLLISION RESOLUTION STRESS TEST";
stage.addChild( caption );

//And finally, listen for updates.
Expand Down Expand Up @@ -163,7 +163,7 @@ class Main extends Sprite {
visualise.graphics.clear();

//shapes theming
visualise.graphics.lineStyle( 2, 0x757161 );
visualise.graphics.lineStyle( 2, 0x72846c );

//draw all the shapes
for(shape in allshapes_list) {
Expand Down
2 changes: 1 addition & 1 deletion hxcollision/tests/usage3/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<window
width="500"
height="500"
background="#140c1c"
background="#232921"
fps="60"
orientation="landscape"
resizable="false"
Expand Down

0 comments on commit b6d955e

Please sign in to comment.