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.


Topics - caladan21ph

Pages: [1] 2
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
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

3
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

4
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!

5
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!

6
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!

7
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);
         
         
         
         
      }
      
   }

}

8
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!

9
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!

10
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!

11
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!

12
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!

13
help / help with this dungeon generator problem
« on: Fri, Dec 30, 2011 »
http://roguebasin.roguelikedevelopment.org/index.php/Complete_Roguelike_Tutorial,_using_python%2Blibtcod,_part_3#Dungeon_building_blocks  hi! I'm trying to convert the python code above to flixel and I'm getting errors. Anyway, here is my code :

package com 
{
   import org.flixel.*;
   /**
    * ...
    * @author
    */
   public class Level extends FlxGroup
   {
      private const _tileWall:uint = 1;
      private const _tileEmpty:uint = 0;
      private var _tileMap:FlxTilemap;
      private var _tilesX:uint; //the number of tiles per row
      private var _tilesY:uint; //the number of tiles per column
      private var _maxRoomSize:uint; //the max width of each rooms
      private var _minRoomSize:uint; //the max height of each room
      
      private var _levelArray:Array;
      private var _finalArray:Array;
      
      private var _maxNumRooms:uint;
      private var _numRooms:uint;
      private var _rooms:Array;
      private var _tileSize:uint;
      
      //starting position of player
      public var playerX:uint;
      public var playerY:uint;
      
      
      [Embed(source = "../res/tileMap.png")] private const tileMapPNG:Class;
      
      public function Level(tilesX:uint,tilesY:uint,maxNumRooms:uint,tileSize:uint):void
      {
         _tilesX =tilesX;
         _tilesY = tilesY;
         _tileSize = tileSize;
         _maxNumRooms = maxNumRooms;
         _numRooms = 0;
         _minRoomSize = 6;
         _maxRoomSize = 10;
         
         
         generate_level();
         
         
         
         _tileMap = new FlxTilemap();
         _tileMap.loadMap(FlxTilemap.arrayToCSV(_finalArray, _tilesX), tileMapPNG, _tileSize, _tileSize);
         add(_tileMap);
         FlxG.watch(this,'_levelArray');
      }
      
      
      public function generate_level():void
      {
         
         fillLevel();
         
         //trace(_levelArray);
         
         generateRooms();
         generateFinalMap();
         
                     
         
         
         
         
         
         
         
      }
      
      
      
      
      public function fillLevel():void
      {
         _levelArray=new Array();
         for (var xi:uint = 0; xi < _tilesX; xi++)
         {
            _levelArray.push(new Array);
            for (var yi:uint = 0; yi <_tilesY; yi++)
            {
               _levelArray[xi][yi]=_tileWall;
            }
         }
      }
      
      
      
      
      
      public function generateRooms():void
      {
         _rooms = new Array();
         //var room:Room = new Room(new FlxRect(50, 10, 10, 5));
         //
         //createRoom(room);
         for (var i:uint = 0; i < _maxNumRooms; i++)
         {
            var w:uint =  _minRoomSize + Math.round(Math.random() * (_maxRoomSize-_minRoomSize));
            var h:uint = _minRoomSize + Math.round(Math.random() * (_maxRoomSize-_minRoomSize));
            var x:uint = Math.floor(Math.random() * _tilesX-_maxRoomSize-1);
            var y:uint = Math.floor(Math.random() * _tilesY-_maxRoomSize-1);
            trace(_levelArray.length);
         
         
            var room:Room = new Room(new FlxRect(x, y, w, h));
            createRoom(room);
            
         }
         
            
            
         
         

         
      }
      
      
      public function createRoom(room:Room):void
      {
         
         trace(_levelArray.length);
         
         for (var xi:uint = room.x+1; xi < room.x2; xi++)
         {
            for (var yi:uint = room.y+1; yi < room.y2; yi++)
            {
               _levelArray[xi][yi] = _tileEmpty;
            }
         }
         
         
      }
      
   
      
      
      
      
      
      public function generateFinalMap():void
      {
         _finalArray = new Array();
         for (var yi:uint = 0; yi < _tilesY; yi++)
         {
            for (var xi:uint = 0; xi < _tilesX; xi++)
            {
               _finalArray.push(_levelArray[yi][xi]);
            }
         }
      
      }
         
   }

}


sorry for the bad code. The error I'm getting is this:
TypeError: Error #1010: A term is undefined and has no properties.
   at com::Level/createRoom()[D:\Game Development\Flash Projects\RogueLike\src\com\Level.as:133]
   at com::Level/generateRooms()[D:\Game Development\Flash Projects\RogueLike\src\com\Level.as:111]
   at com::Level/generate_level()[D:\Game Development\Flash Projects\RogueLike\src\com\Level.as:62]
   at com::Level()[D:\Game Development\Flash Projects\RogueLike\src\com\Level.as:44]
   at com::PlayState/create()[D:\Game Development\Flash Projects\RogueLike\src\com\PlayState.as:14]
   at org.flixel::FlxGame/switchState()[D:\Game Development\Flash Projects\RogueLike\src\org\flixel\FlxGame.as:499]
   at org.flixel::FlxGame/step()[D:\Game Development\Flash Projects\RogueLike\src\org\flixel\FlxGame.as:544]
   at org.flixel::FlxGame/onEnterFrame()[D:\Game Development\Flash Projects\RogueLike\src\org\flixel\FlxGame.as:453]


Sometimes the code works and sometimes it gets the error. I really can't find the problem and I've been trying to solve this so I would appreciate any help. Thanks! :)

14
help / Making wandering monster need help
« on: Sun, Dec 18, 2011 »
Hi! I'm in mid Ludum Dare. ;D One of the monsters in my game is supposed to wander around randomly throughout the map or move towards the player character. Can anyone help me regarding the use of the flixel pathfinding(saw this in the features) to move towards the charatcer or make the monster wander randomly? Or is there a function in flixel for checking if there is in a tile? For example: check if there is an object to the north of the character, or west of the character.

Thanks a lot, gotta get back to the fray!

15
help / Saving the player's progress
« on: Mon, Nov 28, 2011 »
How  does one save the user's progress in the game in game portal's like Kongregate? What I want to do in my game is to have a level selection screen like in Diamond Hollow 2. Is there a flixel class for that? Thanks!

16
games / Something I made with Flixel
« on: Thu, Nov 24, 2011 »
Hi! This is one of the first games I made with Flixel and my entry to the mini Ludum Dare. Decided to post it here since I want to get involved more with this community. Its more of something I made for learning rather than a complete game. Here it is:http://www.kongregate.com/games/caladan21ph/the-adaptor . Hopefully I'll get better with Flixel soon and be able to create bigger projects and perhaps collaborate with other people.

17
help / Regarding this DAME tutorial
« on: Sun, Nov 20, 2011 »
Hi! I would like to know for what version this DAME tutorial is: http://www.brighthub.com/hubfolio/matthew-casperson/articles/105366.aspx#comments . I'm using Flixel 2.55 and I still can't run it. There is an error regarding FlxSprite.RIGHT, FlxSprite.LEFT. I

Thanks!

18
help / Random level generation
« on: Sat, Nov 12, 2011 »
What programming concepts do I need to learn to make random levels for platformers or maze game? Someone led me to the procedural content wiki, but I have  no idea yet how to implement the algorithms there. Anyone familiar with the books Structure and Interpretation of Computer Programs, and Introduction to Algorithms? Are they good places to start if I want to learn about procedural level generation?

19
help / Getting players position from Dame map
« on: Sat, Nov 5, 2011 »
Hi! I'm trying to learn Dame ad so far I've managed to load the wall tiles in my map. However, I have no idea how to load the sprites in my map.How should I go about doing this?

20
Hello!  I'm reading Learning Action 3.0 a Beginners guide as per Photonstorm's recommendation on his blog. I would like to ask which topics in actionscript I should focus on the most or study much more deeply to really get a good grasp of the language. Thanks!


Pages: [1] 2