Author Topic: Swap Player Tileset  (Read 2862 times)

Quazi

  • Guest
Swap Player Tileset
« on: 2005-09-06, 02:16:15 PM »
I'm to make a generic Sub I can call to Swap out the player's tileset but cannot seem to figure out the path. I modified some code I found but it just overlays the Player tileset. And I want to change the tileset.

Sub SwapTileSet(NewTileSet)
Dim TS    
   With ProjectObj.GamePlayer
      Set TS = ProjectObj.TileSetDef(NewTileSet)
      If Not TS.IsLoaded Then
         TS.Load
      End If
      If TS.LoadedInstance Is Nothing Then
         Set TS.LoadedInstance = CurrentDisplay.CreateTileSet( _
         TS.Image, TS.TileWidth, TS.TileHeight)
      End If
         CurrentDisplay.DrawTile _
         TS.LoadedInstance, _
         .PlayerSprite.CurTile, _
         .PlayerSprite.X - .MapScrollX, _
         .PlayerSprite.Y - .MapScrollY, _
         0, 0, 640, 480, True        
   End With
End Sub

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Swap Player Tileset
« Reply #1 on: 2005-09-06, 03:10:14 PM »
Why do want to change the player's tileset?  If it's so that you can change the look of the player, it would be easier, I think, to create a different sprite and choose "Switch To Sprite" as a special function.

What it looks like you are doing is simply draw the tiles directly to the screen, which is more used when creating programs using BMDXCtls.  The drawing of tiles should be handled by SGDK automatically.  So what exactly are you trying to do?
Edward Dassmesser

Quazi

  • Guest
Swap Player Tileset
« Reply #2 on: 2005-09-06, 03:15:50 PM »
I have a really weird player set up where there's 4 different single state movement sprites and it would be easier to change the tileset when I get a different weapon than create 4 more sprites. It would also make it so I dont have to make lots of new interaction special functions and inventory items to get the movement and such working right. I'd change it to a left/right sprites but I'd have to redo all the special functions, inventory and scripting to get it working the same way. So basically I just need to know how to change the player sprite tileset and I can save myself tons of work.

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Swap Player Tileset
« Reply #3 on: 2005-09-06, 04:25:01 PM »
I'll have to defer to BlueMonk for the answer to how to actually do what you want.  However, I don't understand why you would need to change / add special functions, inventory, etc. if you are switching to a different sprite.  Collisions are based on classes, and special functions activate when the player hits them, no matter what sprite it is currently represented by.  As for inventory, I've got no idea what you would need to change that for at all.
Edward Dassmesser

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Changing sprite template
« Reply #4 on: 2005-09-06, 06:10:28 PM »
I think you want to change the player sprite's template... something like this:
Code: [Select]
With ProjectObj.GamePlayer.PlayerSprite.rDef.Template
   Set .StateTilesetDef(0) = ProjectObj.TileSetDef(NewTileSet)
   .LoadTiles(CurrentDisplay)
End With

or this:
Code: [Select]
With ProjectObj.GamePlayer.PlayerSprite.rDef.Template
   .ClearState(0)
   .AppendStateFrame(0,MyFrameIndex)
End With