Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - caladan21ph

Pages: [1] 2 3
1
help / Variable jump with FlxControl
« on: Sun, Jul 12, 2015 »
Hi,

Anyone here have any idea how to make variable jump( height of jump depends on how long the player presses the key) work
with FlxControl?

Thanks!


2
Hi, solved my problem. It seems that FlxButtonPlus checks if the mouse is hovering over a button using screen coordinates. I just added a new parameter to FlxButtonPlus to check for either screen or world coordinates( and set it to check for world coordinates) and it worked.

Code: [Select]
if (FlxMath.mouseInFlxRect(_worldCoords, buttonNormal.rect))
{
offAll = false;

if (FlxG.mouse.justPressed())
{
_status = PRESSED;
}

if (_status == NORMAL)
{
_status = HIGHLIGHT;
}
}

3
I'm also having this problem. When I scroll the camera, it seems as if the rect used to check for mouseover is left in the original position.
Anyone have the answer to this question?

4
help / Re: Anyone have access to FlxMovieClip?
« on: Wed, Jun 3, 2015 »
Hi,

Thanks a lot! Tried it but I'm getting some sort of bitmap error.

Do I just create an instance of this, and pass my swf as a class and add it like a regular FlxObject?

Thanks,

-Tristan

5
help / Anyone have access to FlxMovieClip?
« on: Sun, May 31, 2015 »
Hi,

I've read about  FlxMovieClip while try to read about how to use swfs with flixel. Unfortunately, the site doesn't seem to exist anymore.
Anyone here know where to get FlxMovieClip or can give me an idea how use swfs with flixel?

Thanks!

-Tristan

6
help / Re: Implementing Stealth Mechanics
« on: Mon, Oct 28, 2013 »
Thanks for the response!

Would you happen to know any good algos for this? Basically my game is 2D and the gameplay will be that the player will be controlling one character at a time( while the other two follow) and have them accomplish goals in the level without being seen by the enemies. If you're familiar with Commandos for the pc then the gameplay will be like that except 2D.


-Tristan

7
help / Implementing Stealth Mechanics
« on: Sun, Oct 27, 2013 »
Hi!

I'm currently doing a stealth game and these are the mechanics I want to implement:

1) Field of View- I want the enemies to have a cone FOV and detect the player inside the cone.
2) Detect sounds- if the player makes some noise within an area enemies will detect him


How should I go about doing this?

Thanks!

-Tristan

8
help / Problem with movement
« on: Sun, Mar 3, 2013 »
Hi,

I'm having a little problem with the movement of my sprites. The thing is, the sprite can't move horizontally unless its jumping. I have a separate class to control the sprite movements and I'm using FlxControl. When I use Flxcontrol inside of the sprite itself, there is no problem but when I use my ControlHandler class(which is using Flxcontrol) then the problem appears. I'm pasting my code here:
Code: [Select]

Here's my Controller class:
package Tristan
{
import flash.utils.Dictionary;
import org.flixel.FlxG;
import org.flixel.plugin.photonstorm.*;
import org.flixel.plugin.photonstorm.FlxControl;
import org.flixel.FlxObject;

/**
* ...
* @author Tristan Angeles
*/
public class ControlHandler
{

private static var _instance:ControlHandler;
private var controlDict:Dictionary;



//controller types
public static  var ARROWKEYS:uint = 0;
public static var WASD:uint = 1;
public static var HJKL:uint = 2;
//public static var typesArray:Array = [0, 1,2];

//controller array
private var controllerArray:Vector.<FlxControlHandler>;


//movement
private var xSpeed:uint=0;
private var ySpeed:uint=0;
private var maxSpeedX:uint = 0;
private var maxSpeedy:uint = 0;
private var xDecel:uint = 0;
private var yDecel:uint = 0;
private var jumpHeight:uint = 0;
private var jumpRepeat:uint = 0;
private var gravity:uint = 0;
private var fall:uint = 0;


public static function Instance():ControlHandler
{
if (_instance == null)
{
_instance = new ControlHandler();
trace("ControlHandler instantiated");

}

return _instance;
}




public function ControlHandler()
{
if (FlxG.getPlugin(FlxControl) == null)
{
FlxG.addPlugin(new FlxControl);
}

controllerArray = new Vector.<FlxControlHandler>;
controlDict = new Dictionary();


}




public function AddControl(numPlayer:uint):void
{
//check if there is an instance of game handler
if (!GameHandler.Instance()) throw new Error("GameHandler not instantiated");
trace(numPlayer);


//get player from game handler and get control type
var player:Player = GameHandler.Instance().GetPlayer(numPlayer);
var type:uint = player.ctrlType;
var controllerNumber:uint = player.controllerNumber;

//create an instance of Flxcontrol handler
var controller:FlxControlHandler=FlxControl.create(player.currentShifter,
FlxControlHandler.MOVEMENT_ACCELERATES, FlxControlHandler.STOPPING_DECELERATES, controllerNumber, true, false);





//add controller to controllerArray
controllerArray.push(controller);

if (controllerArray.length != 0)
{
setControlStats(player.ctrlType,controller);
}

controlDict[controller] = player.PlayerID;









}

public function GetPlayerController(playerID:String):FlxControlHandler
{
return controlDict[playerID];
}



public function setControlStats(playerNum:uint,controller:FlxControlHandler):void
{
//set FlxControlHandler to player's control type
switch(playerNum)
{
case ARROWKEYS:
controller.setCursorControl(false, false, true, true);
controller.setJumpButton("UP", FlxControlHandler.KEYMODE_PRESSED,jumpHeight,FlxObject.FLOOR, jumpRepeat,fall);

break;

case WASD:
controller.setWASDControl(false, false, true, true);
controller.setJumpButton("W", FlxControlHandler.KEYMODE_PRESSED,jumpHeight, FlxObject.FLOOR, jumpRepeat,fall);

break;
case HJKL:
controller.setHJKLControl(false, false, true, true);
break;
}

controller.setMovementSpeed(xSpeed, ySpeed, maxSpeedX, maxSpeedy,xDecel,yDecel);
controller.setGravity(0, gravity);
FlxControl.start();
}




public function ShiftControl(player1:Player, player2:Player):void
{

FlxControl.clear();

//switch current shifters
var temp:Shifter = player1.currentShifter;
player1.currentShifter = player2.currentShifter;
player2.currentShifter = temp;





//then set those shifers to players current control
var ctrl1:FlxControlHandler = FlxControl.create(player1.currentShifter,
FlxControlHandler.MOVEMENT_ACCELERATES, FlxControlHandler.STOPPING_DECELERATES, player1.controllerNumber, true, false);
setControlStats(player1.ctrlType, ctrl1);


var ctrl2:FlxControlHandler = FlxControl.create(player2.currentShifter, FlxControlHandler.MOVEMENT_ACCELERATES,
FlxControlHandler.STOPPING_DECELERATES, player2.controllerNumber, true, false);
setControlStats(player2.ctrlType, ctrl2);

//flicker effects
FlxG.flash(0xfff);
player1.currentShifter.flicker(5);
player2.currentShifter.flicker(5);




}

public function InitializeController():void
{
xSpeed= GameHandler.gameXml.movement.@xSpeed;
ySpeed= GameHandler.gameXml.movement.@ySpeed;
maxSpeedX=GameHandler.gameXml.movement.@maxSpeedX;
maxSpeedy=GameHandler.gameXml.movement.@maxSpeedY;
xDecel = GameHandler.gameXml.movement.@maxSpeedY;
yDecel = GameHandler.gameXml.movement.@xDecel;
jumpHeight= GameHandler.gameXml.jump.@height;
jumpRepeat= GameHandler.gameXml.jump.@repeat;
gravity = GameHandler.gameXml.level.@gravity;
fall = GameHandler.gameXml.jump.@fall;


}




}

}

and here is the sprite it is trying to control:
Code: [Select]
package Tristan
{
import org.flixel.*;
import org.flixel.plugin.photonstorm.*;
import org.flixel.plugin.photonstorm.FlxControl;;

/**
* ...
* @author Tristan Angeles
*/
public class Shifter extends FlxSprite
{
[Embed(source = "../Assets/player1img.png")] private const image:Class;
[Embed(source = "../Assets/player2img.png")] private const image2:Class;
[Embed(source = "../Assets/playerImg.png")] private const test:Class;

private var _currentPlayer:Player = null;
private var _id:String;

public function Shifter(X:Number,Y:Number):void
{
super(X, Y);

immovable = false;
this.immovable = false;

//delete afterwards
//testCode();

}

public function initGraphics():void
{
//trace(_currentPlayer.PlayerID);
if (!_currentPlayer) throw new Error("_currentPlayer not set");


var spriteImage:Class;
switch(_currentPlayer.PlayerID)
{
case "player1":
trace("setting "+_currentPlayer.PlayerID+" image to "+"player1img");
spriteImage = image;
_id = "Max";
break;
case "player2":
trace("setting "+_currentPlayer.PlayerID+" image to "+"player2img");
spriteImage = image2;
_id = "Sam";
break;
default:
trace("setting "+_currentPlayer.PlayerID+" image to "+"default");
spriteImage = image;
break;

}



loadGraphic(spriteImage, true, true, 32, 64);
//scale = new FlxPoint(2, 2);
//add animations
this.addAnimation("move", [0, 1, 2, 3], 10, true);
this.addAnimation("idle", [4, 5, 6, 7], 5, true);

}


public function get Pos():FlxPoint
{
var pos:FlxPoint = new FlxPoint();
pos.x = this.x;
pos.y = this.y;

return pos;
}

public function set currentPlayer(player:Player):void
{

_currentPlayer = player;
trace("current player has been set to" + player.PlayerID);


}

public function get currentPlayer():Player
{
return _currentPlayer;
}


override public function update():void
{
super.update();



trace(velocity.x);
if (velocity.x != 0)
{
play("move");
trace("moving");
}

else
{
play("idle");
}


super.update();

}


public function Show():void
{
if (!_currentPlayer) return;
trace(_id + " current controller is" + _currentPlayer.PlayerID);
}


public function testCode():void
{
if (FlxG.getPlugin(FlxControl) == null)
{
FlxG.addPlugin(new FlxControl)
}

FlxControl.create(this, FlxControlHandler.MOVEMENT_ACCELERATES, FlxControlHandler.STOPPING_DECELERATES, 3, true, false);
FlxControl.player3.setCursorControl(false, false, true, true);
FlxControl.player3.setMovementSpeed(400, 0, 200, 200, 400, 0);
FlxControl.player3.setJumpButton("UP", FlxControlHandler.KEYMODE_PRESSED, 250, FlxObject.FLOOR, 250, 200);
FlxControl.player3.setGravity(0, 400);

}



}

}



Thanks!

9
help / Re: Sprite not updati g
« on: Sat, Nov 24, 2012 »
I missed that. :( Thanks a lot! :)

10
help / Sprite not updati g
« on: Fri, Nov 23, 2012 »
Hi! I need help making this work. Somehow the sprites are not moving even after I set their velocity. Can anyone show me the problem? Thanks! Heres my code:

Code: [Select]
package Elenin
{
import org.flixel.*;
/**
* ...
* @author
*/
public class Playstate extends FlxState
{

public var player:Elenin.Player;
public var test:Elenin.Obstacle;
override public function create():void
{
FlxG.mouse.show();


add(Elenin.GameUI.Instance());
if (!Elenin.GameUI.Instance()) throw new Error("There must be an instance of GameUi");

add(Elenin.ObstacleManager.Instance());
if (!Elenin.ObstacleManager.Instance()) throw new Error("There must be an instance of obstacleManager");


/*test = new Elenin.Obstacle(200, 200,32);
add(test);
test.velocity.x = 10;*/

player = new Elenin.Player(100, 100);
add(player);


super.create();
}


override public function update():void
{
super.update();
}

public function Playstate()
{

}

}

}

Code: [Select]
package Elenin
{
import org.flixel.*;
/**
* ...
* @author
*/
public class ObstacleManager extends FlxGroup
{
private static var _instance:Elenin.ObstacleManager;

private var maxNumObstacles:uint = 50;
private var timer:uint = 0;
private var deployTime:uint = 5;



public static function Instance():Elenin.ObstacleManager
{
if (_instance == null) {
_instance = new Elenin.ObstacleManager();
}


trace("obstacleManager instantiated");
return _instance;


}

public function ObstacleManager()
{
for ( var i:uint = 0; i < maxNumObstacles;++i)
{
add(new Elenin.Obstacle());
//trace("obstacle added");
}

}


override public function update():void
{
timer += FlxU.getTicks() / 1000;
if (timer >= deployTime) {
Deploy();
timer = 0;
}

//trace(timer);
}


public function Deploy():void
{
var newObstacle:Elenin.Obstacle = Elenin.Obstacle(getFirstAvailable());

//if (newObstacle == null) throw new Error("newObstacle is null");

if (newObstacle)
{
newObstacle.Deploy();

}

//Elenin.Obstacle(getFirstAvailable()).Deploy();
}

}

}

Code: [Select]
package Elenin
{
import org.flixel.*;
import org.flixel.FlxSprite
import org.flixel.FlxG;

/**
* ...
* @author
*/
public class Obstacle extends FlxSprite
{

private var size:uint
public function Obstacle():void
{
super(0, 0);

size = 32;
makeGraphic(size, size, 0xffffffff, false);
exists = false;

}



public function Deploy():void
{

x = Elenin.MathUtils.randRange(100, 600);
y = Elenin.MathUtils.randRange(10, 450);
velocity.x = 100;

trace("x:" + this.x + ",y:" + this.y);
//trace(exists);

trace("obstacle deployed");
exists = true;

}

override public function update():void
{
//x += 1
trace("updated");
super.update();
}

}

}



Thanks!

11
help / Audio input
« on: Thu, Jul 5, 2012 »
Hi! I'm joining the experimental gameplay project this month and the theme is audio input. Seems like a great theme
however I have no idea where to start. Can anyone give tips or links to tutorials(or libraries) about the basics of audio input? I'm thinking of just a simple game. Enemies are approaching and you have to scare them by making different pitches of sound. Is this a hard thing to make?How do I check for this?


Thanks!

12
help / Bullets not spawning when player leaves area
« on: Mon, Mar 5, 2012 »
Hi! I'm having the problem that when the player leaves a certain area of the map bullets stop spawning. I'm using Flxweapon from the photonstorm plugin. What could be the cause of this problem? Heres the code for my player class. Thanks!

{
   import org.flixel.*;
   import org.flixel.plugin.photonstorm.*;
   import org.flixel.plugin.photonstorm.FlxControl;
   /**
    * ...
    * @author
    */
   public class Player extends FlxSprite
   {
      
      public var weapon:FlxWeapon;
      
      
      public function Player(X:Number,Y:Number):void
      {
         super(X, Y);
         loadRotatedGraphic(GFX.playerPNG, 360, -1, true,true);
         elasticity = 1;
         
         
         
         weapon = new FlxWeapon("lazer", this, "x", "y");
         weapon.makeImageBullet(40, GFX.bulletImage, 8, 2, true, 360, -1, true, true);
         weapon.setBulletSpeed(200);
         
         
         
         
         
         
         
         if (FlxG.getPlugin(FlxControl) == null)
         {
            FlxG.addPlugin(new FlxControl);
         }
         
         FlxControl.create(this, FlxControlHandler.MOVEMENT_INSTANT, FlxControlHandler.STOPPING_INSTANT,1,false,true);
         FlxControl.player1.setRotationKeys(true, false);
         FlxControl.player1.setRotationSpeed(400, 400, 200,400);
         FlxControl.player1.setThrust("UP", 200);
         FlxControl.player1.setFireButton("SPACE", FlxControlHandler.KEYMODE_PRESSED, 250, weapon.fireFromParentAngle);
         
         
         
         
      }
      
   }

}

13
help / Re: Getting the player position using color
« on: Sun, Mar 4, 2012 »
It worked!Thanks! :) BTW I'm studying your work. Great stuff!!

14
help / Getting the player position using color
« on: Sat, Mar 3, 2012 »
Hi! I'm trying to use Paint.net to draw the level and then just use FlxTilemap.bitmapToCsv. What I want to do this is to specify the player starting position in the map using a color. How would I go about doing this? Thanks!

15
help / Art for games
« on: Wed, Jan 25, 2012 »
Hi! I've a few questions here regarding art assets for games. I need to know there before the Global Game Jam starts.

1) How do I arrange the tileset if I want to create my own tiles and use flixel's autotiling?
2)Should all sprites in the game have the same sizes e.g. all sprites are 16x16 .

Thanks!

16
help / Re: Help with the math
« on: Fri, Jan 20, 2012 »
Well the main difference is that game won't be using the directional buttons. The player will just automatically jump to the platform nearest to him. The platforms will be coming from the top of the screen and then descend. I just need to know how to make an object travel in arc from the current platform he is stepping on to another platform. I'll make a pic then post in.
Its for the experimental gameplay project for this month. The controls will be sensors that the player will be stepping on. If a player is not stepping on a sensor it means that he's jumping from one platform.Something like that.

17
help / Help with the math
« on: Fri, Jan 20, 2012 »
Okay, so I'm making a small game wherein the player jumps between small platforms. In the game, the player jumps automatically when no buttons are currently pressed. What I want to happen in the game is to make the player jump in arc from one platform to the next.Basically all I need is help to create the animation of the player jumping from one platform to the next automatically. How do I do this(if there is math involved please share). Thanks!

18
help / The best way to implement dialogue in games
« on: Sun, Jan 15, 2012 »
What is the best way to implement dialogue in games? By this, I mean the boxes that show what the characters are saying. Do I put the dialogue in the code or load it from somewhere like a text file for example. What if I want the words to appear one by one? Thanks!

19
help / Re: Removing objects when not on screen
« on: Tue, Jan 10, 2012 »
Ok, I did it, thanks!:) I had a problem with onscreen because I created the platforms outside of the screen first before the camera can get to it. I'm trying to experiment on randomly generating levels, this one is for something like canabalt(what do you call these types of games anyway). For these kinds of games how are the platforms normally made?

20
help / Removing objects when not on screen
« on: Tue, Jan 10, 2012 »
hello! How do I make it so that objects which are not on screen are removed from the game. I'm using flxgroups to create platforms made up of tiles. I want the platforms to disappear when it is no longer in sight because it slows down the game. Thanks!

Pages: [1] 2 3