I am working on a project where the guy can walk around a world map of sorts, but when encountering enemies the game jumps to another frame to handle the combat. Once the combat is over, it is supposed to return to the world map frame and the guy is supposed to retain his X,Y position from where he was attacked before.
Now, what I have coded SHOULD work, but for whatever reason it does not. Here's what I have in a nutshell:
(Start of game frame)
Set global array's 1st and 2nd values to 100 (the guy's starting X pos) and 150 (the guy's starting Y pos).
(World Map frame)
Start of Frame --> Set guy's X pos to global array value 1
Set guy's Y pos to global array value 2
Always --> Write: global array value 1 = guy's X pos
Write: global array value 2 = guy's Y pos
Collision between Guy + group: enemies--> Jump to (combat frame)
(combat frame)
The only value carried over from the world map frame that's used here is life and it works okay.
(when combat is over, jump back to world map frame)
Now here's the weird part, each and every time it jumps back to the world frame after combat, my guy
starts in the SAME exact position near the left edge. Mind you, as far as I can tell there is no code that puts these exact same co-ordinates into the array's 1st and 2nd values, or the guy's X and Y values.
It's really odd that this shouldn't work- All of my frames have the global array on them, so that's not it. I've tried messing around with stuff hoping it would work but it doesn't. I know a lot of people have made games where you could jump to another frame and back many times during the course of play (like a separate subscreen, for example.)
Any insight would be great, I think I've included enough information about the problem.
Thank you!
--
"Del Duio has received 0 trophies. Click here to see them all."
"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"
DXF Games, coming next: Hasslevania 2- This Space for Rent!
Some people prefer arrays, I honestly have never used the array object before, and have just stuck with the ini object, since it seems simpler...however I am looking into your problem Del, and should have a solution in a couple of minutes.
Dark One Entertainment
Step Out Of The Light And Enter The Darkness "Why do we need this?
Who was it that said,
Great things come to great men
Well that f**ker lied to us
There's nothing here but a wasteland."
What I mean is that it's an array object with the global to application box checked.
I know you could also use an ini file but I wanted to try and stay away from them for this game because of my last's ability for players to easily alter stats and progress in the game through cheating. If I used an ini, someone would be able to "warp" to areas of the game where they aren't supposed to be yet. I know you can also use the blowfish extension but I wanted to keep all relevant data in one array if possible for this one.
One thing I forgot to include is that the size of the world map screen's frame is pretty big at 2500 x 2500. Is it possibly a "not enough memory" sort of thing? It's just so strange that no matter where on the map I am attacked I end up going back to the same exact spot on the left side of the map. And it's not even at the default position that I give the guy at the start of the game too.
--
"Del Duio has received 0 trophies. Click here to see them all."
"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"
DXF Games, coming next: Hasslevania 2- This Space for Rent!
Ok, well I've set up the scenario and I have no problems at all, I'm uploading a cca of what I did, and you can take a look at it, and see if that can help fix your problem.
To skip frames, to test stuff, hit the space bar key. Move with the arrow keys.
I hope this helps, as the only problem I can see is with your writing to the values and reading and loading them.
Dark One Entertainment
Step Out Of The Light And Enter The Darkness "Why do we need this?
Who was it that said,
Great things come to great men
Well that f**ker lied to us
There's nothing here but a wasteland."
I think he still wants to be able to save those values though as well, as global values, they'd still have to be saved in the array file, and then loaded upon loading up. Using the array object directly just simplifies that process.
Dark One Entertainment
Step Out Of The Light And Enter The Darkness "Why do we need this?
Who was it that said,
Great things come to great men
Well that f**ker lied to us
There's nothing here but a wasteland."
I tried a bunch of different ways, and what I ended up doing was using an ini file to save the position of the guy before he goes into the combat screen, and then load the values at the beginning of the world map screen.
The only complication that happened was that although it saves the guy's position to the ini, there was no actual readable data on the ini when you open it (weird, huh?). So when you restart the application and it goes to the world map for that game's first time, the guy appears where he left off in the last game. I fixed this by using a global variable called GUYLOADPOS. If it's = 0, then first it saves the guy outside his house (the normal starting point for a new game). Then it changes the value to 1, whereas every check afterwards of the map screen frame skips the "save guy in front of house" event and just loads it to wherever he was when he got attacked like it should.
I'm sure it's more complicated than it should be, but at least it works! Thanks guys for your help
--
"Del Duio has received 0 trophies. Click here to see them all."
"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"
DXF Games, coming next: Hasslevania 2- This Space for Rent!