#include "lispreader.h"
#include "resources.h"
#include "music_manager.h"
+#include "gameobjs.h"
using namespace std;
song_title = "Mortimers_chipdisko.mod";
bkgd_image = "arctis.png";
width = 21;
- height = 15;
+ height = 19;
start_pos_x = 100;
start_pos_y = 170;
time_left = 100;
while (!lisp_nil_p(cur))
{
lisp_object_t* data = lisp_car(cur);
+ std::string object_type = "";
- BadGuyData bg_data;
- bg_data.kind = badguykind_from_string(lisp_symbol(lisp_car(data)));
LispReader reader(lisp_cdr(data));
- reader.read_int("x", &bg_data.x);
- reader.read_int("y", &bg_data.y);
- reader.read_bool("stay-on-platform", &bg_data.stay_on_platform);
+ reader.read_string("type", &object_type);
- badguy_data.push_back(bg_data);
+ if (object_type == "badguy" || object_type == "")
+ {
+ BadGuyData bg_data;
+ bg_data.kind = badguykind_from_string(lisp_symbol(lisp_car(data)));
+ reader.read_int("x", &bg_data.x);
+ reader.read_int("y", &bg_data.y);
+ reader.read_bool("stay-on-platform", &bg_data.stay_on_platform);
+
+ badguy_data.push_back(bg_data);
+ }
+ else
+ {
+ if (strcmp(lisp_symbol(lisp_car(data)),"trampoline") == 0)
+ {
+ ObjectData<TrampolineData> _trampoline_data;
+
+ _trampoline_data.type = OBJ_TRAMPOLINE;
+ reader.read_int("x", &_trampoline_data.x);
+ reader.read_int("y", &_trampoline_data.y);
+ reader.read_float("power", &_trampoline_data.type_specific.power);
+
+ trampoline_data.push_back(_trampoline_data);
+ }
+ }
cur = lisp_cdr(cur);
}
/* Write header: */
- fprintf(fi,";SuperTux-Level\n");
+ fprintf(fi,";SuperTux level made using the built-in leveleditor\n");
fprintf(fi,"(supertux-level\n");
fprintf(fi," (version %d)\n", 1);
{
for(int i = 0; i < width; ++i)
fprintf(fi," %d ", bg_tiles[y][i]);
+ fprintf(fi,"\n");
}
fprintf( fi,")\n");
{
for(int i = 0; i < width; ++i)
fprintf(fi," %d ", ia_tiles[y][i]);
+ fprintf(fi,"\n");
}
fprintf( fi,")\n");
{
for(int i = 0; i < width; ++i)
fprintf(fi," %d ", fg_tiles[y][i]);
+ fprintf(fi,"\n");
}
fprintf( fi,")\n");
for(std::vector<BadGuyData>::iterator it = badguy_data.begin();
it != badguy_data.end();
++it)
- fprintf( fi,"(%s (x %d) (y %d) (stay-on-platform %s))\n",
+ fprintf( fi," (%s (x %d) (y %d) (stay-on-platform %s))\n",
badguykind_to_string((*it).kind).c_str(),(*it).x,(*it).y,
it->stay_on_platform ? "#t" : "#f");
}
}
+void Level::draw_bg()
+{
+ if(img_bkgd)
+ {
+ // Tile background horizontally
+ int sx = (int)((float)scroll_x * ((float)bkgd_speed/100.0f)) % img_bkgd->w;
+ int sy = (int)((float)scroll_y * ((float)bkgd_speed/100.0f)) % img_bkgd->h;
+ for (int x = 0; (x-1)*img_bkgd->w <= screen->w; x++)
+ for (int y = 0; (y-1)*img_bkgd->h <= screen->h; y++)
+ img_bkgd->draw_part(x == 0 ? sx : 0, y == 0 ? sy : 0,
+ x == 0 ? 0 : (img_bkgd->w * x) - sx, y == 0 ? 0 : (img_bkgd->h * y) - sy,
+ x == 0 ? img_bkgd->w - sx : img_bkgd->w, y == 0 ? img_bkgd->h - sy : img_bkgd->h);
+ }
+ else
+ {
+ drawgradient(bkgd_top, bkgd_bottom);
+ }
+}
+
void
Level::load_song()
{