Author Topic: what level am i on?  (Read 6707 times)

SmartBoy16

  • Contributor
  • Fanatic
  • **
  • Posts: 587
  • Looking for inspiration.....
    • View Profile
    • Email
what level am i on?
« on: 2007-07-26, 07:52:57 PM »
i'm trying to make a game that includes three save files. I want to beable to show what level the game was saved at using a "letter" tileset. how can i do that?
Looking to the skies.....

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2752
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: what level am i on?
« Reply #1 on: 2007-07-27, 12:35:27 PM »
I'd suggest saving info about which level each of the slots are at in a separate file.  You may be able to use the SGDKFileIO Add-in package to help with that.  I don't remember off the top of my head how it works.  Then you'll probably want to use the Data property of the Layer object (documented in BMDXCtls.hlp provided with the BMDXCtls source code package) to manipulate the tiles on the layer to display the right number, based on values loaded from a file.

Or maybe you could accomplish it without scripting by keeping a master/temporary copy of the project saved that always knows which slots are at which level, and you load that project in order to load other saved games or something.
« Last Edit: 2007-07-27, 12:39:16 PM by bluemonkmn »

SmartBoy16

  • Contributor
  • Fanatic
  • **
  • Posts: 587
  • Looking for inspiration.....
    • View Profile
    • Email
Re: what level am i on?
« Reply #2 on: 2007-07-28, 08:48:24 AM »
ok. ill try it, thanks
Looking to the skies.....

SmartBoy16

  • Contributor
  • Fanatic
  • **
  • Posts: 587
  • Looking for inspiration.....
    • View Profile
    • Email
Re: what level am i on?
« Reply #3 on: 2007-07-30, 01:51:22 PM »
it's not working the way i expected. what i am trying though is using a single save file, but three inventory items (game1, game2, game3) to determine which map to go to. i'll send a copy of the project soon on here.

Edit: use this link http://smartboy16swebsite.freeservers.com/home.html then click on Codename-Shaen.zip
« Last Edit: 2007-07-30, 01:58:43 PM by SmartBoy16 »
Looking to the skies.....

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2752
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: what level am i on?
« Reply #4 on: 2007-07-31, 05:23:51 AM »
That project doesn't have any inventory items.
If it turns out to be difficult to implement this completely without script, maybe you can get most of the way, and then use script just to alter the 3 load-game functions based on the counter values.
« Last Edit: 2007-07-31, 05:27:35 AM by bluemonkmn »

SmartBoy16

  • Contributor
  • Fanatic
  • **
  • Posts: 587
  • Looking for inspiration.....
    • View Profile
    • Email
Re: what level am i on?
« Reply #5 on: 2007-07-31, 08:14:36 AM »
sorry about the inventory items, the game crashed on me and i couldn't save it. i'll post one up with the inventory items later.
Looking to the skies.....

SmartBoy16

  • Contributor
  • Fanatic
  • **
  • Posts: 587
  • Looking for inspiration.....
    • View Profile
    • Email
Re: what level am i on?
« Reply #6 on: 2007-07-31, 12:10:26 PM »
sorry about the inventory items, the game crashed on me and i couldn't save it. i'll post one up with the inventory items later.

i updated it. it also starts on the loadgame map instead of the level1 map
Looking to the skies.....

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2752
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: what level am i on?
« Reply #7 on: 2007-07-31, 04:59:28 PM »
I don't know if I'm failing to properly clear my internet cache or downloading the wrong file or what, but I still don't see any inventory items in that project.

SmartBoy16

  • Contributor
  • Fanatic
  • **
  • Posts: 587
  • Looking for inspiration.....
    • View Profile
    • Email
Re: what level am i on?
« Reply #8 on: 2007-08-01, 06:06:10 PM »
i swear i did update it. ??? ill try it one more time.
Looking to the skies.....

SmartBoy16

  • Contributor
  • Fanatic
  • **
  • Posts: 587
  • Looking for inspiration.....
    • View Profile
    • Email
Re: what level am i on?
« Reply #9 on: 2007-08-09, 09:48:44 AM »
if this was C++ I would write the scrpit like this

Code: [Select]
typedef short int SInt

//inventory items
SInt inv_Game1
SInt inv_Game2
SInt inv_Game3
SInt Game

//activated during game
void TileInt_CollectStar (SInt inv_Game1, SInt inv_Game2, SInt inv_Game3, SInt Game){
if (Game = 1)
inv_Game1++;
else if (Game = 2)
inv_Game2++;
else if (Game = 3){ //same thing
}


//activated during game
void Func_StartGame1 (SInt inv_Game1){
if (inv_Game == 0)
LoadMap ("OverviewMap");
else if (inv_Game1 == 1)
LoadMap ("Level1");
else if (inv_Game1 == 2)
LoadMap ("Level2");
//ect.
else
Msg ("Error!"); break;
Game = 1;
}

//Game2 and Game 3 work same way

int main(){
//rest of code
}

void TileInt_CollectStar is triggered by touching a tile in the Star Category which raises an event
void Func_StartGame1 would be triggered by activating the function druing the game and raising an event
inv_Game1 is the inventory item Game1
Game is the game that's currently "loaded"
LoadMap ("Level1") loads Level1
Msg ("Error!") creates a Message box saying "Error!"

what would this be in VBS?
Looking to the skies.....

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2752
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: what level am i on?
« Reply #10 on: 2007-08-09, 06:57:29 PM »
Well, I don't have time to translate and test a whole script right now, but I can tell you some of the pieces you'd use.  Look at the scripting reference and other samples for details:
1) To create a function that runs when a particular event happens, you'll want to write it like this (it relies on the function name):
Code: [Select]
Sub Player_OnTileInteraction(TileX, TileY, TileVal, bNew, InteractionIndex)
   With ProjectObj.GamePlayer
      If .rMap.Name = "Level6" Then
         If .PlayerSprite.DY > 3 Then .PlayerSprite.DY = -12
      End If
   End With
End Sub

This function executes whenever the player touches a tile, as documented in the player object's OnTileInteraction event in the scripting reference. There are numerous different events for which you can write code, see the scripting reference for details.  Some name comes first and then an underscore followed by the event name.  Then you have to have a line like this to associate the event with the code using the given name:
Code: [Select]
HostObj.SinkObjectEvents ProjectObj.GamePlayer, "Player"That associates all the Player events with functions that start with "Player_".
Note that the tile interaction must check the box for raising an event in order for the code to execute for a particular tile interaction.  In the example above, the code checks to see if the player is on a map called "Level6" and is falling down faster than 3 pixels per frame, and shoots it upwards if so (when the player triggers the tile interaction defined on that map).

2) To alter an inventory value that would be saved with the game, you'll want to access the player's inventory properties like this:
Code: [Select]
   ProjectObj.GamePlayer.InvQuantityOwned(2) = ProjectObj.GamePlayer.InvQuantityOwned(2) + 1
This causes the player's third inventory item (counting from 0) to be incremented by one.

3) This will load the game stored in slot 1.
Code: [Select]
ProjectObj.LoadRuntime("Slot1")Note that it loads the game and everything associated with it.  There are functions to load individual maps, but I'm not clear what approach you want to take.  Loading a map will just load the state of the tiles and sprites on that map, it won't make it the actively running map.  If you want to switch which map is currently active, I suggest activating a Switch Map function because the code for switching maps is relatively complicated and was not encapsulated into a single function except as a "Special Function" object that could be activated something like this:
Code: [Select]
ProjectObj.GamePlayer.ActivateFunction(ProjectObj.Maps("OverviewMap").Specials("SwitchToLevel1")).
4) A message could also be displayed by activating an existing function defined on a map as demonstrated above.