super-tux-commit Mailing List for Super Tux (Page 62)
Brought to you by:
wkendrick
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
(94) |
Apr
(500) |
May
(531) |
Jun
(196) |
Jul
(224) |
Aug
(193) |
Sep
(117) |
Oct
(115) |
Nov
(319) |
Dec
(97) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(19) |
Feb
|
Mar
(105) |
Apr
(41) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(6) |
2007 |
Jan
(1) |
Feb
(2) |
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
(2) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
(4) |
Jul
|
Aug
|
Sep
(7) |
Oct
(12) |
Nov
(26) |
Dec
(39) |
2009 |
Jan
(6) |
Feb
(15) |
Mar
(10) |
Apr
(25) |
May
(29) |
Jun
(21) |
Jul
(26) |
Aug
(8) |
Sep
(3) |
Oct
|
Nov
|
Dec
(10) |
2010 |
Jan
(5) |
Feb
(5) |
Mar
(2) |
Apr
|
May
(5) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
(2) |
Oct
(2) |
Nov
|
Dec
|
From: Matze B. <mat...@us...> - 2004-05-25 10:09:47
|
Update of /cvsroot/super-tux/supertux/data/levels/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29720/data/levels/test Modified Files: level8.stl level9.stl Log Message: forgot to commit my changes to testlevels yesterday Index: level9.stl =================================================================== RCS file: /cvsroot/super-tux/supertux/data/levels/test/level9.stl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- level9.stl 7 May 2004 23:10:54 -0000 1.1 +++ level9.stl 25 May 2004 10:09:30 -0000 1.2 @@ -17,9 +17,19 @@ (bkgd_blue_bottom 255) (time 200) (gravity 10.0) - (hor_autoscroll_speed 0.5) (particle_system "clouds") (theme "antarctica") + (camera + (mode "autoscroll") + (path + (point (x 0) (y 0) (speed 0.5)) + (point (x 500) (y 0) (speed 2)) + (point (x 1200) (y 0) (speed 1)) + (point (x 3000) (y 0) (speed 1)) + (point (x 1500) (y 0) (speed 1.4)) + (point (x 99999) (y 0)) + ) + ) (interactive-tm 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 133 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 132 132 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 26 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 103 0 10 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 133 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 132 132 0 0 0 0 0 Index: level8.stl =================================================================== RCS file: /cvsroot/super-tux/supertux/data/levels/test/level8.stl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- level8.stl 6 May 2004 18:49:10 -0000 1.1 +++ level8.stl 25 May 2004 10:09:30 -0000 1.2 @@ -2,7 +2,7 @@ (supertux-level (version 1) (author "Ricardo Cruz") - (name "Backscroll Test (Above the Arctic Skies)") + (name "No Backscroll Test (Above the Arctic Skies)") (width 290) (height 15) (start_pos_x 100) @@ -17,9 +17,12 @@ (bkgd_blue_bottom 255) (time 200) (gravity 10.0) - (back_scrolling #t) (particle_system "clouds") (theme "antarctica") + (camera + (mode "normal") + (backscrolling #f) + ) (interactive-tm 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 133 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 132 132 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 26 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 103 0 10 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 133 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 132 132 0 0 0 0 0 |
From: Ryan F. <sik...@us...> - 2004-05-25 02:56:41
|
Update of /cvsroot/super-tux/supertux/data/levels/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22426/data/levels/test Modified Files: level10.stl Log Message: - added wingling to test level Index: level10.stl =================================================================== RCS file: /cvsroot/super-tux/supertux/data/levels/test/level10.stl,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- level10.stl 24 May 2004 12:02:25 -0000 1.5 +++ level10.stl 25 May 2004 02:56:31 -0000 1.6 @@ -30,6 +30,10 @@ (y 272) (stay-on-platform #f) ) + (wingling + (x 1200) + (y 150) + ) (trampoline (x 1900) (y 1500) |
From: Ryan F. <sik...@us...> - 2004-05-25 02:51:39
|
Update of /cvsroot/super-tux/supertux/data/images/shared In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21769/data/images/shared Added Files: wingling-1.png Log Message: - beginnings of a wingling --- NEW FILE: wingling-1.png --- (This appears to be a binary file; contents omitted.) |
From: Ryan F. <sik...@us...> - 2004-05-25 02:51:39
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21769/src Modified Files: badguy.cpp badguy.h Log Message: - beginnings of a wingling Index: badguy.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.h,v retrieving revision 1.46 retrieving revision 1.47 diff -u -d -r1.46 -r1.47 --- badguy.h 24 May 2004 22:36:56 -0000 1.46 +++ badguy.h 25 May 2004 02:51:30 -0000 1.47 @@ -49,6 +49,7 @@ BAD_FLYINGSNOWBALL, BAD_SPIKY, BAD_SNOWBALL, + BAD_WINGLING, NUM_BadGuyKinds }; @@ -144,6 +145,7 @@ void action_flyingsnowball(double frame_ratio); void action_spiky(double frame_ratio); void action_snowball(double frame_ratio); + void action_wingling(double frame_ratio); /** initializes the badguy (when he appears on screen) */ void activate(Direction direction); Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.88 retrieving revision 1.89 diff -u -d -r1.88 -r1.89 --- badguy.cpp 24 May 2004 22:36:56 -0000 1.88 +++ badguy.cpp 25 May 2004 02:51:30 -0000 1.89 @@ -74,8 +74,10 @@ Sprite* img_snowball_right; Sprite* img_snowball_squished_left; Sprite* img_snowball_squished_right; +Sprite* img_wingling_left; #define BADGUY_WALK_SPEED .8f +#define WINGLING_FLY_SPEED 1.6f BadGuyKind badguykind_from_string(const std::string& str) { @@ -99,6 +101,8 @@ return BAD_SPIKY; else if (str == "snowball" || str == "bsod") // was bsod in old maps return BAD_SNOWBALL; + else if (str == "wingling") + return BAD_WINGLING; else { printf("Couldn't convert badguy: '%s'\n", str.c_str()); @@ -140,6 +144,9 @@ case BAD_SNOWBALL: return "snowball"; break; + case BAD_WINGLING: + return "wingling"; + break; default: return "snowball"; } @@ -271,6 +278,10 @@ } else if(kind == BAD_SNOWBALL) { physic.set_velocity(dirsign * BADGUY_WALK_SPEED, 0); set_sprite(img_snowball_left, img_snowball_right); + } else if(kind == BAD_WINGLING) { + physic.set_velocity(dirsign * WINGLING_FLY_SPEED, 0); + physic.enable_gravity(false); + set_sprite(img_wingling_left, img_wingling_left); } base.x = start_position.x; @@ -766,6 +777,30 @@ } void +BadGuy::action_wingling(double elapsed_time) +{ + if (dying != DYING_NOT) + physic.enable_gravity(true); + else + { + Player& tux = *World::current()->get_tux(); + + if (fabsf(tux.base.x - base.x) < 200 && base.y < tux.base.y && tux.dying == DYING_NOT) + physic.set_velocity(-2.0f, -2.0f); + else + physic.set_velocity(-WINGLING_FLY_SPEED, 0); + } + + physic.apply(elapsed_time, base.x, base.y); + + + // Handle dying timer: + if (dying == DYING_SQUISHED && !timer.check()) + remove_me(); +} + + +void BadGuy::action(float elapsed_time) { float scroll_x = World::current()->camera->get_translation().x; @@ -864,6 +899,11 @@ case BAD_SNOWBALL: action_snowball(elapsed_time); break; + + case BAD_WINGLING: + action_wingling(elapsed_time); + break; + default: break; } @@ -1040,7 +1080,12 @@ squish_me(player); set_sprite(img_snowball_squished_left, img_snowball_squished_right); return; + } else if(kind == BAD_WINGLING) { + squish_me(player); + set_sprite(img_wingling_left, img_wingling_left); } + + } void @@ -1123,6 +1168,7 @@ case CO_BADGUY: pbad_c = (BadGuy*) p_c_object; + /* If we're a kicked mriceblock, kill [almost] any badguys we hit */ if(kind == BAD_MRICEBLOCK && mode == KICK && kind != BAD_FLAME && kind != BAD_BOMB && kind != BAD_STALACTITE) @@ -1168,7 +1214,11 @@ /* When enemies run into eachother, make them change directions */ else { - // Jumpy, fish, flame, stalactites are exceptions + // Wingling doesn't interact with other badguys + if (pbad_c->kind == BAD_WINGLING || kind == BAD_WINGLING) + break; + + // Jumpy, fish, flame, stalactites, wingling are exceptions if (pbad_c->kind == BAD_JUMPY || pbad_c->kind == BAD_FLAME || pbad_c->kind == BAD_STALACTITE || pbad_c->kind == BAD_FISH) break; @@ -1283,6 +1333,7 @@ img_snowball_right = sprite_manager->load("snowball-right"); img_snowball_squished_left = sprite_manager->load("snowball-squished-left"); img_snowball_squished_right = sprite_manager->load("snowball-squished-right"); + img_wingling_left = sprite_manager->load("wingling-left"); } void free_badguy_gfx() |
From: Ryan F. <sik...@us...> - 2004-05-25 02:51:38
|
Update of /cvsroot/super-tux/supertux/data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21769/data Modified Files: supertux.strf Log Message: - beginnings of a wingling Index: supertux.strf =================================================================== RCS file: /cvsroot/super-tux/supertux/data/supertux.strf,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- supertux.strf 24 May 2004 20:42:21 -0000 1.35 +++ supertux.strf 25 May 2004 02:51:30 -0000 1.36 @@ -617,27 +617,33 @@ ; Trampoline (sprite (name "trampoline-1") (x-hotspot 0) - (x-hotspot 0) + (y-hotspot 0) (images "shared/trampoline-1.png")) (sprite (name "trampoline-2") (x-hotspot 0) - (x-hotspot 0) + (y-hotspot 0) (images "shared/trampoline-2.png")) (sprite (name "trampoline-3") (x-hotspot 0) - (x-hotspot 0) + (y-hotspot 0) (images "shared/trampoline-3.png")) (sprite (name "trampoline-4") (x-hotspot 0) - (x-hotspot 0) + (y-hotspot 0) (images "shared/trampoline-4.png")) ; Flying platforms (sprite (name "flying_platform") (x-hotspot 0) - (x-hotspot 0) + (y-hotspot 0) (images "shared/flying_platform-1.png")) + ; Wingling + (sprite (name "wingling-left") + (x-hotspot 0) + (y-hotspot 0) + (images "shared/wingling-1.png")) + ) ;; EOF ;; |
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29152 Modified Files: Makefile.am camera.cpp camera.h level.cpp level.h player.cpp player.h vector.h world.cpp Added Files: vector.cpp Log Message: implemented autoscrolling and proper camera parsing in levelfiles Index: player.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.h,v retrieving revision 1.61 retrieving revision 1.62 diff -u -d -r1.61 -r1.62 --- player.h 24 May 2004 21:02:27 -0000 1.61 +++ player.h 25 May 2004 00:28:24 -0000 1.62 @@ -119,6 +119,7 @@ int size; bool duck; bool holding_something; + bool dead; DyingType dying; Direction dir; @@ -140,6 +141,7 @@ Timer frame_timer; Timer kick_timer; Timer shooting_timer; // used to show the arm when Tux is shooting + Timer dying_timer; Physic physic; public: @@ -158,14 +160,15 @@ void collision(void* p_c_object, int c_object); void kill(HurtMode mode); - void is_dying(); - bool is_dead(); void player_remove_powerups(); void check_bounds(Camera& viewport, bool back_scrolling, bool hor_autoscroll); bool on_ground(); bool under_solid(); bool tiles_on_air(int tiles); void grow(); + void move(const Vector& vector); + bool is_dead() const + { return dead; } private: void init(); Index: Makefile.am =================================================================== RCS file: /cvsroot/super-tux/supertux/src/Makefile.am,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- Makefile.am 24 May 2004 21:02:26 -0000 1.27 +++ Makefile.am 25 May 2004 00:28:24 -0000 1.28 @@ -90,6 +90,8 @@ tilemap.cpp \ moving_object.h \ moving_object.cpp \ -serializable.h +serializable.h \ +vector.cpp \ +vector.h # EOF # Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.84 retrieving revision 1.85 diff -u -d -r1.84 -r1.85 --- level.cpp 23 May 2004 22:46:34 -0000 1.84 +++ level.cpp 25 May 2004 00:28:24 -0000 1.85 @@ -223,8 +223,8 @@ bkgd_image = "arctis.jpg"; width = 0; height = 0; - start_pos_x = 100; - start_pos_y = 170; + start_pos.x = 100; + start_pos.y = 170; time_left = 100; gravity = 10.; back_scrolling = false; @@ -277,8 +277,8 @@ reader.read_int("version", &version); if(!reader.read_int("width", &width)) st_abort("No width specified for level.", ""); - if (!reader.read_int("start_pos_x", &start_pos_x)) start_pos_x = 100; - if (!reader.read_int("start_pos_y", &start_pos_y)) start_pos_y = 170; + if (!reader.read_float("start_pos_x", &start_pos.x)) start_pos.x = 100; + if (!reader.read_float("start_pos_y", &start_pos.y)) start_pos.y = 170; time_left = 500; if(!reader.read_int("time", &time_left)) { printf("Warning no time specified for level.\n"); @@ -355,7 +355,7 @@ } } - { // Read BadGuys + { // Read Objects lisp_object_t* cur = 0; if (reader.read_lisp("objects", &cur)) { @@ -364,77 +364,15 @@ } } -#if 0 // TODO fix this or remove it - // Convert old levels to the new tile numbers - if (version == 0) - { - std::map<char, int> transtable; - transtable['.'] = 0; - transtable['x'] = 104; - transtable['X'] = 77; - transtable['y'] = 78; - transtable['Y'] = 105; - transtable['A'] = 83; - transtable['B'] = 102; - transtable['!'] = 103; - transtable['a'] = 84; - transtable['C'] = 85; - transtable['D'] = 86; - transtable['E'] = 87; - transtable['F'] = 88; - transtable['c'] = 89; - transtable['d'] = 90; - transtable['e'] = 91; - transtable['f'] = 92; - - transtable['G'] = 93; - transtable['H'] = 94; - transtable['I'] = 95; - transtable['J'] = 96; - - transtable['g'] = 97; - transtable['h'] = 98; - transtable['i'] = 99; - transtable['j'] = 100 - ; - transtable['#'] = 11; - transtable['['] = 13; - transtable['='] = 14; - transtable[']'] = 15; - transtable['$'] = 82; - transtable['^'] = 76; - transtable['*'] = 80; - transtable['|'] = 79; - transtable['\\'] = 81; - transtable['&'] = 75; - - int x = 0; - int y = 0; - for(std::vector<int>::iterator i = ia_tm.begin(); i != ia_tm.end(); ++i) - { - if (*i == '0' || *i == '1' || *i == '2') - { - badguy_data.push_back(BadGuyData(static_cast<BadGuyKind>(*i-'0'), - x*32, y*32, false)); - *i = 0; - } - else - { - std::map<char, int>::iterator j = transtable.find(*i); - if (j != transtable.end()) - *i = j->second; - else - printf("Error: conversion will fail, unsupported char: '%c' (%d)\n", *i, *i); - } - ++x; - if (x >= width) - { - x = 0; - ++y; - } - } - } -#endif + { // Read Camera + lisp_object_t* cur = 0; + if (reader.read_lisp("camera", &cur)) + { + LispReader reader(cur); + if(world) + world->camera->read(reader); + } + } } lisp_free(root_obj); Index: vector.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/vector.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- vector.h 20 May 2004 12:12:38 -0000 1.1 +++ vector.h 25 May 2004 00:28:24 -0000 1.2 @@ -41,6 +41,11 @@ return Vector(x * s, y * s); } + Vector operator/(float s) const + { + return Vector(x / s, y / s); + } + const Vector& operator +=(const Vector& other) { x += other.x; @@ -48,6 +53,15 @@ return *this; } + // scalar product of 2 vectors + float operator*(const Vector& other) const + { + return x*other.x + y*other.y; + } + + float norm() const; + Vector unit() const; + // ... add the other operators as needed, I'm too lazy now ... float x, y; // leave this public, get/set methods just give me headaches Index: level.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.h,v retrieving revision 1.52 retrieving revision 1.53 diff -u -d -r1.52 -r1.53 --- level.h 21 May 2004 00:22:57 -0000 1.52 +++ level.h 25 May 2004 00:28:24 -0000 1.53 @@ -92,8 +92,7 @@ int width; int height; int bkgd_speed; - int start_pos_x; - int start_pos_y; + Vector start_pos; float gravity; bool back_scrolling; float hor_autoscroll_speed; Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.122 retrieving revision 1.123 diff -u -d -r1.122 -r1.123 --- player.cpp 24 May 2004 23:32:41 -0000 1.122 +++ player.cpp 25 May 2004 00:28:24 -0000 1.123 @@ -83,8 +83,6 @@ void Player::init() { - Level* plevel = World::current()->get_level(); - holding_something = false; base.width = 32; @@ -93,12 +91,13 @@ size = SMALL; got_power = NONE_POWER; - base.x = plevel->start_pos_x; - base.y = plevel->start_pos_y; + base.x = 0; + base.y = 0; previous_base = old_base = base; dir = RIGHT; old_dir = dir; duck = false; + dead = false; dying = DYING_NOT; last_ground_y = 0; @@ -181,6 +180,11 @@ { bool jumped_in_solid = false; + if(dying && !dying_timer.check()) { + dead = true; + return; + } + if (input.fire == UP) holding_something = false; @@ -831,6 +835,9 @@ void Player::kill(HurtMode mode) { + if(dying) + return; + play_sound(sounds[SND_HURT], SOUND_CENTER_SPEAKER); physic.set_velocity_x(0); @@ -854,32 +861,12 @@ physic.enable_gravity(true); physic.set_acceleration(0, 0); physic.set_velocity(0, 7); - if(dying != DYING_SQUISHED) --player_status.lives; dying = DYING_SQUISHED; + dying_timer.start(3000); } } -void -Player::is_dying() -{ - remove_powerups(); - dying = DYING_NOT; -} - -bool Player::is_dead() -{ - float scroll_x = - World::current()->camera->get_translation().x; - float scroll_y = - World::current()->camera->get_translation().y; - if(base.y > screen->h + scroll_y || base.y > World::current()->get_level()->height*32 || - base.x < scroll_x - AUTOSCROLL_DEAD_INTERVAL) // can happen in auto-scrolling - return true; - else - return false; -} - /* Remove Tux's power ups */ void Player::remove_powerups() @@ -890,6 +877,14 @@ } void +Player::move(const Vector& vector) +{ + base.x = vector.x; + base.y = vector.y; + old_base = previous_base = base; +} + +void Player::check_bounds(Camera& viewport, bool back_scrolling, bool hor_autoscroll) { @@ -904,10 +899,27 @@ if (base.y > World::current()->get_level()->height * /*TILE_HEIGHT*/ 32) { kill(KILL); + return; } - if(base.x < viewport.get_translation().x && (!back_scrolling || hor_autoscroll)) // can happen if back scrolling is disabled + bool adjust = false; + // can happen if back scrolling is disabled + if(base.x < viewport.get_translation().x) { base.x = viewport.get_translation().x; + adjust = true; + } + if(base.x >= viewport.get_translation().x + screen->w - base.width) { + base.x = viewport.get_translation().x + screen->w - base.width; + adjust = true; + } + + if(adjust) { + // squished now? + if(collision_object_map(base)) { + kill(KILL); + return; + } + } if(hor_autoscroll) { Index: camera.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/camera.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- camera.cpp 24 May 2004 23:02:34 -0000 1.5 +++ camera.cpp 25 May 2004 00:28:24 -0000 1.6 @@ -18,6 +18,8 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "camera.h" +#include <stdexcept> +#include <sstream> #include <math.h> #include "lispwriter.h" #include "player.h" @@ -25,7 +27,8 @@ #include "globals.h" Camera::Camera(Player* newplayer, Level* newlevel) - : player(newplayer), level(newlevel), scrollchange(NONE) + : player(newplayer), level(newlevel), do_backscrolling(true), + scrollchange(NONE), auto_idx(0), auto_t(0) { if(!player || !level) mode = MANUAL; @@ -44,14 +47,74 @@ } void +Camera::read(LispReader& reader) +{ + std::string modename; + + reader.read_string("mode", &modename); + if(modename == "normal") { + mode = NORMAL; + + do_backscrolling = true; + reader.read_bool("backscrolling", &do_backscrolling); + } else if(modename == "autoscroll") { + mode = AUTOSCROLL; + + lisp_object_t* cur = 0; + reader.read_lisp("path", &cur); + if(cur == 0) { + throw std::runtime_error("No path specified in autoscroll camera."); + } + float speed = .5; + while(!lisp_nil_p(cur)) { + if(strcmp(lisp_symbol(lisp_car(lisp_car(cur))), "point") != 0) { + std::cerr << "Warning: unknown token in camera path.\n"; + continue; + } + + LispReader reader(lisp_cdr(lisp_car(cur))); + + ScrollPoint point; + if(!reader.read_float("x", &point.position.x) || + !reader.read_float("y", &point.position.y)) { + throw std::runtime_error("x and y missing in point of camerapath"); + } + reader.read_float("speed", &speed); + point.speed = speed; + scrollpoints.push_back(point); + + cur = lisp_cdr(cur); + } + } else if(modename == "manual") { + mode = MANUAL; + } else { + std::stringstream str; + str << "invalid camera mode '" << modename << "'found in worldfile."; + throw std::runtime_error(str.str()); + } +} + +void Camera::write(LispWriter& writer) { writer.start_list("camera"); if(mode == NORMAL) { writer.write_string("mode", "normal"); + writer.write_bool("backscrolling", do_backscrolling); } else if(mode == AUTOSCROLL) { writer.write_string("mode", "autoscroll"); + writer.start_list("path"); + for(std::vector<ScrollPoint>::iterator i = scrollpoints.begin(); + i != scrollpoints.end(); ++i) { + writer.start_list("point"); + writer.write_float("x", i->position.x); + writer.write_float("y", i->position.y); + writer.write_float("speed", i->speed); + writer.end_list("point"); + } + + writer.end_list("path"); } else if(mode == MANUAL) { writer.write_string("mode", "manual"); } @@ -72,6 +135,20 @@ } void +Camera::keep_in_bounds() +{ + // don't scroll before the start or after the level's end + if(translation.y > level->height * 32 - screen->h) + translation.y = level->height * 32 - screen->h; + if(translation.y < 0) + translation.y = 0; + if(translation.x > level->width * 32 - screen->w) + translation.x = level->width * 32 - screen->w; + if(translation.x < 0) + translation.x = 0; +} + +void Camera::scroll_normal(float elapsed_time) { assert(level != 0 && player != 0); @@ -112,12 +189,6 @@ // finally scroll with calculated speed translation.y -= speed_y * elapsed_time; - - // don't scroll before the start or after the level's end - if(translation.y > level->height * 32 - screen->h) - translation.y = level->height * 32 - screen->h; - if(translation.y < 0) - translation.y = 0; } /****** Horizontal scrolling part *******/ @@ -131,7 +202,7 @@ || (player->dir == ::RIGHT && scrollchange == LEFT)) scrollchange = NONE; // when in left 1/3rd of screen scroll left - if(player->base.x < translation.x + screen->w/3 && level->back_scrolling) + if(player->base.x < translation.x + screen->w/3 && do_backscrolling) scrollchange = LEFT; // scroll right when in right 1/3rd of screen else if(player->base.x > translation.x + screen->w/3*2) @@ -161,15 +232,39 @@ // apply scrolling translation.x -= speed_x * elapsed_time; - // don't scroll before the start or after the level's end - if(translation.x > level->width * 32 - screen->w) - translation.x = level->width * 32 - screen->w; - if(translation.x < 0) - translation.x = 0; + keep_in_bounds(); } void Camera::scroll_autoscroll(float elapsed_time) { - // TODO + if(player->dying) + return; + + if(auto_t - elapsed_time >= 0) { + translation += current_dir * elapsed_time; + auto_t -= elapsed_time; + } else { + // do the rest of the old movement + translation += current_dir * auto_t; + elapsed_time -= auto_t; + auto_t = 0; + + // construct path for next point + if(auto_idx+1 >= scrollpoints.size()) { + keep_in_bounds(); + return; + } + Vector distance = scrollpoints[auto_idx+1].position + - scrollpoints[auto_idx].position; + current_dir = distance.unit() * scrollpoints[auto_idx].speed; + auto_t = distance.norm() / scrollpoints[auto_idx].speed; + + // do movement for the remaining time + translation += current_dir * elapsed_time; + auto_t -= elapsed_time; + auto_idx++; + } + + keep_in_bounds(); } Index: camera.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/camera.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- camera.h 24 May 2004 21:29:11 -0000 1.3 +++ camera.h 25 May 2004 00:28:24 -0000 1.4 @@ -19,6 +19,7 @@ #ifndef __VIEWPORT_H__ #define __VIEWPORT_H__ +#include <vector> #include "vector.h" #include "game_object.h" #include "serializable.h" @@ -44,7 +45,7 @@ } /// parse camera mode from lisp file - void parse_camera(LispReader& reader); + void read(LispReader& reader); /// write camera mode to a lisp file virtual void write(LispWriter& writer); @@ -60,10 +61,12 @@ { NORMAL, AUTOSCROLL, MANUAL }; + CameraMode mode; private: void scroll_normal(float elapsed_time); void scroll_autoscroll(float elapsed_time); + void keep_in_bounds(); enum LeftRightScrollChange { @@ -74,12 +77,21 @@ Player* player; Level* level; - CameraMode mode; // normal mode + bool do_backscrolling; LeftRightScrollChange scrollchange; // autoscroll mode + class ScrollPoint { + public: + Vector position; + float speed; + }; + std::vector<ScrollPoint> scrollpoints; + size_t auto_idx; + float auto_t; + Vector current_dir; }; #endif Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.113 retrieving revision 1.114 diff -u -d -r1.113 -r1.114 --- world.cpp 24 May 2004 22:36:56 -0000 1.113 +++ world.cpp 25 May 2004 00:28:24 -0000 1.114 @@ -48,16 +48,20 @@ // world calls child functions current_ = this; + tux = new Player(displaymanager); + add_object(tux); + level = new Level(); + camera = new Camera(tux, level); + add_object(camera); + if(level_nr >= 0) { level->load(filename, level_nr, this); } else { level->load(filename, this); } - - tux = new Player(displaymanager); - add_object(tux); - + tux->move(level->start_pos); + set_defaults(); level->load_gfx(); @@ -75,9 +79,6 @@ add_object(new TileMap(displaymanager, level)); level->load_song(); - camera = new Camera(tux, level); - add_object(camera); - apply_bonuses(); } --- NEW FILE: vector.cpp --- #include "vector.h" #include <math.h> Vector Vector::unit() const { return *this / norm(); } float Vector::norm() const { return sqrt(x*x + y*y); } |
From: Ryan F. <sik...@us...> - 2004-05-24 23:32:54
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18823 Modified Files: player.cpp Log Message: - fixed it so Tux doesn't die on spikes if safety timer is started Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.121 retrieving revision 1.122 diff -u -d -r1.121 -r1.122 --- player.cpp 24 May 2004 23:03:43 -0000 1.121 +++ player.cpp 24 May 2004 23:32:41 -0000 1.122 @@ -199,7 +199,7 @@ collision_swept_object_map(&old_base, &base); - if (!invincible_timer.started() + if ((!invincible_timer.started() && !safe_timer.started()) && (isspike(base.x, base.y) || isspike(base.x + base.width, base.y) || isspike(base.x, base.y + base.height) || isspike(base.x + base.width, base.y + base.height))) |
From: Ryan F. <sik...@us...> - 2004-05-24 23:03:52
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12652 Modified Files: player.cpp Log Message: - fixed it so arm is not drawn when Tux is shooting and ducking Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.120 retrieving revision 1.121 diff -u -d -r1.120 -r1.121 --- player.cpp 24 May 2004 21:02:27 -0000 1.120 +++ player.cpp 24 May 2004 23:03:43 -0000 1.121 @@ -626,7 +626,7 @@ if(layer == LAYER_OBJECTS + 1) { // Draw arm overlay graphics when Tux is holding something - if ((holding_something && physic.get_velocity_y() == 0) || shooting_timer.check()) + if ((holding_something && physic.get_velocity_y() == 0) || shooting_timer.check() && !duck) { if (dir == RIGHT) sprite->grab_right->draw(pos); |
From: Matze B. <mat...@us...> - 2004-05-24 23:02:44
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12243 Modified Files: camera.cpp Log Message: added some comments to scrolling code Index: camera.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/camera.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- camera.cpp 24 May 2004 21:52:14 -0000 1.4 +++ camera.cpp 24 May 2004 23:02:34 -0000 1.5 @@ -80,21 +80,28 @@ if(elapsed_time < EPSILON) return; + /****** Vertical Scrolling part ******/ bool do_y_scrolling = true; if(player->dying || level->height == 19) do_y_scrolling = false; if(do_y_scrolling) { - float target_y; + // target_y is the high we target our scrolling at. This is not always the + // high of the player, but if he is jumping upwards we should use the + // position where he last touched the ground. + float target_y; if(player->fall_mode == Player::JUMPING) target_y = player->last_ground_y + player->base.height; else target_y = player->base.y + player->base.height; + // delta_y is the distance we'd have to travel to directly reach target_y float delta_y = translation.y - (target_y - screen->h/2); + // speed is the speed the camera would need to reach target_y in this frame float speed_y = delta_y / elapsed_time; + // limit the camera speed when jumping upwards if(player->fall_mode != Player::FALLING && player->fall_mode != Player::TRAMPOLINE_JUMP) { if(speed_y > max_speed_y) @@ -103,6 +110,7 @@ speed_y = -max_speed_y; } + // finally scroll with calculated speed translation.y -= speed_y * elapsed_time; // don't scroll before the start or after the level's end @@ -112,14 +120,24 @@ translation.y = 0; } + /****** Horizontal scrolling part *******/ + + // our camera is either in leftscrolling, rightscrolling or nonscrollingmode. + + // when suddenly changing directions while scrolling into the other direction. + // abort scrolling, since tux might be going left/right at a relatively small + // part of the map (like when jumping upwards) if((player->dir == ::LEFT && scrollchange == RIGHT) || (player->dir == ::RIGHT && scrollchange == LEFT)) scrollchange = NONE; + // when in left 1/3rd of screen scroll left if(player->base.x < translation.x + screen->w/3 && level->back_scrolling) scrollchange = LEFT; + // scroll right when in right 1/3rd of screen else if(player->base.x > translation.x + screen->w/3*2) scrollchange = RIGHT; + // calculate our scroll target depending on scroll mode float target_x; if(scrollchange == LEFT) target_x = player->base.x - screen->w/3*2; @@ -128,15 +146,19 @@ else target_x = translation.x; + // that's the distance we would have to travel to reach target_x float delta_x = translation.x - target_x; + // the speed we'd need to travel to reach target_x in this frame float speed_x = delta_x / elapsed_time; + // limit our speed float maxv = 1 + fabsf(player->physic.get_velocity_x() * 1.3); if(speed_x > maxv) speed_x = maxv; else if(speed_x < -maxv) speed_x = -maxv; - + + // apply scrolling translation.x -= speed_x * elapsed_time; // don't scroll before the start or after the level's end |
From: Matze B. <mat...@us...> - 2004-05-24 22:54:05
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10470 Modified Files: defines.h Log Message: increase offscreen distance Index: defines.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/defines.h,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- defines.h 22 May 2004 17:55:44 -0000 1.41 +++ defines.h 24 May 2004 22:53:39 -0000 1.42 @@ -92,8 +92,8 @@ /* Size constraints: */ -#define X_OFFSCREEN_DISTANCE 280 -#define Y_OFFSCREEN_DISTANCE 240 +#define X_OFFSCREEN_DISTANCE screen->w*2 +#define Y_OFFSCREEN_DISTANCE screen->h*2 #define LEVEL_WIDTH 375 |
From: Matze B. <mat...@us...> - 2004-05-24 22:37:06
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7071 Modified Files: badguy.cpp badguy.h world.cpp Log Message: make badguys reappear when scrolling back Index: badguy.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.h,v retrieving revision 1.45 retrieving revision 1.46 diff -u -d -r1.45 -r1.46 --- badguy.h 24 May 2004 21:02:26 -0000 1.45 +++ badguy.h 24 May 2004 22:36:56 -0000 1.46 @@ -102,6 +102,7 @@ bool seen; int squishcount; /// number of times this enemy was squiched Timer timer; + Vector start_position; Physic physic; float angle; @@ -144,6 +145,9 @@ void action_spiky(double frame_ratio); void action_snowball(double frame_ratio); + /** initializes the badguy (when he appears on screen) */ + void activate(Direction direction); + /** handles falling down. disables gravity calculation when we're back on * ground */ void fall(); Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.87 retrieving revision 1.88 diff -u -d -r1.87 -r1.88 --- badguy.cpp 24 May 2004 21:02:26 -0000 1.87 +++ badguy.cpp 24 May 2004 22:36:56 -0000 1.88 @@ -151,12 +151,8 @@ { display_manager.add_drawable(this, LAYER_OBJECTS); - base.x = 0; - base.y = 0; - lispreader.read_float("x", &base.x); - lispreader.read_float("y", &base.y); - base.width = 0; - base.height = 0; + lispreader.read_float("x", &start_position.x); + lispreader.read_float("y", &start_position.y); kind = kind_; @@ -171,10 +167,8 @@ { display_manager.add_drawable(this, LAYER_OBJECTS); - base.x = x; - base.y = y; - base.width = 0; - base.height = 0; + start_position.x = x; + start_position.y = y; stay_on_platform = false; kind = kind_; @@ -189,35 +183,78 @@ void BadGuy::init() { + base.x = 0; + base.y = 0; + base.width = 0; + base.height = 0; + mode = NORMAL; dying = DYING_NOT; old_base = base; dir = LEFT; seen = false; - frozen_timer.init(true); animation_offset = 0; sprite_left = sprite_right = 0; physic.reset(); + frozen_timer.init(true); timer.init(true); + // if we're in a solid tile at start correct that now + if(kind != BAD_FLAME && kind != BAD_FISH && collision_object_map(base)) + { + std::cout << "Warning: badguy started in wall: kind: " << badguykind_to_string(kind) + << " pos: (" << base.x << ", " << base.y << ")" << std::endl; + while(collision_object_map(base)) + --base.y; + } + + // just activate the badguy, since he might be on screen already. If not he + // gets deactivated anyway + activate(LEFT); +} + +void +BadGuy::write(LispWriter& writer) +{ + writer.start_list(badguykind_to_string(kind)); + + writer.write_float("x", base.x); + writer.write_float("y", base.y); + writer.write_bool("stay-on-platform", stay_on_platform); + + writer.end_list(badguykind_to_string(kind)); +} + +void +BadGuy::activate(Direction activation_dir) +{ + mode = NORMAL; + animation_offset = 0; + physic.reset(); + frozen_timer.init(true); + timer.init(true); + + dir = activation_dir; + float dirsign = activation_dir == LEFT ? -1 : 1; + if(kind == BAD_MRBOMB) { - physic.set_velocity(-BADGUY_WALK_SPEED, 0); + physic.set_velocity(dirsign * BADGUY_WALK_SPEED, 0); set_sprite(img_mrbomb_left, img_mrbomb_right); } else if (kind == BAD_MRICEBLOCK) { - physic.set_velocity(-BADGUY_WALK_SPEED, 0); + physic.set_velocity(dirsign * BADGUY_WALK_SPEED, 0); set_sprite(img_mriceblock_left, img_mriceblock_right); } else if(kind == BAD_JUMPY) { set_sprite(img_jumpy_left_up, img_jumpy_left_up); } else if(kind == BAD_BOMB) { set_sprite(img_mrbomb_ticking_left, img_mrbomb_ticking_right); - // hack so that the bomb doesn't hurt until it expldes... + // hack so that the bomb doesn't hurt until it expldes... dying = DYING_SQUISHED; } else if(kind == BAD_FLAME) { angle = 0; physic.enable_gravity(false); set_sprite(img_flame, img_flame); } else if(kind == BAD_BOUNCINGSNOWBALL) { - physic.set_velocity(-1.3, 0); + physic.set_velocity(dirsign * 1.3, 0); set_sprite(img_bouncingsnowball_left, img_bouncingsnowball_right); } else if(kind == BAD_STALACTITE) { physic.enable_gravity(false); @@ -229,33 +266,17 @@ set_sprite(img_flyingsnowball, img_flyingsnowball); physic.enable_gravity(false); } else if(kind == BAD_SPIKY) { - physic.set_velocity(-BADGUY_WALK_SPEED, 0); + physic.set_velocity(dirsign * BADGUY_WALK_SPEED, 0); set_sprite(img_spiky_left, img_spiky_right); } else if(kind == BAD_SNOWBALL) { - physic.set_velocity(-BADGUY_WALK_SPEED, 0); + physic.set_velocity(dirsign * BADGUY_WALK_SPEED, 0); set_sprite(img_snowball_left, img_snowball_right); } - // if we're in a solid tile at start correct that now - if(kind != BAD_FLAME && kind != BAD_FISH && collision_object_map(base)) - { - std::cout << "Warning: badguy started in wall: kind: " << badguykind_to_string(kind) - << " pos: (" << base.x << ", " << base.y << ")" << std::endl; - while(collision_object_map(base)) - --base.y; - } -} - -void -BadGuy::write(LispWriter& writer) -{ - writer.start_list(badguykind_to_string(kind)); - - writer.write_float("x", base.x); - writer.write_float("y", base.y); - writer.write_bool("stay-on-platform", stay_on_platform); - - writer.end_list(badguykind_to_string(kind)); + base.x = start_position.x; + base.y = start_position.y; + old_base = base; + seen = true; } void @@ -661,11 +682,7 @@ // Handle dying timer: if (dying == DYING_SQUISHED && !timer.check()) - { - /* Remove it if time's up: */ - remove_me(); - return; - } + remove_me(); } void @@ -701,11 +718,7 @@ // Handle dying timer: if (dying == DYING_SQUISHED && !timer.check()) - { - /* Remove it if time's up: */ - remove_me(); - return; - } + remove_me(); } void @@ -746,6 +759,10 @@ physic.apply(elapsed_time, base.x, base.y); if (dying != DYING_FALLING) collision_swept_object_map(&old_base,&base); + + // Handle dying timer: + if (dying == DYING_SQUISHED && !timer.check()) + remove_me(); } void @@ -771,16 +788,37 @@ kill_me(0); } - // Once it's on screen, it's activated! - if (base.x > scroll_x - X_OFFSCREEN_DISTANCE && - base.x < scroll_x + screen->w + X_OFFSCREEN_DISTANCE && - base.y > scroll_y - Y_OFFSCREEN_DISTANCE && - base.y < scroll_y + screen->h + Y_OFFSCREEN_DISTANCE) - seen = true; - + if(!seen) { + /* activate badguys if they're just inside the offscreen_distance around the + * screen. Don't activate them inside the screen, since that might have the + * effect of badguys suddenly popping up from nowhere + */ + if (start_position.x > scroll_x - X_OFFSCREEN_DISTANCE && + start_position.x < scroll_x - base.width) + activate(RIGHT); + else if(start_position.x > scroll_y - Y_OFFSCREEN_DISTANCE && + start_position.y < scroll_y - base.height) + activate(LEFT); + else if(start_position.x > scroll_x + screen->w && + start_position.x < scroll_x + screen->w + X_OFFSCREEN_DISTANCE) + activate(LEFT); + else if(start_position.y > scroll_y + screen->h && + start_position.y < scroll_y + screen->h + Y_OFFSCREEN_DISTANCE) + activate(LEFT); + } else { + if(base.x + base.width < scroll_x - X_OFFSCREEN_DISTANCE + || base.x > scroll_x + screen->w + X_OFFSCREEN_DISTANCE + || base.y + base.height < scroll_y - Y_OFFSCREEN_DISTANCE + || base.y > scroll_y + screen->h + Y_OFFSCREEN_DISTANCE) { + seen = false; + if(dying != DYING_NOT) + remove_me(); + } + } + if(!seen) return; - + switch (kind) { case BAD_MRICEBLOCK: @@ -968,7 +1006,7 @@ player_status.score_multiplier++; - // check for maximum number of squiches + // check for maximum number of squishes squishcount++; if(squishcount >= MAX_ICEBLOCK_SQUICHES) { kill_me(50); Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.112 retrieving revision 1.113 diff -u -d -r1.112 -r1.113 --- world.cpp 24 May 2004 21:18:56 -0000 1.112 +++ world.cpp 24 May 2004 22:36:56 -0000 1.113 @@ -203,7 +203,8 @@ * during the iteration) */ for(size_t i = 0; i < gameobjects.size(); ++i) - gameobjects[i]->action(elapsed_time); + if(gameobjects[i]->is_valid()) + gameobjects[i]->action(elapsed_time); /* Handle all possible collisions. */ collision_handler(); |
From: Ricardo C. <rm...@us...> - 2004-05-24 21:52:25
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30109/src Modified Files: camera.cpp Log Message: Small fix. Don't do back scrolling, in case it is unabled. And don't do vertical scrolling when there are 19 height tiles. It is necessary to explecity say so cause in this case, the actual height of the level is 608, higher than the screen (600). Index: camera.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/camera.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- camera.cpp 24 May 2004 21:28:44 -0000 1.3 +++ camera.cpp 24 May 2004 21:52:14 -0000 1.4 @@ -82,7 +82,7 @@ bool do_y_scrolling = true; - if(player->dying) + if(player->dying || level->height == 19) do_y_scrolling = false; if(do_y_scrolling) { @@ -115,7 +115,7 @@ if((player->dir == ::LEFT && scrollchange == RIGHT) || (player->dir == ::RIGHT && scrollchange == LEFT)) scrollchange = NONE; - if(player->base.x < translation.x + screen->w/3) + if(player->base.x < translation.x + screen->w/3 && level->back_scrolling) scrollchange = LEFT; else if(player->base.x > translation.x + screen->w/3*2) scrollchange = RIGHT; |
From: Ryan F. <sik...@us...> - 2004-05-24 21:29:22
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24730 Modified Files: camera.h Log Message: - missing include Index: camera.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/camera.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- camera.h 24 May 2004 21:18:56 -0000 1.2 +++ camera.h 24 May 2004 21:29:11 -0000 1.3 @@ -22,6 +22,7 @@ #include "vector.h" #include "game_object.h" #include "serializable.h" +#include <cassert> class LispReader; class Player; |
From: Matze B. <mat...@us...> - 2004-05-24 21:28:54
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24636 Modified Files: camera.cpp Log Message: try to make the scrolling a bit smoother Index: camera.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/camera.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- camera.cpp 24 May 2004 21:18:56 -0000 1.2 +++ camera.cpp 24 May 2004 21:28:44 -0000 1.3 @@ -131,7 +131,7 @@ float delta_x = translation.x - target_x; float speed_x = delta_x / elapsed_time; - float maxv = 1 + fabsf(player->physic.get_velocity_x() * 2); + float maxv = 1 + fabsf(player->physic.get_velocity_x() * 1.3); if(speed_x > maxv) speed_x = maxv; else if(speed_x < -maxv) |
From: Matze B. <mat...@us...> - 2004-05-24 21:19:06
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22529 Modified Files: camera.cpp camera.h world.cpp world.h Log Message: fixed bug I just introduced Index: world.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.h,v retrieving revision 1.49 retrieving revision 1.50 diff -u -d -r1.49 -r1.50 --- world.h 24 May 2004 21:02:44 -0000 1.49 +++ world.h 24 May 2004 21:18:56 -0000 1.50 @@ -49,8 +49,6 @@ Level* level; Player* tux; - Timer scrolling_timer; - int distro_counter; bool counting_distros; int currentmusic; @@ -71,9 +69,7 @@ static World* current() { return current_; } static void set_current(World* w) { current_ = w; } - World(const std::string& filename); - World(const std::string& subset, int level_nr); - //World() {}; + World(const std::string& filename, int level_nr = -1); ~World(); Level* get_level() { return level; } Index: camera.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/camera.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- camera.cpp 24 May 2004 21:02:26 -0000 1.1 +++ camera.cpp 24 May 2004 21:18:56 -0000 1.2 @@ -132,7 +132,6 @@ float speed_x = delta_x / elapsed_time; float maxv = 1 + fabsf(player->physic.get_velocity_x() * 2); - printf("SX: %f MV: %f.\n", player->physic.get_velocity_x(), maxv); if(speed_x > maxv) speed_x = maxv; else if(speed_x < -maxv) Index: camera.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/camera.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- camera.h 24 May 2004 21:02:26 -0000 1.1 +++ camera.h 24 May 2004 21:18:56 -0000 1.2 @@ -74,7 +74,11 @@ Player* player; Level* level; CameraMode mode; + + // normal mode LeftRightScrollChange scrollchange; + + // autoscroll mode }; #endif Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.111 retrieving revision 1.112 diff -u -d -r1.111 -r1.112 --- world.cpp 24 May 2004 21:02:27 -0000 1.111 +++ world.cpp 24 May 2004 21:18:56 -0000 1.112 @@ -42,14 +42,18 @@ World* World::current_ = 0; -World::World(const std::string& filename) +World::World(const std::string& filename, int level_nr) { // FIXME: Move this to action and draw and everywhere else where the // world calls child functions current_ = this; level = new Level(); - level->load(filename, this); + if(level_nr >= 0) { + level->load(filename, level_nr, this); + } else { + level->load(filename, this); + } tux = new Player(displaymanager); add_object(tux); @@ -71,44 +75,10 @@ add_object(new TileMap(displaymanager, level)); level->load_song(); - apply_bonuses(); - camera = new Camera(tux, level); - add_object(camera); - - scrolling_timer.init(true); -} - -World::World(const std::string& subset, int level_nr) -{ - // FIXME: Move this to action and draw and everywhere else where the - // world calls child functions - current_ = this; - - level = new Level(); - level->load(subset, level_nr, this); - - tux = new Player(displaymanager); - gameobjects.push_back(tux); - - set_defaults(); - - get_level()->load_gfx(); - activate_particle_systems(); - background = new Background(displaymanager); - if(level->img_bkgd) { - background->set_image(level->img_bkgd, level->bkgd_speed); - } else { - background->set_gradient(level->bkgd_top, level->bkgd_bottom); - } - gameobjects.push_back(background); - // add tilemap - gameobjects.push_back(new TileMap(displaymanager, get_level())); - get_level()->load_song(); + add_object(camera); apply_bonuses(); - - scrolling_timer.init(true); } void @@ -226,15 +196,15 @@ void World::action(float elapsed_time) { + tux->check_bounds(*camera, + level->back_scrolling, (bool)level->hor_autoscroll_speed); + /* update objects (don't use iterators here, because the list might change * during the iteration) */ for(size_t i = 0; i < gameobjects.size(); ++i) gameobjects[i]->action(elapsed_time); - tux->check_bounds(*camera, - level->back_scrolling, (bool)level->hor_autoscroll_speed); - /* Handle all possible collisions. */ collision_handler(); @@ -283,147 +253,6 @@ } } -/* the space that it takes for the screen to start scrolling, regarding */ -/* screen bounds (in pixels) */ -// should be higher than screen->w/2 (400) -#define X_SPACE (500-16) -// should be less than screen->h/2 (300) -#define Y_SPACE 250 - -static const float max_speed_y = 1.4; - -// the time it takes to move the camera (in ms) -#define CHANGE_DIR_SCROLL_SPEED 2000 - -static const float EPSILON = .0001; - -#if 0 -/* This functions takes cares of the scrolling */ -void World::scrolling(float elapsed_time) -{ - if(elapsed_time < EPSILON) - return; - - Vector scroll = displaymanager.get_viewport().get_translation(); - bool do_y_scrolling = true; - - if(tux->dying) - do_y_scrolling = false; - - /* Y-axis scrolling */ - if(do_y_scrolling) { - float target_y; - // upwards we target the y position of the platforms tux stands on - if(tux->fall_mode != Player::FALLING) - target_y = tux->last_ground_y + tux->base.height; - else - target_y = tux->base.y + tux->base.height; - - float delta_y = scroll.y - (target_y - (screen->h/2)); - float speed_y = delta_y / elapsed_time; - - float max = max_speed_y; - if(fabsf(delta_y) > float(screen->h)/5.0) - max *= 5; - - if(speed_y > max) - speed_y = max; - else if(speed_y < -max) - speed_y = -max; - - scroll.y -= speed_y * elapsed_time; - - // don't scroll before the start or after the level's end - if(scroll.y > level->height * 32 - screen->h) - scroll.y = level->height * 32 - screen->h; - if(scroll.y < 0) - scroll.y = 0; - } - - /* X-axis scrolling */ - -#if 0 - /* Auto scrolling */ - if(level->hor_autoscroll_speed) - { - scroll_x += level->hor_autoscroll_speed * elapsed_time; - displaymanager.get_viewport().set_translation(Vector(scroll_x, scroll_y)); - return; - } -#endif - - /* Horizontal backscrolling */ - float tux_pos_x = tux->base.x + (tux->base.width/2); - - if(tux->old_dir != tux->dir && level->back_scrolling) - scrolling_timer.start(CHANGE_DIR_SCROLL_SPEED); - - bool right = false; - bool left = false; - if (tux->physic.get_velocity_x() > 0) - right = true; - else if (tux->physic.get_velocity_x() < 0) - left = true; - else - { - if (tux->dir == RIGHT) - right = true; - else - left = true; - } - - if(scrolling_timer.check()) - { - float final_scroll_x; - float constant1; - float constant2; - if (right) - final_scroll_x = tux_pos_x - (screen->w - X_SPACE); - else - final_scroll_x = tux_pos_x - X_SPACE; - - if((tux->physic.get_velocity_x() > 0 && tux->dir == RIGHT) - || (tux->physic.get_velocity_x() < 0 && tux->dir == LEFT)) - { - constant1 = 1.0; - constant2 = .4; - } - else - { - constant1 = 0.; - constant2 = 0.; - } - - float number = 2.5/(elapsed_time * CHANGE_DIR_SCROLL_SPEED/1000)*exp((CHANGE_DIR_SCROLL_SPEED-scrolling_timer.get_left())/1400.); - if(left) number *= -1.; - - scroll.x += number - + constant1 * tux->physic.get_velocity_x() * elapsed_time - + constant2 * tux->physic.get_acceleration_x() * elapsed_time * - elapsed_time; - - if ((right && final_scroll_x - scroll.x < 0) || (left && final_scroll_x - - scroll.x > 0)) - scroll.x = final_scroll_x; - } - else - { - if (right && scroll.x < tux_pos_x - (screen->w - X_SPACE)) - scroll.x = tux_pos_x - (screen->w - X_SPACE); - else if (left && scroll.x > tux_pos_x - X_SPACE && level->back_scrolling) - scroll.x = tux_pos_x - X_SPACE; - } - - // don't scroll before the start or after the level's end - if(scroll.x > level->width * 32 - screen->w) - scroll.x = level->width * 32 - screen->w; - if(scroll.x < 0) - scroll.x = 0; - - displaymanager.get_viewport().set_translation(scroll); -} -#endif - void World::collision_handler() { |
From: Ricardo C. <rm...@us...> - 2004-05-24 21:06:07
|
Update of /cvsroot/super-tux/supertux/data/images/background In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19455/data/images/background Added Files: forest1.jpg Log Message: Forest background made by Benjamin! --- NEW FILE: forest1.jpg --- (This appears to be a binary file; contents omitted.) |
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17717 Modified Files: Makefile.am background.cpp background.h badguy.cpp badguy.h button.cpp display_manager.cpp display_manager.h drawable.h game_object.h gameloop.cpp gameobjs.cpp gameobjs.h leveleditor.cpp particlesystem.cpp particlesystem.h player.cpp player.h special.cpp special.h tilemap.cpp tilemap.h world.cpp world.h Added Files: camera.cpp camera.h Removed Files: viewport.cpp viewport.h Log Message: -renamed ViewPort to Camera -removed type() function from GameObject, you should better use C++ RTTI: * casting: BadGuy* badguy = dynamic_cast<BadGuy*> (object); * comparing for specific type if(typeid(object) == typeid(BadGuy)) * getting the name typeid(object).name() -moved camera handling into Camera class -tweaked camera behaviour. Look for details in http://netpanzer.berlios.de/supertux/index.php/Camera Horizontal scrolling seems to be nicely now, vertical scrolling is still a bit too hectically... Index: world.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.h,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- world.h 24 May 2004 11:59:59 -0000 1.48 +++ world.h 24 May 2004 21:02:44 -0000 1.49 @@ -64,6 +64,7 @@ std::vector<Bullet*> bullets; std::vector<GameObject*> gameobjects; + Camera* camera; DisplayManager displaymanager; public: @@ -84,7 +85,6 @@ void draw(); void action(float elapsed_time); - void scrolling(float elapsed_time); // camera scrolling void play_music(int musictype); int get_music_type(); Index: special.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/special.cpp,v retrieving revision 1.49 retrieving revision 1.50 diff -u -d -r1.49 -r1.50 --- special.cpp 22 May 2004 17:55:44 -0000 1.49 +++ special.cpp 24 May 2004 21:02:27 -0000 1.50 @@ -96,9 +96,9 @@ physic.set_velocity_y(-9); float scroll_x = - World::current()->displaymanager.get_viewport().get_translation().x; + World::current()->camera->get_translation().x; float scroll_y = - World::current()->displaymanager.get_viewport().get_translation().y; + World::current()->camera->get_translation().y; if (base.x < scroll_x || base.x > scroll_x + screen->w || base.y < scroll_y || @@ -112,7 +112,7 @@ } void -Bullet::draw(ViewPort& viewport, int ) +Bullet::draw(Camera& viewport, int ) { if(kind == FIRE_BULLET) img_firebullet->draw(viewport.world2screen(Vector(base.x, base.y))); @@ -187,9 +187,9 @@ /* Away from the screen? Kill it! */ float scroll_x = - World::current()->displaymanager.get_viewport().get_translation().x; + World::current()->camera->get_translation().x; float scroll_y = - World::current()->displaymanager.get_viewport().get_translation().y; + World::current()->camera->get_translation().y; if(base.x < scroll_x - X_OFFSCREEN_DISTANCE || base.x > scroll_x + screen->w + X_OFFSCREEN_DISTANCE || @@ -243,7 +243,7 @@ } void -Upgrade::draw(ViewPort& viewport, int) +Upgrade::draw(Camera& viewport, int) { SDL_Rect dest; Index: drawable.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/drawable.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- drawable.h 20 May 2004 23:19:55 -0000 1.2 +++ drawable.h 24 May 2004 21:02:26 -0000 1.3 @@ -19,7 +19,7 @@ #ifndef __DRAWABLE_H__ #define __DRAWABLE_H__ -class ViewPort; +class Camera; /** interface for all game objects that can be drawn on screen. */ @@ -28,7 +28,7 @@ public: /** This function draws the object on screen. */ - virtual void draw(ViewPort& viewport, int layer) = 0; + virtual void draw(Camera& viewport, int layer) = 0; }; #endif Index: tilemap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/tilemap.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- tilemap.cpp 20 May 2004 23:19:55 -0000 1.4 +++ tilemap.cpp 24 May 2004 21:02:27 -0000 1.5 @@ -42,7 +42,7 @@ } void -TileMap::draw(ViewPort& viewport, int layer) +TileMap::draw(Camera& viewport, int layer) { std::vector<unsigned int>* tiles; switch(layer) { Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.136 retrieving revision 1.137 diff -u -d -r1.136 -r1.137 --- gameloop.cpp 21 May 2004 00:22:57 -0000 1.136 +++ gameloop.cpp 24 May 2004 21:02:26 -0000 1.137 @@ -147,7 +147,7 @@ char str[60]; - ViewPort dummy; + Camera dummy; world->background->draw(dummy, LAYER_BACKGROUND0); sprintf(str, "%s", world->get_level()->name.c_str()); @@ -719,7 +719,7 @@ { char str[80]; - ViewPort dummy; + Camera dummy; world->background->draw(dummy, LAYER_BACKGROUND0); blue_text->drawf("Result:", 0, 200, A_HMIDDLE, A_TOP, 1); Index: special.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/special.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- special.h 20 May 2004 23:07:25 -0000 1.22 +++ special.h 24 May 2004 21:02:27 -0000 1.23 @@ -53,14 +53,11 @@ virtual ~Upgrade(); virtual void action(float frame_ratio); - virtual void draw(ViewPort& viewport, int layer); + virtual void draw(Camera& viewport, int layer); virtual void collision(const MovingObject& other, int); void collision(void* p_c_object, int c_object, CollisionType type); - virtual std::string type() const - { return "Upgrade"; }; - private: void bump(Player* player); }; @@ -77,12 +74,10 @@ int kind); virtual void action(float frame_ratio); - virtual void draw(ViewPort& viewport, int layer); + virtual void draw(Camera& viewport, int layer); void collision(int c_object); virtual void collision(const MovingObject& other_object, int type); - virtual std::string type() const - { return "Bullet"; }; int kind; Index: display_manager.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/display_manager.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- display_manager.h 20 May 2004 23:19:55 -0000 1.3 +++ display_manager.h 24 May 2004 21:02:26 -0000 1.4 @@ -22,7 +22,7 @@ #include <vector> #include "drawable.h" -#include "viewport.h" +#include "camera.h" // some constants for predefined layer values enum { @@ -51,10 +51,7 @@ void remove_drawable(Drawable* object); - void draw(); - - ViewPort& get_viewport() - { return viewport; } + void draw(Camera& camera); private: class DrawingQueueEntry { @@ -74,7 +71,6 @@ typedef std::vector<DrawingQueueEntry> DisplayList; DisplayList displaylist; - ViewPort viewport; }; #endif Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.86 retrieving revision 1.87 diff -u -d -r1.86 -r1.87 --- badguy.cpp 22 May 2004 18:42:40 -0000 1.86 +++ badguy.cpp 24 May 2004 21:02:26 -0000 1.87 @@ -35,7 +35,7 @@ #include "gameloop.h" #include "display_manager.h" #include "lispwriter.h" -#include "viewport.h" +#include "camera.h" Sprite* img_mriceblock_flat_left; Sprite* img_mriceblock_flat_right; @@ -316,8 +316,7 @@ check_horizontal_bump(); if(mode == KICK && changed != dir) { - float scroll_x = World::current()->displaymanager - .get_viewport().get_translation().x; + float scroll_x = World::current()->camera->get_translation().x; /* handle stereo sound (number 10 should be tweaked...)*/ if (base.x < scroll_x + screen->w/2 - 10) @@ -518,8 +517,7 @@ dying = DYING_NOT; // now the bomb hurts timer.start(EXPLODETIME); - float scroll_x = World::current()->displaymanager - .get_viewport().get_translation().x; + float scroll_x = World::current()->camera->get_translation().x; /* play explosion sound */ // FIXME: is the stereo all right? maybe we should use player cordinates... if (base.x < scroll_x + screen->w/2 - 10) @@ -753,10 +751,8 @@ void BadGuy::action(float elapsed_time) { - float scroll_x = World::current()->displaymanager - .get_viewport().get_translation().x; - float scroll_y = World::current()->displaymanager - .get_viewport().get_translation().y; + float scroll_x = World::current()->camera->get_translation().x; + float scroll_y = World::current()->camera->get_translation().y; // BadGuy fall below the ground if (base.y > World::current()->get_level()->height * 32) { @@ -836,7 +832,7 @@ } void -BadGuy::draw(ViewPort& viewport, int) +BadGuy::draw(Camera& viewport, int) { float scroll_x = viewport.get_translation().x; float scroll_y = viewport.get_translation().y; Index: badguy.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.h,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- badguy.h 20 May 2004 23:07:24 -0000 1.44 +++ badguy.h 24 May 2004 21:02:26 -0000 1.45 @@ -118,10 +118,8 @@ virtual void write(LispWriter& writer); virtual void action(float frame_ratio); - virtual void draw(ViewPort& viewport, int layer); + virtual void draw(Camera& viewport, int layer); virtual void collision(const MovingObject& other, int type); - virtual std::string type() const - { return "BadGuy"; }; void collision(void* p_c_object, int c_object, CollisionType type = COLLISION_NORMAL); Index: gameobjs.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.cpp,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- gameobjs.cpp 24 May 2004 20:41:43 -0000 1.34 +++ gameobjs.cpp 24 May 2004 21:02:27 -0000 1.35 @@ -47,7 +47,7 @@ } void -BouncyDistro::draw(ViewPort& viewport, int ) +BouncyDistro::draw(Camera& viewport, int ) { img_distro[0]->draw(viewport.world2screen(position)); } @@ -71,7 +71,7 @@ } void -BrokenBrick::draw(ViewPort& viewport, int ) +BrokenBrick::draw(Camera& viewport, int ) { SDL_Rect src, dest; src.x = rand() % 16; @@ -110,7 +110,7 @@ } void -BouncyBrick::draw(ViewPort& viewport, int) +BouncyBrick::draw(Camera& viewport, int) { Tile::draw(viewport.world2screen(position + Vector(0, offset)), shape); } @@ -135,7 +135,7 @@ } void -FloatingScore::draw(ViewPort& viewport, int ) +FloatingScore::draw(Camera& viewport, int ) { gold_text->draw(str, viewport.world2screen(position)); } @@ -174,7 +174,7 @@ } void -Trampoline::draw(ViewPort& viewport, int ) +Trampoline::draw(Camera& viewport, int ) { img_trampoline[frame]->draw(viewport.world2screen(Vector(base.x, base.y))); frame = 0; @@ -264,8 +264,10 @@ else frame = 0; - if (squish_amount < 20) + if (squish_amount < 20) { pplayer_c->physic.set_velocity_y(power); + pplayer_c->fall_mode = Player::TRAMPOLINE_JUMP; + } else if (pplayer_c->physic.get_velocity_y() < 0) pplayer_c->physic.set_velocity_y(-squish_amount/32); } @@ -316,7 +318,7 @@ } void -FlyingPlatform::draw(ViewPort& viewport, int ) +FlyingPlatform::draw(Camera& viewport, int ) { img_flying_platform->draw(viewport.world2screen(Vector(base.x, base.y))); } --- NEW FILE: camera.cpp --- // $Id: camera.cpp,v 1.1 2004/05/24 21:02:26 matzebraun Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Matthias Braun <ma...@br... // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "camera.h" #include <math.h> #include "lispwriter.h" #include "player.h" #include "level.h" #include "globals.h" Camera::Camera(Player* newplayer, Level* newlevel) : player(newplayer), level(newlevel), scrollchange(NONE) { if(!player || !level) mode = MANUAL; else mode = NORMAL; } Camera::~Camera() { } void Camera::set_translation(const Vector& newtranslation) { translation = newtranslation; } void Camera::write(LispWriter& writer) { writer.start_list("camera"); if(mode == NORMAL) { writer.write_string("mode", "normal"); } else if(mode == AUTOSCROLL) { writer.write_string("mode", "autoscroll"); } else if(mode == MANUAL) { writer.write_string("mode", "manual"); } writer.end_list("camera"); } static const float EPSILON = .00001; static const float max_speed_y = 1.4; void Camera::action(float elapsed_time) { if(mode == NORMAL) scroll_normal(elapsed_time); else if(mode == AUTOSCROLL) scroll_autoscroll(elapsed_time); } void Camera::scroll_normal(float elapsed_time) { assert(level != 0 && player != 0); // check that we don't have division by zero later if(elapsed_time < EPSILON) return; bool do_y_scrolling = true; if(player->dying) do_y_scrolling = false; if(do_y_scrolling) { float target_y; if(player->fall_mode == Player::JUMPING) target_y = player->last_ground_y + player->base.height; else target_y = player->base.y + player->base.height; float delta_y = translation.y - (target_y - screen->h/2); float speed_y = delta_y / elapsed_time; if(player->fall_mode != Player::FALLING && player->fall_mode != Player::TRAMPOLINE_JUMP) { if(speed_y > max_speed_y) speed_y = max_speed_y; else if(speed_y < -max_speed_y) speed_y = -max_speed_y; } translation.y -= speed_y * elapsed_time; // don't scroll before the start or after the level's end if(translation.y > level->height * 32 - screen->h) translation.y = level->height * 32 - screen->h; if(translation.y < 0) translation.y = 0; } if((player->dir == ::LEFT && scrollchange == RIGHT) || (player->dir == ::RIGHT && scrollchange == LEFT)) scrollchange = NONE; if(player->base.x < translation.x + screen->w/3) scrollchange = LEFT; else if(player->base.x > translation.x + screen->w/3*2) scrollchange = RIGHT; float target_x; if(scrollchange == LEFT) target_x = player->base.x - screen->w/3*2; else if(scrollchange == RIGHT) target_x = player->base.x - screen->w/3; else target_x = translation.x; float delta_x = translation.x - target_x; float speed_x = delta_x / elapsed_time; float maxv = 1 + fabsf(player->physic.get_velocity_x() * 2); printf("SX: %f MV: %f.\n", player->physic.get_velocity_x(), maxv); if(speed_x > maxv) speed_x = maxv; else if(speed_x < -maxv) speed_x = -maxv; translation.x -= speed_x * elapsed_time; // don't scroll before the start or after the level's end if(translation.x > level->width * 32 - screen->w) translation.x = level->width * 32 - screen->w; if(translation.x < 0) translation.x = 0; } void Camera::scroll_autoscroll(float elapsed_time) { // TODO } Index: game_object.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/game_object.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- game_object.h 20 May 2004 23:19:55 -0000 1.3 +++ game_object.h 24 May 2004 21:02:26 -0000 1.4 @@ -41,11 +41,6 @@ GameObject(); virtual ~GameObject(); - /** returns the name of the objecttype, this is mainly usefull for the editor. - * For the coding part you should use C++ RTTI (ie. typeid and dynamic_cast) - * instead. - */ - virtual std::string type() const = 0; /** This function is called once per frame and allows the object to update * it's state. The elapsed_time is the time since the last frame and should be * the base for all timed things. Index: Makefile.am =================================================================== RCS file: /cvsroot/super-tux/supertux/src/Makefile.am,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- Makefile.am 20 May 2004 23:19:55 -0000 1.26 +++ Makefile.am 24 May 2004 21:02:26 -0000 1.27 @@ -77,8 +77,8 @@ music_manager.h \ musicref.cpp \ musicref.h \ -viewport.cpp \ -viewport.h \ +camera.cpp \ +camera.h \ game_object.cpp \ game_object.h \ display_manager.h \ Index: player.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.h,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- player.h 23 May 2004 00:11:58 -0000 1.60 +++ player.h 24 May 2004 21:02:27 -0000 1.61 @@ -112,6 +112,7 @@ public: enum HurtMode { KILL, SHRINK }; enum Power { NONE_POWER, FIRE_POWER, ICE_POWER }; + enum FallMode { ON_GROUND, JUMPING, TRAMPOLINE_JUMP, FALLING }; player_input_type input; int got_power; @@ -123,6 +124,9 @@ Direction dir; Direction old_dir; + float last_ground_y; + FallMode fall_mode; + bool jumping; bool can_jump; bool butt_jump; @@ -148,18 +152,16 @@ void grabdistros(); virtual void action(float elapsed_time); - virtual void draw(ViewPort& viewport, int layer); + virtual void draw(Camera& viewport, int layer); virtual void collision(const MovingObject& other_object, int collision_type); - virtual std::string type() const - { return "Player"; } void collision(void* p_c_object, int c_object); void kill(HurtMode mode); void is_dying(); bool is_dead(); void player_remove_powerups(); - void check_bounds(ViewPort& viewport, bool back_scrolling, bool hor_autoscroll); + void check_bounds(Camera& viewport, bool back_scrolling, bool hor_autoscroll); bool on_ground(); bool under_solid(); bool tiles_on_air(int tiles); --- viewport.h DELETED --- Index: particlesystem.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/particlesystem.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- particlesystem.cpp 20 May 2004 12:12:38 -0000 1.7 +++ particlesystem.cpp 24 May 2004 21:02:27 -0000 1.8 @@ -25,7 +25,7 @@ #include "world.h" #include "level.h" #include "scene.h" -#include "viewport.h" +#include "camera.h" #include "display_manager.h" ParticleSystem::ParticleSystem(DisplayManager& displaymanager) @@ -44,7 +44,7 @@ } } -void ParticleSystem::draw(ViewPort& viewport, int layer) +void ParticleSystem::draw(Camera& viewport, int layer) { std::vector<Particle*>::iterator i; for(i = particles.begin(); i != particles.end(); ++i) { Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.110 retrieving revision 1.111 diff -u -d -r1.110 -r1.111 --- world.cpp 24 May 2004 11:59:59 -0000 1.110 +++ world.cpp 24 May 2004 21:02:27 -0000 1.111 @@ -33,7 +33,7 @@ #include "tile.h" #include "resources.h" #include "gameobjs.h" -#include "viewport.h" +#include "camera.h" #include "display_manager.h" #include "background.h" #include "tilemap.h" @@ -52,11 +52,11 @@ level->load(filename, this); tux = new Player(displaymanager); - gameobjects.push_back(tux); + add_object(tux); set_defaults(); - get_level()->load_gfx(); + level->load_gfx(); // add background activate_particle_systems(); background = new Background(displaymanager); @@ -65,14 +65,17 @@ } else { background->set_gradient(level->bkgd_top, level->bkgd_bottom); } - gameobjects.push_back(background); + add_object(background); // add tilemap - gameobjects.push_back(new TileMap(displaymanager, get_level())); - get_level()->load_song(); + add_object(new TileMap(displaymanager, level)); + level->load_song(); apply_bonuses(); + camera = new Camera(tux, level); + add_object(camera); + scrolling_timer.init(true); } @@ -217,7 +220,7 @@ World::draw() { /* Draw objects */ - displaymanager.draw(); + displaymanager.draw(*camera); } void @@ -229,9 +232,8 @@ for(size_t i = 0; i < gameobjects.size(); ++i) gameobjects[i]->action(elapsed_time); - tux->check_bounds(displaymanager.get_viewport(), + tux->check_bounds(*camera, level->back_scrolling, (bool)level->hor_autoscroll_speed); - scrolling(elapsed_time); /* Handle all possible collisions. */ collision_handler(); @@ -288,35 +290,59 @@ // should be less than screen->h/2 (300) #define Y_SPACE 250 +static const float max_speed_y = 1.4; + // the time it takes to move the camera (in ms) #define CHANGE_DIR_SCROLL_SPEED 2000 +static const float EPSILON = .0001; + +#if 0 /* This functions takes cares of the scrolling */ void World::scrolling(float elapsed_time) { - float scroll_x = displaymanager.get_viewport().get_translation().x; - float scroll_y = displaymanager.get_viewport().get_translation().y; + if(elapsed_time < EPSILON) + return; + + Vector scroll = displaymanager.get_viewport().get_translation(); + bool do_y_scrolling = true; + + if(tux->dying) + do_y_scrolling = false; /* Y-axis scrolling */ + if(do_y_scrolling) { + float target_y; + // upwards we target the y position of the platforms tux stands on + if(tux->fall_mode != Player::FALLING) + target_y = tux->last_ground_y + tux->base.height; + else + target_y = tux->base.y + tux->base.height; - float tux_pos_y = tux->base.y + (tux->base.height/2); + float delta_y = scroll.y - (target_y - (screen->h/2)); + float speed_y = delta_y / elapsed_time; - if(level->height > VISIBLE_TILES_Y-1 && !tux->dying) - { - if (scroll_y < tux_pos_y - (screen->h - Y_SPACE)) - scroll_y = tux_pos_y - (screen->h - Y_SPACE); - else if (scroll_y > tux_pos_y - Y_SPACE) - scroll_y = tux_pos_y - Y_SPACE; - } + float max = max_speed_y; + if(fabsf(delta_y) > float(screen->h)/5.0) + max *= 5; + + if(speed_y > max) + speed_y = max; + else if(speed_y < -max) + speed_y = -max; - // this code prevent the screen to scroll before the start or after the level's end - if(scroll_y > level->height * 32 - screen->h) - scroll_y = level->height * 32 - screen->h; - if(scroll_y < 0) - scroll_y = 0; + scroll.y -= speed_y * elapsed_time; + + // don't scroll before the start or after the level's end + if(scroll.y > level->height * 32 - screen->h) + scroll.y = level->height * 32 - screen->h; + if(scroll.y < 0) + scroll.y = 0; + } /* X-axis scrolling */ +#if 0 /* Auto scrolling */ if(level->hor_autoscroll_speed) { @@ -324,7 +350,7 @@ displaymanager.get_viewport().set_translation(Vector(scroll_x, scroll_y)); return; } - +#endif /* Horizontal backscrolling */ float tux_pos_x = tux->base.x + (tux->base.width/2); @@ -371,31 +397,32 @@ float number = 2.5/(elapsed_time * CHANGE_DIR_SCROLL_SPEED/1000)*exp((CHANGE_DIR_SCROLL_SPEED-scrolling_timer.get_left())/1400.); if(left) number *= -1.; - scroll_x += number + scroll.x += number + constant1 * tux->physic.get_velocity_x() * elapsed_time + constant2 * tux->physic.get_acceleration_x() * elapsed_time * elapsed_time; - if ((right && final_scroll_x - scroll_x < 0) || (left && final_scroll_x - scroll_x > 0)) - scroll_x = final_scroll_x; - + if ((right && final_scroll_x - scroll.x < 0) || (left && final_scroll_x - + scroll.x > 0)) + scroll.x = final_scroll_x; } else { - if (right && scroll_x < tux_pos_x - (screen->w - X_SPACE)) - scroll_x = tux_pos_x - (screen->w - X_SPACE); - else if (left && scroll_x > tux_pos_x - X_SPACE && level->back_scrolling) - scroll_x = tux_pos_x - X_SPACE; + if (right && scroll.x < tux_pos_x - (screen->w - X_SPACE)) + scroll.x = tux_pos_x - (screen->w - X_SPACE); + else if (left && scroll.x > tux_pos_x - X_SPACE && level->back_scrolling) + scroll.x = tux_pos_x - X_SPACE; } - // this code prevent the screen to scroll before the start or after the level's end - if(scroll_x > level->width * 32 - screen->w) - scroll_x = level->width * 32 - screen->w; - if(scroll_x < 0) - scroll_x = 0; + // don't scroll before the start or after the level's end + if(scroll.x > level->width * 32 - screen->w) + scroll.x = level->width * 32 - screen->w; + if(scroll.x < 0) + scroll.x = 0; - displaymanager.get_viewport().set_translation(Vector(scroll_x, scroll_y)); + displaymanager.get_viewport().set_translation(scroll); } +#endif void World::collision_handler() Index: gameobjs.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- gameobjs.h 24 May 2004 11:59:59 -0000 1.22 +++ gameobjs.h 24 May 2004 21:02:27 -0000 1.23 @@ -42,9 +42,7 @@ public: BouncyDistro(DisplayManager& displaymanager, const Vector& pos); virtual void action(float elapsed_time); - virtual void draw(ViewPort& viewport, int layer); - virtual std::string type() const - { return "BouncyDistro"; }; + virtual void draw(Camera& viewport, int layer); private: Vector position; @@ -65,10 +63,7 @@ const Vector& pos, const Vector& movement); virtual void action(float elapsed_time); - virtual void draw(ViewPort& viewport, int layer); - - virtual std::string type() const - { return "BrokenBrick"; }; + virtual void draw(Camera& viewport, int layer); private: Timer timer; @@ -82,11 +77,8 @@ public: BouncyBrick(DisplayManager& displaymanager, const Vector& pos); virtual void action(float elapsed_time); - virtual void draw(ViewPort& viewport, int layer); + virtual void draw(Camera& viewport, int layer); - virtual std::string type() const - { return "BouncyBrick"; }; - private: Vector position; float offset; @@ -100,9 +92,7 @@ FloatingScore(DisplayManager& displaymanager, const Vector& pos, int s); virtual void action(float elapsed_time); - virtual void draw(ViewPort& viewport, int layer); - virtual std::string type() const - { return "FloatingScore"; }; + virtual void draw(Camera& viewport, int layer); private: Vector position; @@ -117,9 +107,7 @@ virtual void write(LispWriter& writer); virtual void action(float frame_ratio); - virtual void draw(ViewPort& viewport, int layer); - virtual std::string type() const - { return "Trampoline"; }; + virtual void draw(Camera& viewport, int layer); virtual void collision(const MovingObject& other, int); void collision(void *p_c_object, int c_object, CollisionType type); @@ -139,9 +127,7 @@ virtual void write(LispWriter& writer); virtual void action(float frame_ratio); - virtual void draw(ViewPort& viewport, int layer); - virtual std::string type() const - { return "Trampoline"; }; + virtual void draw(Camera& viewport, int layer); virtual void collision(const MovingObject& other, int); void collision(void *p_c_object, int c_object, CollisionType type); Index: tilemap.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/tilemap.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- tilemap.h 20 May 2004 23:19:55 -0000 1.3 +++ tilemap.h 24 May 2004 21:02:27 -0000 1.4 @@ -34,9 +34,7 @@ virtual ~TileMap(); virtual void action(float elapsed_time); - virtual void draw(ViewPort& viewport, int layer); - virtual std::string type() const - { return "TileMap"; } + virtual void draw(Camera& viewport, int layer); private: Level* level; Index: particlesystem.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/particlesystem.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- particlesystem.h 20 May 2004 23:07:25 -0000 1.5 +++ particlesystem.h 24 May 2004 21:02:27 -0000 1.6 @@ -48,7 +48,7 @@ ParticleSystem(DisplayManager& displaymanager); virtual ~ParticleSystem(); - virtual void draw(ViewPort& view, int layer); + virtual void draw(Camera& view, int layer); protected: class Particle --- NEW FILE: camera.h --- // $Id: camera.h,v 1.1 2004/05/24 21:02:26 matzebraun Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Matthias Braun <ma...@br... // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef __VIEWPORT_H__ #define __VIEWPORT_H__ #include "vector.h" #include "game_object.h" #include "serializable.h" class LispReader; class Player; class Level; class Camera : public GameObject, public Serializable { public: Camera(Player* player = 0, Level* level = 0); virtual ~Camera(); /** transforms a coordinate in world space to screen space. * Basically you have to apply this function to each coordinate that you want * to display on screen. */ Vector world2screen(const Vector& worldpos) const { return worldpos - translation; } /// parse camera mode from lisp file void parse_camera(LispReader& reader); /// write camera mode to a lisp file virtual void write(LispWriter& writer); /** returns the current translation (=scroll) vector of the viewport */ const Vector& get_translation() const { return translation; } /** set the curren translation vector of the viewport */ void set_translation(const Vector& translation); virtual void action(float elapsed_time); enum CameraMode { NORMAL, AUTOSCROLL, MANUAL }; private: void scroll_normal(float elapsed_time); void scroll_autoscroll(float elapsed_time); enum LeftRightScrollChange { NONE, LEFT, RIGHT }; Vector translation; Player* player; Level* level; CameraMode mode; LeftRightScrollChange scrollchange; }; #endif --- viewport.cpp DELETED --- Index: button.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/button.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- button.cpp 20 May 2004 19:56:37 -0000 1.30 +++ button.cpp 24 May 2004 21:02:26 -0000 1.31 @@ -24,7 +24,7 @@ #include "screen.h" #include "globals.h" #include "button.h" -#include "viewport.h" +#include "camera.h" Timer Button::popup_timer; @@ -87,7 +87,7 @@ if(drawable) { - ViewPort viewport; + Camera viewport; viewport.set_translation(Vector(rect.x, rect.y)); drawable->draw(viewport, 0); } Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.125 retrieving revision 1.126 diff -u -d -r1.125 -r1.126 --- leveleditor.cpp 21 May 2004 19:35:14 -0000 1.125 +++ leveleditor.cpp 24 May 2004 21:02:27 -0000 1.126 @@ -19,6 +19,7 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <map> +#include <typeinfo> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -942,8 +943,7 @@ Uint8 a; /* Draw the real background */ - le_world->background->draw(le_world->displaymanager.get_viewport(), - LAYER_BACKGROUND0); + le_world->background->draw(*le_world->camera, LAYER_BACKGROUND0); if(le_current.IsTile()) { @@ -1012,7 +1012,7 @@ continue; /* to support frames: img_bsod_left[(frame / 5) % 4] */ - ViewPort viewport; + Camera viewport; viewport.set_translation(Vector(pos_x, pos_y)); badguy->draw(viewport, 0); } @@ -1028,7 +1028,8 @@ Menu* object_properties_menu = new Menu(); bool loop = true; - object_properties_menu->additem(MN_LABEL,pobj->type() + " Properties",0,0); + std::string type = typeid(pobj).name(); + object_properties_menu->additem(MN_LABEL, type + " Properties",0,0); object_properties_menu->additem(MN_HL,"",0,0); BadGuy* pbad = dynamic_cast<BadGuy*>(pobj); @@ -1510,15 +1511,17 @@ if(le_current.IsObject()) { le_level_changed = true; - std::string type = le_current.obj->type(); + BadGuy* pbadguy = dynamic_cast<BadGuy*>(le_current.obj); - if(type == "BadGuy") + if(pbadguy) { - ViewPort viewport(le_world->displaymanager.get_viewport()); + Camera& camera = *le_world->camera; DisplayManager dummy; - BadGuy* pbadguy = dynamic_cast<BadGuy*>(le_current.obj); - le_world->bad_guys.push_back(new BadGuy(dummy, pbadguy->kind, cursor_x + viewport.get_translation().x, cursor_y + viewport.get_translation().y)); + le_world->bad_guys.push_back( + new BadGuy(dummy, pbadguy->kind, + cursor_x + camera.get_translation().x, + cursor_y + camera.get_translation().y)); le_world->gameobjects.push_back(le_world->bad_guys.back()); } } @@ -1678,11 +1681,11 @@ /* if there is a bad guy over there, remove it */ // XXX TODO for(std::vector<GameObject*>::iterator it = le_world->gameobjects.begin(); - it != le_world->gameobjects.end(); ++it) - if ((*it)->type() == "BadGuy") + it != le_world->gameobjects.end(); ++it) { + BadGuy* badguy = dynamic_cast<BadGuy*>((*it)); + if (badguy) { - BadGuy* pbadguy = dynamic_cast<BadGuy*>((*it)); - if(rectcollision(cursor_base, pbadguy->base)) + if(rectcollision(cursor_base, badguy->base)) { delete (*it); //le_world->bad_guys.erase(it); @@ -1690,6 +1693,7 @@ break; } } + } break; case SQUARE: @@ -1724,9 +1728,9 @@ for(std::vector<GameObject*>::iterator it = le_world->gameobjects.begin(); it != le_world->gameobjects.end(); ++it /* will be at end of loop */) { - if ((*it)->type() == "BadGuy") + MovingObject* pmobject = dynamic_cast<MovingObject*> (*it); + if (pmobject) { - MovingObject* pmobject = dynamic_cast<MovingObject*> (*it); if(pmobject->base.x/32 >= x1 && pmobject->base.x/32 <= x2 && pmobject->base.y/32 >= y1 && pmobject->base.y/32 <= y2) { Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.119 retrieving revision 1.120 diff -u -d -r1.119 -r1.120 --- player.cpp 24 May 2004 11:59:59 -0000 1.119 +++ player.cpp 24 May 2004 21:02:27 -0000 1.120 @@ -101,6 +101,8 @@ duck = false; dying = DYING_NOT; + last_ground_y = 0; + fall_mode = ON_GROUND; jumping = false; can_jump = true; butt_jump = false; @@ -415,6 +417,17 @@ void Player::handle_vertical_input() { + // set fall mode... + if(on_ground()) { + fall_mode = ON_GROUND; + last_ground_y = base.y; + } else { + if(base.y > last_ground_y) + fall_mode = FALLING; + else if(fall_mode == ON_GROUND) + fall_mode = JUMPING; + } + // Press jump key if(input.up == DOWN && can_jump && on_ground()) { @@ -596,7 +609,7 @@ } void -Player::draw(ViewPort& viewport, int layer) +Player::draw(Camera& viewport, int layer) { PlayerSprite* sprite; @@ -857,9 +870,9 @@ bool Player::is_dead() { float scroll_x = - World::current()->displaymanager.get_viewport().get_translation().x; + World::current()->camera->get_translation().x; float scroll_y = - World::current()->displaymanager.get_viewport().get_translation().y; + World::current()->camera->get_translation().y; if(base.y > screen->h + scroll_y || base.y > World::current()->get_level()->height*32 || base.x < scroll_x - AUTOSCROLL_DEAD_INTERVAL) // can happen in auto-scrolling return true; @@ -877,7 +890,7 @@ } void -Player::check_bounds(ViewPort& viewport, +Player::check_bounds(Camera& viewport, bool back_scrolling, bool hor_autoscroll) { /* Keep tux in bounds: */ Index: background.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/background.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- background.cpp 20 May 2004 23:19:55 -0000 1.2 +++ background.cpp 24 May 2004 21:02:26 -0000 1.3 @@ -19,7 +19,7 @@ #include "background.h" #include "globals.h" -#include "viewport.h" +#include "camera.h" #include "display_manager.h" Background::Background(DisplayManager& displaymanager) @@ -53,7 +53,7 @@ } void -Background::draw(ViewPort& viewport, int ) +Background::draw(Camera& viewport, int ) { if(bgtype == BACKGROUND_GRADIENT) { drawgradient(gradient_top, gradient_bottom); Index: display_manager.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/display_manager.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- display_manager.cpp 20 May 2004 23:19:55 -0000 1.3 +++ display_manager.cpp 24 May 2004 21:02:26 -0000 1.4 @@ -51,10 +51,10 @@ } void -DisplayManager::draw() +DisplayManager::draw(Camera& camera) { for(DisplayList::iterator i = displaylist.begin(); i != displaylist.end(); ++i) - i->object->draw(viewport, i->layer); + i->object->draw(camera, i->layer); } Index: background.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/background.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- background.h 20 May 2004 23:19:55 -0000 1.3 +++ background.h 24 May 2004 21:02:26 -0000 1.4 @@ -40,12 +40,9 @@ void set_gradient(Color top, Color bottom); - virtual std::string type() const - { return "Background"; } - virtual void action(float elapsed_time); - virtual void draw(ViewPort& viewport, int layer); + virtual void draw(Camera& viewport, int layer); private: int bgtype; |
From: Ricardo C. <rm...@us...> - 2004-05-24 20:42:31
|
Update of /cvsroot/super-tux/supertux/data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14173/data Modified Files: supertux.strf Log Message: Fixed checking for next point and the use of sprites. Index: supertux.strf =================================================================== RCS file: /cvsroot/super-tux/supertux/data/supertux.strf,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- supertux.strf 24 May 2004 12:01:35 -0000 1.34 +++ supertux.strf 24 May 2004 20:42:21 -0000 1.35 @@ -633,7 +633,7 @@ (images "shared/trampoline-4.png")) ; Flying platforms - (sprite (name "flying_platform-1") + (sprite (name "flying_platform") (x-hotspot 0) (x-hotspot 0) (images "shared/flying_platform-1.png")) |
From: Ricardo C. <rm...@us...> - 2004-05-24 20:41:55
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14025/src Modified Files: gameobjs.cpp Log Message: Fixed checking for next point and the use of sprites. Index: gameobjs.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- gameobjs.cpp 24 May 2004 11:59:59 -0000 1.33 +++ gameobjs.cpp 24 May 2004 20:41:43 -0000 1.34 @@ -280,8 +280,7 @@ /* Flying Platform */ -#define FLYING_PLATFORM_FRAMES 1 -Sprite *img_flying_platform[FLYING_PLATFORM_FRAMES]; +Sprite *img_flying_platform; FlyingPlatform::FlyingPlatform(DisplayManager& displaymanager, LispReader& reader) { @@ -319,7 +318,7 @@ void FlyingPlatform::draw(ViewPort& viewport, int ) { -img_flying_platform[frame]->draw(viewport.world2screen(Vector(base.x, base.y))); +img_flying_platform->draw(viewport.world2screen(Vector(base.x, base.y))); } void @@ -327,21 +326,21 @@ { // TODO: Remove if we're too far off the screen - // FIXME: change frame if(!move) return; if((unsigned)point+1 != pos_x.size()) + { if(((pos_x[point+1] > pos_x[point] && base.x >= pos_x[point+1]) || (pos_x[point+1] < pos_x[point] && base.x <= pos_x[point+1]) || - pos_x[point+1] == pos_x[point+1]) && + pos_x[point] == pos_x[point+1]) && ((pos_y[point+1] > pos_y[point] && base.y >= pos_y[point+1]) || (pos_y[point+1] < pos_y[point] && base.y <= pos_y[point+1]) || - pos_y[point+1] == pos_y[point+1])) + pos_y[point] == pos_y[point+1])) { point++; -std::cerr << "next point: " << point << std::endl; } + } else // last point { // point = 0; @@ -349,14 +348,14 @@ return; } -if(pos_x[point] > base.x) +if(pos_x[point+1] > base.x) base.x += velocity * frame_ratio; -else if(pos_x[point] < base.x) +else if(pos_x[point+1] < base.x) base.x -= velocity * frame_ratio; -if(pos_y[point] > base.y) +if(pos_y[point+1] > base.y) base.y += velocity * frame_ratio; -else if(pos_y[point] < base.y) +else if(pos_y[point+1] < base.y) base.y -= velocity * frame_ratio; /* float x = pos_x[point+1] - pos_x[point]; @@ -387,7 +386,7 @@ case CO_PLAYER: // pplayer_c = (Player*) p_c_object; move = true; - + break; default: @@ -406,9 +405,5 @@ img_trampoline[i] = sprite_manager->load(sprite_name); } - for (int i = 0; i < FLYING_PLATFORM_FRAMES; i++) - { - sprintf(sprite_name, "flying_platform-%i", i+1); - img_flying_platform[i] = sprite_manager->load(sprite_name); - } + img_flying_platform = sprite_manager->load("flying_platform"); } |
From: Matze B. <mat...@us...> - 2004-05-24 16:14:52
|
Update of /cvsroot/super-tux/supertux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18424 Modified Files: configure.ac Log Message: add -Werror flag to debug mode Index: configure.ac =================================================================== RCS file: /cvsroot/super-tux/supertux/configure.ac,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- configure.ac 11 May 2004 01:18:38 -0000 1.24 +++ configure.ac 24 May 2004 16:14:42 -0000 1.25 @@ -48,7 +48,7 @@ AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [enable debugging mode]),, enable_debug="yes") if test "x${enable_debug}" != "xno"; then - CXXFLAGS="$CXXFLAGS -Wall -W -DDEBUG -O0 -g3" + CXXFLAGS="$CXXFLAGS -Wall -Werror -DDEBUG -O0 -g3" AC_MSG_RESULT([enabled]) else AC_MSG_RESULT([disabled]) |
From: Ricardo C. <rm...@us...> - 2004-05-24 12:02:35
|
Update of /cvsroot/super-tux/supertux/data/levels/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28667/data/levels/test Modified Files: level10.stl Log Message: Added flying platform into the buttjump and trampoline test level. Index: level10.stl =================================================================== RCS file: /cvsroot/super-tux/supertux/data/levels/test/level10.stl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- level10.stl 21 May 2004 02:28:27 -0000 1.4 +++ level10.stl 24 May 2004 12:02:25 -0000 1.5 @@ -35,5 +35,10 @@ (y 1500) (power 10) ) + (flying-platform + (x 1300 1600 1600 1800 2000) + (y 250 250 300 250 120) + (velocity 2.0) + ) ) ) |
From: Ricardo C. <rm...@us...> - 2004-05-24 12:01:50
|
Update of /cvsroot/super-tux/supertux/data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28490/data Modified Files: supertux.strf Log Message: Added entry for flying platform. Index: supertux.strf =================================================================== RCS file: /cvsroot/super-tux/supertux/data/supertux.strf,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- supertux.strf 16 May 2004 18:05:10 -0000 1.33 +++ supertux.strf 24 May 2004 12:01:35 -0000 1.34 @@ -632,6 +632,12 @@ (x-hotspot 0) (images "shared/trampoline-4.png")) + ; Flying platforms + (sprite (name "flying_platform-1") + (x-hotspot 0) + (x-hotspot 0) + (images "shared/flying_platform-1.png")) + ) ;; EOF ;; |
From: Ricardo C. <rm...@us...> - 2004-05-24 12:01:18
|
Update of /cvsroot/super-tux/supertux/data/images/shared In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28397/data/images/shared Added Files: flying_platform-1.png Log Message: Added Benjamin's flying platform image. I could not add more than one frame cause the format is animated GIF... --- NEW FILE: flying_platform-1.png --- (This appears to be a binary file; contents omitted.) |
From: Ricardo C. <rm...@us...> - 2004-05-24 12:00:13
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27915/src Modified Files: collision.h gameobjs.cpp gameobjs.h player.cpp world.cpp world.h Log Message: New flying platform object. Though seems to have some probs checking if reached next point, resulting in a bad movement. I'll have a look at this later. Index: world.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.h,v retrieving revision 1.47 retrieving revision 1.48 diff -u -d -r1.47 -r1.48 --- world.h 22 May 2004 15:27:45 -0000 1.47 +++ world.h 24 May 2004 11:59:59 -0000 1.48 @@ -44,6 +44,8 @@ BadGuys bad_guys_to_add; typedef std::list<Trampoline*> Trampolines; Trampolines trampolines; + typedef std::list<FlyingPlatform*> FlyingPlatforms; + FlyingPlatforms flying_platforms; Level* level; Player* tux; Index: collision.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/collision.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- collision.h 17 May 2004 06:26:41 -0000 1.13 +++ collision.h 24 May 2004 11:59:59 -0000 1.14 @@ -32,7 +32,8 @@ CO_BULLET, CO_BADGUY, CO_PLAYER, - CO_TRAMPOLINE + CO_TRAMPOLINE, + CO_FLYING_PLATFORM }; enum CollisionType { Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.118 retrieving revision 1.119 diff -u -d -r1.118 -r1.119 --- player.cpp 23 May 2004 00:11:58 -0000 1.118 +++ player.cpp 24 May 2004 11:59:59 -0000 1.119 @@ -709,6 +709,7 @@ { BadGuy* pbad_c = NULL; Trampoline* ptramp_c = NULL; + FlyingPlatform* pplatform_c = NULL; switch (c_object) { @@ -799,7 +800,11 @@ } } */ - + break; + case CO_FLYING_PLATFORM: + pplatform_c = (FlyingPlatform*) p_c_object; + + base.y = pplatform_c->base.y - base.height; break; default: Index: gameobjs.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.cpp,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- gameobjs.cpp 20 May 2004 23:07:24 -0000 1.32 +++ gameobjs.cpp 24 May 2004 11:59:59 -0000 1.33 @@ -145,17 +145,6 @@ #define TRAMPOLINE_FRAMES 4 Sprite *img_trampoline[TRAMPOLINE_FRAMES]; -void load_object_gfx() -{ - char sprite_name[16]; - - for (int i = 0; i < TRAMPOLINE_FRAMES; i++) - { - sprintf(sprite_name, "trampoline-%i", i+1); - img_trampoline[i] = sprite_manager->load(sprite_name); - } -} - Trampoline::Trampoline(DisplayManager& displaymanager, LispReader& reader) { displaymanager.add_drawable(this, LAYER_OBJECTS); @@ -289,4 +278,137 @@ } } +/* Flying Platform */ + +#define FLYING_PLATFORM_FRAMES 1 +Sprite *img_flying_platform[FLYING_PLATFORM_FRAMES]; + +FlyingPlatform::FlyingPlatform(DisplayManager& displaymanager, LispReader& reader) +{ + displaymanager.add_drawable(this, LAYER_OBJECTS); + + reader.read_int_vector("x", &pos_x); + reader.read_int_vector("y", &pos_y); + + velocity = 2.0; + reader.read_float("velocity", &velocity); + + base.x = pos_x[0]; + base.y = pos_y[0]; + base.width = 96; + base.height = 40; + + point = 0; + move = false; + + frame = 0; +} + +void +FlyingPlatform::write(LispWriter& writer) +{ + writer.start_list("flying-trampoline"); + + writer.write_int_vector("x", pos_x); + writer.write_int_vector("y", pos_y); + writer.write_float("velocity", velocity); + + writer.end_list("flying-trampoline"); +} + +void +FlyingPlatform::draw(ViewPort& viewport, int ) +{ +img_flying_platform[frame]->draw(viewport.world2screen(Vector(base.x, base.y))); +} + +void +FlyingPlatform::action(float frame_ratio) +{ + // TODO: Remove if we're too far off the screen + + // FIXME: change frame +if(!move) + return; + +if((unsigned)point+1 != pos_x.size()) + if(((pos_x[point+1] > pos_x[point] && base.x >= pos_x[point+1]) || + (pos_x[point+1] < pos_x[point] && base.x <= pos_x[point+1]) || + pos_x[point+1] == pos_x[point+1]) && + ((pos_y[point+1] > pos_y[point] && base.y >= pos_y[point+1]) || + (pos_y[point+1] < pos_y[point] && base.y <= pos_y[point+1]) || + pos_y[point+1] == pos_y[point+1])) + { + point++; +std::cerr << "next point: " << point << std::endl; + } +else // last point + { + // point = 0; + // reverse vector + return; + } + +if(pos_x[point] > base.x) + base.x += velocity * frame_ratio; +else if(pos_x[point] < base.x) + base.x -= velocity * frame_ratio; + +if(pos_y[point] > base.y) + base.y += velocity * frame_ratio; +else if(pos_y[point] < base.y) + base.y -= velocity * frame_ratio; +/* +float x = pos_x[point+1] - pos_x[point]; +float y = pos_y[point+1] - pos_y[point]; +float vel_x = x*velocity / sqrt(x*x + y*y); +float vel_y = velocity - vel_x; + +base.x += vel_x * frame_ratio; +base.y += vel_y * frame_ratio; +*/ +} + +void +FlyingPlatform::collision(const MovingObject&, int) +{ + // comes later +} + +void +FlyingPlatform::collision(void *p_c_object, int c_object, CollisionType type) +{ +(void) p_c_object; +(void) type; + +// Player* pplayer_c = NULL; + switch (c_object) + { + case CO_PLAYER: +// pplayer_c = (Player*) p_c_object; + move = true; + + break; + + default: + break; + + } +} + +void load_object_gfx() +{ + char sprite_name[16]; + + for (int i = 0; i < TRAMPOLINE_FRAMES; i++) + { + sprintf(sprite_name, "trampoline-%i", i+1); + img_trampoline[i] = sprite_manager->load(sprite_name); + } + for (int i = 0; i < FLYING_PLATFORM_FRAMES; i++) + { + sprintf(sprite_name, "flying_platform-%i", i+1); + img_flying_platform[i] = sprite_manager->load(sprite_name); + } +} Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.109 retrieving revision 1.110 diff -u -d -r1.109 -r1.110 --- world.cpp 22 May 2004 15:27:45 -0000 1.109 +++ world.cpp 24 May 2004 11:59:59 -0000 1.110 @@ -165,6 +165,9 @@ Trampoline* trampoline = dynamic_cast<Trampoline*> (object); if(trampoline) trampolines.push_back(trampoline); + FlyingPlatform* flying_platform = dynamic_cast<FlyingPlatform*> (object); + if(flying_platform) + flying_platforms.push_back(flying_platform); gameobjects.push_back(object); } @@ -180,7 +183,11 @@ if(object_type == "trampoline") { add_object(new Trampoline(displaymanager, reader)); - } else { + } + else if(object_type == "flying-platform") { + add_object(new FlyingPlatform(displaymanager, reader)); + } + else { BadGuyKind kind = badguykind_from_string(object_type); add_object(new BadGuy(displaymanager, kind, reader)); } @@ -259,6 +266,12 @@ std::remove(trampolines.begin(), trampolines.end(), trampoline), trampolines.end()); } + FlyingPlatform* flying_platform= dynamic_cast<FlyingPlatform*> (*i); + if(flying_platform) { + flying_platforms.erase( + std::remove(flying_platforms.begin(), flying_platforms.end(), flying_platform), + flying_platforms.end()); + } delete *i; i = gameobjects.erase(i); @@ -485,6 +498,24 @@ } } } + + // CO_FLYING_PLATFORM & (CO_PLAYER or CO_BADGUY) + for (FlyingPlatforms::iterator i = flying_platforms.begin(); i != flying_platforms.end(); ++i) + { + if (rectcollision((*i)->base, tux->base)) + { + if (tux->previous_base.y < tux->base.y && + tux->previous_base.y + tux->previous_base.height + < (*i)->base.y + (*i)->base.height/2) + { + (*i)->collision(tux, CO_PLAYER, COLLISION_SQUISH); + tux->collision(*i, CO_FLYING_PLATFORM); + } +/* else if (tux->previous_base.y <= tux->base.y) + { + }*/ + } + } } void Index: gameobjs.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.h,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- gameobjs.h 20 May 2004 23:07:24 -0000 1.21 +++ gameobjs.h 24 May 2004 11:59:59 -0000 1.22 @@ -132,6 +132,33 @@ unsigned int frame; }; +class FlyingPlatform : public MovingObject, public Drawable, public Serializable +{ +public: + FlyingPlatform(DisplayManager& displaymanager, LispReader& reader); + + virtual void write(LispWriter& writer); + virtual void action(float frame_ratio); + virtual void draw(ViewPort& viewport, int layer); + virtual std::string type() const + { return "Trampoline"; }; + + virtual void collision(const MovingObject& other, int); + void collision(void *p_c_object, int c_object, CollisionType type); + + Physic physic; + enum { M_NORMAL, M_HELD } mode; + + private: + std::vector<int> pos_x; + std::vector<int> pos_y; + float velocity; + + int point; + bool move; + unsigned int frame; +}; + void load_object_gfx(); #endif |
From: Matze B. <mat...@us...> - 2004-05-23 22:46:47
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5659 Modified Files: level.cpp Log Message: fix a bug when resizing maps and when saving maps which I recently introduced Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.83 retrieving revision 1.84 diff -u -d -r1.83 -r1.84 --- level.cpp 23 May 2004 20:20:20 -0000 1.83 +++ level.cpp 23 May 2004 22:46:34 -0000 1.84 @@ -498,6 +498,7 @@ writer.start_list("point"); writer.write_int("x", i->x); writer.write_int("y", i->y); + writer.end_list("point"); } writer.end_list("reset-points"); @@ -566,27 +567,39 @@ void Level::resize(int new_width, int new_height) { - // first: resize height - ia_tiles.resize(new_height * width, 0); - bg_tiles.resize(new_height * width, 0); - fg_tiles.resize(new_height * width, 0); - height = new_height; + if(new_width < width) { + // remap tiles for new width + for(int y = 0; y < height && y < new_height; ++y) { + for(int x = 0; x < new_width; ++x) { + ia_tiles[y * new_width + x] = ia_tiles[y * width + x]; + bg_tiles[y * new_width + x] = bg_tiles[y * width + x]; + fg_tiles[y * new_width + x] = fg_tiles[y * width + x]; + } + } + } - // remap horizontal tiles for new width - int np = 0; - for(int y = 0; y < height; ++y) { - for(int x = 0; x < new_width && x < width; ++x) { - ia_tiles[np] = ia_tiles[y * width + x]; - bg_tiles[np] = bg_tiles[y * width + x]; - fg_tiles[np] = fg_tiles[y * width + x]; - np++; + ia_tiles.resize(new_width * new_height); + bg_tiles.resize(new_width * new_height); + fg_tiles.resize(new_width * new_height); + + if(new_width > width) { + // remap tiles + for(int y = std::min(height, new_height)-1; y >= 0; --y) { + for(int x = new_width-1; x >= 0; --x) { + if(x >= width) { + ia_tiles[y * new_width + x] = 0; + bg_tiles[y * new_width + x] = 0; + fg_tiles[y * new_width + x] = 0; + } else { + ia_tiles[y * new_width + x] = ia_tiles[y * width + x]; + bg_tiles[y * new_width + x] = bg_tiles[y * width + x]; + fg_tiles[y * new_width + x] = fg_tiles[y * width + x]; + } + } } } - ia_tiles.resize(new_height * new_width); - bg_tiles.resize(new_height * new_width); - fg_tiles.resize(new_height * new_width); - + height = new_height; width = new_width; } |