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 - zez

Pages: 1 [2]
21
So, I was using FlxG.scores to hold all the information about the player in my game (so, stats, skills, and race) everything in there is a number, save for race, which is a string. It was working fine till I tried to load the array. I have the array saved on my server as a file, containing a comma separated string representing all the data, and I load it into scores using string.split(",")
That works fine, and the array is loaded, and everything displays correctly in game, but if any of the values get changed, it goes crazy. the basic exp goes from whatever number is being displayed to NaN, Im assuming that happens because its being treated as a string and not a number, and adding a number to a string doesnt work, and the skill exp instantly hits the level cap, and proceeds to run the skill level event 19 times, a little broken, seeing as the skill exp gets reset to zero every time the event is run, and the event is triggered by the skill exp being > 23 times the skill level. Also worth noting, it worked fine till I imported the array.
Im assuming all the data after the race is being treated as a string, and thats whats breaking it (although that still leaves me a little baffled with the skill leveling up so much, as I would assume it would either loop the event infinitely, because a number is always greater then a string * 23, or just never hit 23 * the level... its even weirder, because it displays the correct value for 23 * the level, and the exp does go up as expected.)

I am also having this same problem if I omit the race string, and use a number instead, so that theory is a little bit more broken... Im friggin confused though.

22
help / If anyone else wants (near) infinite levels.
« on: Mon, Mar 15, 2010 »
so, My current project is a dungeon crawler with randomly generated levels (currently my generator is really primitive, it just places either nothing or a random tile at each possible map coordinate, gets rid of the tiles at entrances, then uses a drunkards walk to make the actual playable space.)
at the start of the playstate, it checks to say what level you are currently entering, and if you are entering from the top, bottom, left, or right. It then checks to see if that level exists, and if it does, loads it, and sets the players coordinates, and if it doesnt, generates the level, then loads it and sets coordinates. (This is temporary, currently the generator is a flxstate, so that I can watch it work well Im tweaking the code, the plan is to have it run during the playstate, and save a new map when one doesnt exist.)

Anyhow, thats all well and good, the bit of this I actually thought was worth sharing was how I dealt with determining what level to load. Basically, at the start of the playstate, you load the tilemap file based on a number in the playstates function, every time you leave the map at the bottom, you go to level (whatever level you are on + 1) and the player is set to spawn from the top entrance, every time you leave from the top, you go to level (whatever you are on - 1) fairly straight forward, if you start at level zero, then go down a screen, you are at level 1, you go down again, your at level 2, you go back up, your back to level 1 etcetc. the maps all line up, and there are infinite levels, cool. A little bit linear though. Heres the nifty bit, you go to the right, and the level suddenly jumps up by +1000, meaning, you go down 1 and right 1 and you are at level 1001, right another 2 and up 3 and you just hit level 2998. Seems wonky, I know. Next step, moving left makes the level go down by 1000 (-1000,) meaning, if you go 1 right, you go to level 1000, if you then go 1 left, you are back at level 0, you go up 1 you hit level -1, you go 1 to the right, you hit level 999, you go down 1 you hit level 1000, back left and you hit level 0 again, making a total loop.
The one 'shortcoming' of this method, is that theoretically, if you ran straight down for enough screens you would eventually end up on the screen thats 1 to the right of your starting position. I used 1000 as the left/right variable for this reason. Granted, that does mean that 1 left and 500 down  is the same level as 1 right and 500 up, but I think its pretty unlikely anyone will ever make it that far, seeing as the levels usually deadend in 1 or 2 directions (so far, It has never generated a true dead end level, but it does regularly generated levels where you can only go from 1 entrance/exit to 1 other one, making it a dead end from two directions,) and thats really far. Im also fairly sure if anyone DID make it that far, in both possible directions, they wouldnt notice that the level was the same.

Anyhow, this post is really long, so Ima summarize the important part, in psuedo code;
Code: [Select]
if (_player.x > (the right side of the level))
{
level value + 1000,
new level
}
if (_player.x < (zero, or 1 or 2 tiles, depending)(the left side of the level))
{
level value - 1000,
new level
}
if (_player.y > (the bottom of the level))
{
level value + 1,
new level
}
if (_player.y <(probably zero, or 1 or 2 tiles) (the top of the level))
{
level value - 1,
new level
}
and suddenly you have near infinite levels!

23
help / Tilemap MapData exporting..?[solved!]
« on: Sun, Mar 14, 2010 »
Is there a way to get the MapData back out of a tilemap? I know I could just use getTile a billion times, but that seems like an awful way of doing it. Is there a way to get a whole row at once as a string?

24
help / some confusion interfacing with PHP[solved]
« on: Sat, Mar 13, 2010 »
So, theoretically, this code will check if a folder with the name of the variable I sent to it exists, and if it doesnt, create said folder (the variable _map is getting sent as well, but shouldnt be doing anything...)
In practice, nothing happens. The Actionscript side of things runs, doesnt give any errors, and after a second or two, runs the event complete, but no new folders have been made, and the value Im passing as user_account is not a folder that exists. Anyhow, here's the PHP
Code: [Select]
<?php
function MakeDirectory($user_account$mode 0755)
{
$user_account $_post['user_account'];
  if (
is_dir($user_account) || @mkdir($user_account,$mode)) return TRUE;
  if (!
MakeDirectory(dirname($user_account),$mode)) return FALSE;
  return @
mkdir($user_account,$mode);
}
?>
and here's the Actionscrip
Code: [Select]
{
import flash.events.Event;
import flash.net.*;
import org.flixel.*;
public class Server extends FlxState
{
private var account:URLVariables
private var loader:URLLoader
private var request:URLRequest

override public function Server(stage:Number, user:String):void
{
var txt:FlxText
txt = new FlxText(0, (FlxG.width / 2) - 80, FlxG.width, "map doesnt exist")
txt.setFormat(null, 16, 0xFFFFFFFF, "center")
this.add(txt);

request = new URLRequest("myserver/flash/users/user.php")
account = new URLVariables();
loader = new URLLoader();
account.user_account = user;
account._map = stage;
request.data = account;
request.method = URLRequestMethod.POST;
loader.addEventListener(Event.COMPLETE, huzzah);
loader.load(request);
}
private function huzzah(e:Event):void
{
var txt:FlxText
txt = new FlxText(0, (FlxG.width / 2), FlxG.width - 80, "test event worked")
txt.setFormat(null, 16, 0xFFFFFFFF, "center")
this.add(txt);
}
}
}
Im sure that my server allows the mkdir command (I already asked the admin, to make sure that wasnt the problem) and Im fairly sure the permissions are set up correctly, I am not however, very confident in my ability to work between actionscript and php, as I have never tried to do it before (this is my first time doing much of anything in PHP, and Im still a bit of an actionscript noob...) so I would put money on this being a problem with my code...

25
help / overlaps
« on: Mon, Mar 8, 2010 »
So, FlxU.overlap seems to either instantly kill whatever is overlapping (if the function is set to null), or freeze (visibly, it apparently isnt frozen, as things can still move out of the overlap) my app till the overlap isnt happening by running some function a gagillion(oh man the spell check results on that word are awesome) times.
How would I check if two things (in this case, both groups) are overlapping without breaking everything, or having to make them no longer overlap as soon the event triggers (because I actually WANT them overlapping, in this case, I just want to know if they are...)

26
so, attempting to get my map data from a txt file on a separate host, theoretically the permissions are set up for reading and writing, the code just idles forever tho. compiles fine, no weird error's, the does.... nothing. Im a little stumped, and I think Iv been staring at this altogether to long, so maybe an extra set of eyes?


{
   import org.flixel.*;
   import flash.display.Loader;
   import flash.net.URLRequest;
   import flash.events.Event;
   
   public class MapLoader extends FlxState
   {
      private var yoinkmap:Loader;
      public var map:String;
      public function MapLoader():void
      {
         var txt:FlxText
         txt = new FlxText(0, (FlxG.width / 2) - 80, FlxG.width, "Loading...")
         txt.setFormat(null, 16, 0xFFFFFFFF, "center")
         this.add(txt);
         yoinkmap = new Loader();
         yoinkmap.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
         yoinkmap.load(new URLRequest("http://cropcrusade.netai.net/flash/maps/map.txt"));
      }
      override public function update():void
      {
         super.update();
      }
      private function loadComplete(event_load:Event):void
      {          
      map = event_load.target.content;
      FlxG.state = new PlayState();
      }
   }
}

27
So, I guess basically, my questions are; is there a way to have a variable that controls what graphic is used for a sprite, and is there a way to remote load data that would normally be embedded?

Im working on a top down dungeon crawler, and I want the player to be able to be able to choose what graphic they use for there character, as well as modify (through the game itself, and there choices, not a level editor) the levels themselves. Im planning on having the whole thing running online, with accounts set up for each player that store the whole of there world and all variables associated with the actual character. This is more an issue with the map then the player, as I could just deal with a variable controlling what animations are used, and have 1 giant sprite sheet, although that seems kind of bassackwards, but I would still want the map array to be modifiable...

Pages: 1 [2]