Author Topic: copying content from old levels  (Read 5952 times)

motorfirebox

  • Visitor
  • *
  • Posts: 3
    • View Profile
copying content from old levels
« on: 2007-02-28, 04:01:49 PM »
maybe i just missed it, but does the SGDK have an easy way to copy content from old levels into other levels? for instance, if i make a sprite in one level, is there an easy way to make it appear in other levels? i know i'll have to create new paths for it, but do i have to recreate all the animations and behaviors? what about special functions?

dutch_619

  • Regular
  • **
  • Posts: 90
    • View Profile
    • Email
Re: copying content from old levels
« Reply #1 on: 2007-02-28, 04:42:16 PM »
The sprite template should be saved, so that won't have to be recreated. The playable sprite will need a new path, and all special functions will have to be added once again. Just reuse the template for the previous sprite and all the animations, etc. will be the same.


durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: copying content from old levels
« Reply #2 on: 2007-02-28, 06:46:39 PM »
One option, used in Wudd (search the forums) and GoldYoink (on the project listings page) is to use a dummy map to create all sprites, special functions, etc.  Then, use a script to copy them to all the other maps during gameplay.
Edward Dassmesser

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: copying content from old levels
« Reply #3 on: 2007-03-01, 05:37:15 AM »
Another option (I think) is to export your project as XML and copy the sprite templates from one map to another using Notepad, then re-import the XML.  I don't know if I've tried this, but I don't see why it wouldn't work.

motorfirebox

  • Visitor
  • *
  • Posts: 3
    • View Profile
Re: copying content from old levels
« Reply #4 on: 2007-03-02, 01:15:48 AM »
hm. what i want to do is complex enough that i think scripting is the best answer. however, i've never used VBScript, and my only experience with coding is a semester of Java a few years ago. i've read through several tutorials, and i think i've got a decent grasp of the concepts and syntax. trying to wade through the script for GoldYoink is pretty confusing, though. could someone post a short example of defining a sprite template and special function using scripting, or at least copy and paste an example from GoldYoink? i can work my way up from there.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: copying content from old levels
« Reply #5 on: 2007-03-02, 06:23:25 AM »
If you look at the GoldYoink script in the help file (under "Scripting Documentation" -> "GoldYoink Project Source Code") the lines are numbered, and you'll be able to follow this relatively easily:

1) Lines 378 to 380 loop through all the templates in the initial map and copy all the sprite templates to the current map (the oMap that was passed in the parameter to the function).  No maps besides the initial map contain any functions, sprites, templates or paths, just tiles.

2) Lines 382 through 384 loop through all the templates copied to the map looking for the template that represents the enemy sprite template (so it will be easier to assign the enemy sprites to use it later).  To find it, it looks for any template with the word "Enemy" in the name.

3) Lines 393 and 394 begin a loop to examine every tile on the main (only) layer of the map.

4) Line 400 determines if a tile is one of the tiles that represents a picture of an enemy

5) Lines 401 through 414 replace the enemy tile with a sprite referencing the enemy template, using a new path at the tile's location.  Initial instance is turned on for each enemy sprite with FLAG_INSTANCE.

6) Line 543 is where InitMap was called from

7) A little farther down you'll see in line 569 in that same function, an "InitEnemies" function is called to initialize some more details of the enemy sprite template after it is copied.  Additional initialization is required only because the enemy sprites are implemented as a proprietary sprite type not supported by GameDev.  They have ladder climbing states and falling states all in the same sprite.  The enemy sprite template build into GameDev only defines the enemy as a left/right sprite, but the script adds a number of additional states after copying this template.  The player sprite operates a little differently and did not need this kind of logic.  The player sprite actually switches sprite templates when changing modes instead of just switching states.

8) In lines 575 through 588 the InitEnemies function locates the enemy sprite template information

9) In line 587 and 588, it sets it as a proprietary sprite type -- one not used by GameDev, and tells GameDev that this proprietary type has 7 states.

10) In lines 597 through 603, it clears out all the existing state information (the frames that were in the dummy left/right template)

11) In lines 605 through 611, it makes each state reference the same tileset that was referenced by the original 2 states.

12) In lines 613 and 625, it adds the images to the animations of the various states


motorfirebox

  • Visitor
  • *
  • Posts: 3
    • View Profile
Re: copying content from old levels
« Reply #6 on: 2007-03-02, 02:24:38 PM »
cool. i want several types of enemies, and i want them to stick to the individual paths i define for them, rather than chasing the player around the entire map--like most of the Paratroopas in Super Mario Bros. it seems like the best course might be searching the map for certain path types (probably by name), and replacing the sprite attached to that path with the sprite template i want.

so, to make a Paratroopa, i'd create the Paratroopa sprite and template on my source level (a level with one instance of each type of sprite). i'd create a path on the level i want the Paratroopa to appear on, and call that path something like L1Paratroopa0 (level 1, enemy type, index of that type). i'd attach a single-state sprite with a blank tile to that path. the script would do an InStr for "Paratroopa", locate the sprite attached to the path, and replace it with a sprite created from the Paratroopa template.

that sound right?

edit: oh, the reason i think i should search for paths instead of tiles is, i don't want to be limited to a single tile size for the entire game.
« Last Edit: 2007-03-02, 03:14:13 PM by motorfirebox »

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: copying content from old levels
« Reply #7 on: 2007-03-02, 05:20:22 PM »
You wouldn't have to attach a sprite to the path at design time.

SmartBoy16

  • Contributor
  • Fanatic
  • **
  • Posts: 587
  • Looking for inspiration.....
    • View Profile
    • Email
Re: copying content from old levels
« Reply #8 on: 2007-07-25, 10:33:15 PM »
What i just do is create a new map with one path and a player sprite. then i create new maps and save then all blank. then i open the project folder and delete the newly made maps and copy the first map renaming them matching the ones i just deleted. then i reopen gamedev and all the maps, sprites, and definitions are copied.
Looking to the skies.....