Page 6 of 13
Re: Flash
Posted: Sun Aug 02, 2009 2:50 pm
by hallsofvallhalla
i love the smell of code in the morning!
Re: Flash
Posted: Mon Aug 03, 2009 3:14 am
by SpiritWebb
hallsofvallhalla wrote:i love the smell of code in the morning!

LOL!
Re: Flash
Posted: Mon Aug 03, 2009 8:01 am
by SpiritWebb
Using actionscript and php, how would I go about taking the player, saving their current location when they log out, so that way when they log back in, they are in that spot they were last at?
Right now all it does is control the ship. But when you log out, then back in, the ship is back at the starting point when you first ran it.
Re: Flash
Posted: Mon Aug 03, 2009 8:16 am
by Jackolantern
Are you using a database? I would think that you could save their last location into the database, and add the replacement of the player at their last location to the start-up when the player logins in. When the start-up code runs, you could also have a condition that if no location is found for the player in the DB that is assumes the character is new and begins them in the default position. If you are not using a database, you would need to have about the same setup with some other kind of file or variable saving location.
Re: Flash
Posted: Mon Aug 03, 2009 8:25 am
by SpiritWebb
Im using MySql and php with it. So, yeah there is a database, but I just dont know how to set it up and make it work. Right now Im also working on trying to correct the error im getting with the code neronix gave me. The code that Agent fixed for me, is what I'm currently using with the flash file, works great until I can get the other working.
Re: Flash
Posted: Mon Aug 03, 2009 9:42 am
by Torniquet
not read the whole thread... so dnno wht ya lookin for or ya problems.. I dont rly know n e thin bout flash...
but head over toooooooo developphp.com they have quite a few flash/php tutorials. dunno if u can find summert in there tht mite help ya
LUBS xx
Re: Flash
Posted: Mon Aug 03, 2009 11:15 am
by Agent
SpiritWebb wrote:Using actionscript and php, how would I go about taking the player, saving their current location when they log out, so that way when they log back in, they are in that spot they were last at?
Right now all it does is control the ship. But when you log out, then back in, the ship is back at the starting point when you first ran it.
Like I said before, this is a tough job to pull off. I recommend sitting down with some paper and pen and mapping out the structure/functioning of the game in a layout map. So how server communicates with client / etc.
Anyway, currently I assume you just have your 'flash game' embedded in the html file following the login. This of course will not save the last known position by itself. SO you must have as i stated before a .php script that will communicate with your flash file (exchange variables).
So you could try to do something like this (I am just making this up on the spot, you will have to modify it to suit your needs):
You could get your positions last known position in a few ways i guess - but a smart - less process active way could be that on pressing the logout or save button / whatever - the engine executes a command to get the ships position and translate that over to a php variable which THEN externally saves out to a database. Then the same process back - when the play logs in the flash file searches for the locally stored player variable .php file and automatically asks for the x and y pos of the ship (when last saved) then translates that over. So something like this could be used-
getXPos = this._x;
getYPos = this._y;
where then for example -
$playerXPos = getXPos;
$playerYPos = getYPos;
and to set the ships position back on login -
this._x = $playerXPos; // or getXPos
this._y = $playerYPos; // or getYPos
See how you go with that...
Re: Flash
Posted: Mon Aug 03, 2009 6:58 pm
by SpiritWebb
neronix:
SpiritWebb wrote:lol...its cool.
I got it all to show, but now my map is all over the place...it places the map down on the far left, not centered...
what size should the map be? The map is centered to the ship, on its right border.
EDIT: When I press the down key and left or right, it quits moving...only up seems to work. I aim down, the map scrolls right. Aim right, map goes up, aim up, map goes left, aim left map goes down.
Any ideas on how i can fix this?
Re: Flash
Posted: Mon Aug 03, 2009 7:59 pm
by neronix17
SpiritWebb wrote:neronix:
SpiritWebb wrote:lol...its cool.
I got it all to show, but now my map is all over the place...it places the map down on the far left, not centered...
what size should the map be? The map is centered to the ship, on its right border.
EDIT: When I press the down key and left or right, it quits moving...only up seems to work. I aim down, the map scrolls right. Aim right, map goes up, aim up, map goes left, aim left map goes down.
Any ideas on how i can fix this?
If whats happened is what i think has then first when you make the map make sure its at 2000x2000, thats what my ones set to. The second problem i think would be the direction your ship is facing when you made the symbol, make sure it is facing towards the left and that should make it move properly, the problem with reversing is that my one didnt have that so Il go see if i can get it to do that for you just now
Re: Flash
Posted: Mon Aug 03, 2009 8:11 pm
by neronix17
right, for the code for reversing you just have to change one bit:
this
Code: Select all
// brake
if (Key.isDown(Key.DOWN)) {
speed *= 0.75;
}
to
Code: Select all
// brake
if (Key.isDown(Key.DOWN) && speed<maxspeed) {
speed -= [b]-1.5[/b];
}
the speed for going backwards is slightly slower than the speed of going forward but you can speed it up by making the number in bold lower (like -2.5), hope thats the answer you were looking for
EDIT the number in bold tags actually, since they dont work within the code tags
