Skip to content

Commit

Permalink
Consistent { positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
Gama11 committed Jan 15, 2016
1 parent ca9be33 commit a38d7ef
Show file tree
Hide file tree
Showing 54 changed files with 542 additions and 427 deletions.
11 changes: 8 additions & 3 deletions Arcade/Flappybalt/source/PlayState.hx
Expand Up @@ -130,16 +130,21 @@ class PlayState extends FlxState
override public function update(elapsed:Float):Void
{
if (FlxG.pixelPerfectOverlap(_player, _spikeBottom) || FlxG.pixelPerfectOverlap(_player, _spikeTop)
|| FlxG.pixelPerfectOverlap(_player, _paddleLeft) || FlxG.pixelPerfectOverlap(_player, _paddleRight)) {
|| FlxG.pixelPerfectOverlap(_player, _paddleLeft) || FlxG.pixelPerfectOverlap(_player, _paddleRight))
{
_player.kill();
} else if (_player.x < 5) {
}
else if (_player.x < 5)
{
_player.x = 5;
_player.velocity.x = -_player.velocity.x;
_player.flipX = false;
increaseScore();
_bounceLeft.animation.play("flash");
_paddleRight.randomize();
} else if (_player.x + _player.width > FlxG.width - 5) {
}
else if (_player.x + _player.width > FlxG.width - 5)
{
_player.x = FlxG.width - _player.width - 5;
_player.velocity.x = -_player.velocity.x;
_player.flipX = true;
Expand Down
8 changes: 5 additions & 3 deletions Arcade/Flappybalt/source/Player.hx
Expand Up @@ -17,11 +17,13 @@ class Player extends FlxSprite
override public function update(elapsed:Float)
{
#if !FLX_NO_KEYBOARD
if (FlxG.keys.justPressed.SPACE) {
if (FlxG.keys.justPressed.SPACE)
#elseif !FLX_NO_TOUCH
if (FlxG.touches.justStarted().length > 0) {
if (FlxG.touches.justStarted().length > 0)
#end
if (acceleration.y == 0) {
{
if (acceleration.y == 0)
{
acceleration.y = 500;
velocity.x = 80;
}
Expand Down
5 changes: 2 additions & 3 deletions Arcade/Flappybalt/source/Reg.hx
@@ -1,4 +1,5 @@
package;

import flash.display.BitmapData;
import flash.geom.Rectangle;
import flixel.util.FlxSave;
Expand Down Expand Up @@ -30,10 +31,8 @@ class Reg
*/
static public function dustMote():BitmapData
{
if (dustMoteData == null) {
if (dustMoteData == null)
dustMoteData = new BitmapData(2, 2, true, 0x88FFFFFF);
}

return dustMoteData;
}

Expand Down
24 changes: 13 additions & 11 deletions Arcade/Flixius/source/MessagePopup.hx
Expand Up @@ -75,11 +75,13 @@ class MessagePopup extends FlxSubState
add(_text);
add(_textContinue);

forEachOfType(FlxSprite, function(sprite) {
forEachOfType(FlxSprite, function(sprite)
{
sprite.alpha = 0;
});

FlxTween.num(0, 1, .66, { type:FlxTween.ONESHOT, ease:FlxEase.sineOut, onComplete:function(_) {
FlxTween.num(0, 1, .66, { type:FlxTween.ONESHOT, ease:FlxEase.sineOut, onComplete:function(_)
{
_fadingIn = false;
}}, updateAlpha);
}
Expand Down Expand Up @@ -113,28 +115,28 @@ class MessagePopup extends FlxSubState
{
_talkTimer -= elapsed * 20;
}

if (!_fadingIn && !_fadingOut)
{
#if !FLX_NO_KEYBOARD
if (FlxG.keys.anyJustReleased([X]))
{
_fadingOut = true;
FlxTween.num(1, 0, .66, { type:FlxTween.ONESHOT, ease:FlxEase.circOut, onComplete:function(_) {
FlxTween.num(1, 0, .66, { type:FlxTween.ONESHOT, ease:FlxEase.circOut, onComplete:function(_)
{
close();
}},updateAlpha);
}}, updateAlpha);
}
#end
#if !FLX_NO_TOUCH
var t:FlxTouch = FlxG.touches.getFirst();
if (t != null)
if (t != null && t.justReleased)
{
if (t.justReleased)
_fadingOut = true;
FlxTween.num(1, 0, .66, { type:FlxTween.ONESHOT, ease:FlxEase.circOut, onComplete:function(_)
{
_fadingOut = true;
FlxTween.num(1, 0, .66, { type:FlxTween.ONESHOT, ease:FlxEase.circOut, onComplete:function(_) {
close();
}}, updateAlpha);
}
close();
}}, updateAlpha);
}
#end
}
Expand Down
16 changes: 7 additions & 9 deletions Arcade/Flixius/source/PlayState.hx
Expand Up @@ -290,17 +290,15 @@ class PlayState extends FlxState
_sprPlayer.velocity.y = 40;
}
}
else
else if (!_fading)
{
if (!_fading)
_fading = true;
FlxG.sound.music.fadeOut(.6);
FlxG.camera.fade(FlxColor.BLACK, .8, false, function()
{
_fading = true;
FlxG.sound.music.fadeOut(.6);
FlxG.camera.fade(FlxColor.BLACK, .8, false, function() {
FlxG.sound.music.stop();
FlxG.resetState();
});
}
FlxG.sound.music.stop();
FlxG.resetState();
});
}

_txtScore.text = Std.string(_score);
Expand Down
7 changes: 4 additions & 3 deletions Arcade/FlxPongApi/source/Ball.hx
Expand Up @@ -31,7 +31,8 @@ class Ball extends PongSprite

public function init():Void
{
_exhaust = Reg.PS.emitterGroup.recycle(Emitter, function() {
_exhaust = Reg.PS.emitterGroup.recycle(Emitter, function()
{
return new Emitter(x, y, 2, Reg.med_lite);
}, true);
_exhaust.acceleration.set(0, 0.5);
Expand Down Expand Up @@ -64,9 +65,9 @@ class Ball extends PongSprite
velocity = DEFAULT_VELOCITY();
}

override public function kill():Void {
override public function kill():Void
{
_emitter.start(true);

super.kill();
}
}
6 changes: 2 additions & 4 deletions Arcade/FlxPongApi/source/Enemy.hx
Expand Up @@ -25,13 +25,11 @@ class Enemy extends PongSprite
{
acceleration.x = acceleration.y = 0;

if (Reg.PS.ball.my < my) {
if (Reg.PS.ball.my < my)
velocity.y = -Reg.level;
}

if (Reg.PS.ball.my > my) {
if (Reg.PS.ball.my > my)
velocity.y = Reg.level;
}

super.update(elapsed);
}
Expand Down
84 changes: 55 additions & 29 deletions Arcade/FlxPongApi/source/MenuState.hx
Expand Up @@ -38,7 +38,8 @@ class MenuState extends FlxState
private var _input2:FlxTextField;
private var _imageDisplay:FlxSprite;

inline private static function API_TEST_BUTTONS():Array<Array<String>> {
private static inline function API_TEST_BUTTONS():Array<Array<String>>
{
return [["fetchUser", "authUser", "openSession", "pingSession"],
["closeSession", "fetchTrophy", "addTrophy", "fetchScore"],
["addScore", "getTables", "fetchData", "setData"],
Expand Down Expand Up @@ -154,30 +155,35 @@ class MenuState extends FlxState
_apiPages = [];
_apiCurrentPage = 0;

for (i in 0...API_TEST_BUTTONS().length) {
for (i in 0...API_TEST_BUTTONS().length)
{
_apiPages.push(new FlxGroup());

var button1:Button;
var button2:Button;
var button3:Button;
var button4:Button;

if (API_TEST_BUTTONS()[i][0] != null) {
if (API_TEST_BUTTONS()[i][0] != null)
{
button1 = new Button(xpos, ypos[0], API_TEST_BUTTONS()[i][0], apiCallback, buttonwidth);
_apiPages[i].add(button1);
}

if (API_TEST_BUTTONS()[i][1] != null) {
if (API_TEST_BUTTONS()[i][1] != null)
{
button2 = new Button(xpos, ypos[1], API_TEST_BUTTONS()[i][1], apiCallback, buttonwidth);
_apiPages[i].add(button2);
}

if (API_TEST_BUTTONS()[i][2] != null) {
if (API_TEST_BUTTONS()[i][2] != null)
{
button3 = new Button(xpos, ypos[2], API_TEST_BUTTONS()[i][2], apiCallback, buttonwidth);
_apiPages[i].add(button3);
}

if (API_TEST_BUTTONS()[i][3] != null) {
if (API_TEST_BUTTONS()[i][3] != null)
{
button4 = new Button(xpos, ypos[3], API_TEST_BUTTONS()[i][3], apiCallback, buttonwidth);
_apiPages[i].add(button4);
}
Expand All @@ -204,7 +210,8 @@ class MenuState extends FlxState

// Add everything to this screen

for (g in _apiPages) {
for (g in _apiPages)
{
_apiTest.add(g);
}

Expand Down Expand Up @@ -293,9 +300,12 @@ class MenuState extends FlxState
// with .readUTFBytes( ba.length ). The ba.length ensures that the ByteArray will be read from beginning to end
// and then stop; otherwise, there would be an error when the end of the ByteArray was reached.

if (!FlxGameJolt.initialized) {
if (!FlxGameJolt.initialized)
{
FlxGameJolt.init(19975, ba.readUTFBytes(ba.length), true, null, null, initCallback);
} else {
}
else
{
_connection.text = "Welcome back to the main menu, " + FlxGameJolt.username + "!";
}

Expand Down Expand Up @@ -351,27 +361,32 @@ class MenuState extends FlxState

private function switchMenu(Name:String):Void
{
if (_loginGroup.visible) {
if (_loginGroup.visible)
{
_input1.text = " ";
_input2.text = " ";
}

for (g in _allScreens) {
for (g in _allScreens)
{
g.visible = false;
g.active = false;
}

if (Name == "Back") {
if (Name == "Back")
{
_main.visible = true;
_main.active = true;
}

if (Name == "API Functions") {
if (Name == "API Functions")
{
_apiTest.visible = true;
_apiTest.active = true;
}

if (Name == "Log in") {
if (Name == "Log in")
{
_loginGroup.visible = true;
_loginGroup.active = true;
}
Expand All @@ -393,7 +408,8 @@ class MenuState extends FlxState
_imageDisplay.visible = false;
_return.text = "Sending " + Name + " request to GameJolt...";

switch (Name) {
switch (Name)
{
case "fetchUser":
FlxGameJolt.fetchUser(0, FlxGameJolt.username, [], apiReturn);
case "authUser":
Expand Down Expand Up @@ -459,7 +475,8 @@ class MenuState extends FlxState
{
_return.text = "The user authentication returned: " + Success;

if (!Success) {
if (!Success)
{
_return.text += ". This is probably because the user is already authenticated! You can use resetUser() to authenticate a new user.";
}
}
Expand All @@ -469,46 +486,55 @@ class MenuState extends FlxState
_apiPages[_apiCurrentPage].visible = false;
_apiPages[_apiCurrentPage].active = false;

if (Name.charCodeAt(0) == 60) {
if (Name.charCodeAt(0) == 60)
{
_apiCurrentPage--;
} else if (Name.charCodeAt(0) == 62) {
}
else if (Name.charCodeAt(0) == 62)
{
_apiCurrentPage++;
}

if (_apiCurrentPage < 0) {
if (_apiCurrentPage < 0)
_apiCurrentPage = _apiPages.length - 1;
}

if (_apiCurrentPage > _apiPages.length - 1) {
if (_apiCurrentPage > _apiPages.length - 1)
_apiCurrentPage = 0;
}

_apiPages[_apiCurrentPage].visible = true;
_apiPages[_apiCurrentPage].active = true;
}

private function initCallback(Result:Bool):Void
{
if (_connection != null) {
if (Result) {
if (_connection != null) {
if (_connection != null)
{
if (Result)
{
if (_connection != null)
{
_connection.text = "Successfully connected to GameJolt! Hi " + FlxGameJolt.username + "!";
}

FlxGameJolt.addTrophy(5072);

if (_login.visible) {
if (_login.visible)
{
_login.visible = false;
_login.active = false;
}

if (_loginGroup.visible == true) {
if (_loginGroup.visible == true)
{
switchMenu("Back");
}

//FlxGameJolt.fetchAvatarImage( avatarCallback );
} else {
if (_connection != null) {
}
else
{
if (_connection != null)
{
_connection.text = "Unable to verify your information with GameJolt.";
}
_login.visible = true;
Expand Down
3 changes: 2 additions & 1 deletion Arcade/FlxPongApi/source/PlayState.hx
Expand Up @@ -146,7 +146,8 @@ class PlayState extends FlxState

public function newObstacle():Void
{
var obs:PongSprite = _obstacles.recycle(PongSprite, function() {
var obs:PongSprite = _obstacles.recycle(PongSprite, function()
{
return new PongSprite(FlxG.width, FlxG.random.int(0, FlxG.height),
FlxG.random.int(1, 20), FlxG.random.int(4, 40), Reg.med_dark);
});
Expand Down

0 comments on commit a38d7ef

Please sign in to comment.