From 00fb759c2385ff08caf38e916c2d0ba8cafc8a41 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Tue, 23 Nov 2004 02:00:52 +0000 Subject: [PATCH] fix some more timings and the long standing gradient software bug (which was function argument overriding class field) SVN-Revision: 2140 --- TODO | 4 +- contrib/tilemanager/Application.cs | 8 +-- contrib/tilemanager/Parser.cs | 3 + contrib/tilemanager/Tile.cs | 15 ++-- contrib/tilemanager/tiler.glade | 4 +- data/images/supertux.strf | 9 ++- data/images/tilesets/supertux.stgt | 68 ++++++++++++++++-- data/levels/test/animtiles.stl | 106 ++++++++++++++++++++++++++++ data/levels/test/bonusblock.stl | 141 +++++++++++++++++++++++++++++++++++++ lib/video/drawing_context.cpp | 35 +++++---- lib/video/drawing_context.h | 35 ++++----- lib/video/surface.cpp | 69 +++++++++--------- src/Makefile.am | 1 + src/gameloop.cpp | 8 +-- src/gameloop.h | 1 - src/leveleditor.cpp | 6 -- src/leveleditor.h | 1 - src/particlesystem.cpp | 2 +- src/player.cpp | 4 +- src/scene.h | 2 - src/tile.cpp | 6 +- src/tile.h | 2 +- src/title.cpp | 1 - src/worldmap.cpp | 14 +--- src/worldmap.h | 4 +- 25 files changed, 422 insertions(+), 127 deletions(-) create mode 100644 data/levels/test/animtiles.stl create mode 100644 data/levels/test/bonusblock.stl diff --git a/TODO b/TODO index 96de6bdca..0c1ba3745 100644 --- a/TODO +++ b/TODO @@ -90,6 +90,7 @@ L: low priority * what to do when stuck under tiles (after using duck-sliding) * do we want multi hit scores again? * tux doesn't stop at igloo anymore + * background particle systems are too slow --Code Refactoring/Cleanup/Optimisation-- [H] make the title using GameSession instead of reimplementing all the stuff @@ -149,9 +150,6 @@ L: low priority - New forest tileset - Badguy sprites - Tux's buttjump animation -[H] Background code have the following bugs: - - Gradient in software rendering doesn't currently work (at least here). - Matze: can you give more details? The code looks perfectly fine to me [M] Save score on per-level basis to make high-score [M] Save time on per-level basis to make low-time-score diff --git a/contrib/tilemanager/Application.cs b/contrib/tilemanager/Application.cs index fb2059313..ec842e236 100644 --- a/contrib/tilemanager/Application.cs +++ b/contrib/tilemanager/Application.cs @@ -26,7 +26,7 @@ public class Application { [Glade.Widget] private Gtk.Entry DataEntry; [Glade.Widget] - private Gtk.Entry AnimSpeedEntry; + private Gtk.Entry AnimFpsEntry; [Glade.Widget] private Gtk.Entry IDEntry; [Glade.Widget] @@ -342,8 +342,8 @@ public class Application { tile.ID = Int32.Parse(IDEntry.Text); if(sender == DataEntry) tile.Data = Int32.Parse(DataEntry.Text); - if(sender == AnimSpeedEntry) - tile.AnimSpeed = Int32.Parse(AnimSpeedEntry.Text); + if(sender == AnimFpsEntry) + tile.AnimFps = Single.Parse(AnimFpsEntry.Text); } catch(Exception exception) { // ignore parse errors for now... } @@ -380,7 +380,7 @@ public class Application { SlopeCheckButton.Active = tile.Slope; DontUseCheckButton.Active = tile.ID == -1; DataEntry.Text = tile.Data.ToString(); - AnimSpeedEntry.Text = tile.AnimSpeed.ToString(); + AnimFpsEntry.Text = tile.AnimFps.ToString(); IDEntry.Text = tile.ID.ToString(); IDEntry.Editable = true; first = false; diff --git a/contrib/tilemanager/Parser.cs b/contrib/tilemanager/Parser.cs index 784893f5d..daa0ade11 100644 --- a/contrib/tilemanager/Parser.cs +++ b/contrib/tilemanager/Parser.cs @@ -85,6 +85,9 @@ public class Parser { public bool BoolValue { get { return StringValue == "t" ? true : false; } } + public float FloatValue { + get { return Single.Parse(lexer.TokenString); } + } } } diff --git a/contrib/tilemanager/Tile.cs b/contrib/tilemanager/Tile.cs index 4af0daf14..c9387d7f3 100644 --- a/contrib/tilemanager/Tile.cs +++ b/contrib/tilemanager/Tile.cs @@ -23,14 +23,14 @@ public class Tile { public bool Goal; public int NextTile; public int Data; - public int AnimSpeed; + public float AnimFps; public string EditorImage; public ArrayList Images = new ArrayList(); public Tile() { ID = -1; NextTile = -1; - AnimSpeed = 25; + AnimFps = 1; } public void Write(LispWriter writer) { @@ -82,8 +82,11 @@ public class Tile { writer.Write("editor-images", EditorImage); if(Data != 0) writer.Write("data", Data); - if(AnimSpeed != 25) - writer.Write("anim-speed", AnimSpeed); + if(Images.Count > 1) { + if(AnimFps == 1.0) + AnimFps = 40; + writer.Write("anim-fps", AnimFps); + } writer.EndList("tile"); } @@ -121,8 +124,8 @@ public class Tile { Slope = true; Data = parser.IntegerValue; break; - case "anim-speed": - AnimSpeed = parser.IntegerValue; + case "anim-fps": + AnimFps = parser.FloatValue; break; case "spike": Spike = parser.BoolValue; diff --git a/contrib/tilemanager/tiler.glade b/contrib/tilemanager/tiler.glade index a84081897..07302c8d8 100644 --- a/contrib/tilemanager/tiler.glade +++ b/contrib/tilemanager/tiler.glade @@ -471,7 +471,7 @@ True - AnimSpeed: + AnimFPS: False False GTK_JUSTIFY_LEFT @@ -493,7 +493,7 @@ - + True True True diff --git a/data/images/supertux.strf b/data/images/supertux.strf index ec2b028dd..e6a892b40 100644 --- a/data/images/supertux.strf +++ b/data/images/supertux.strf @@ -1206,12 +1206,19 @@ (sprite (name "bonusblock") (action + (fps 15) (name "default") (images "tilesets/bonus2-1.png" "tilesets/bonus2-2.png" "tilesets/bonus2-3.png" "tilesets/bonus2-4.png" - "tilesets/bonus2-5.png")) + "tilesets/bonus2-5.png" + "tilesets/bonus2-3.png" + "tilesets/bonus2-2.png" + "tilesets/bonus2-1.png" + "tilesets/bonus2-1.png" + "tilesets/bonus2-1.png" + )) (action (name "empty") (images "tilesets/bonus2-d.png")) diff --git a/data/images/tilesets/supertux.stgt b/data/images/tilesets/supertux.stgt index 2ef45f889..bcdd02c96 100644 --- a/data/images/tilesets/supertux.stgt +++ b/data/images/tilesets/supertux.stgt @@ -232,7 +232,7 @@ (fullbox #t) (next-tile 84) (data 1) - (anim-speed 50) + (anim-fps 2) ) (tile (id 27) @@ -363,6 +363,7 @@ "coin-8.png" ) (distro #t) + (anim-fps 10) ) (tile (id 47) @@ -575,6 +576,7 @@ "waves-2.png" ) (water #t) + (anim-fps 10) ) (tile (id 77) @@ -610,6 +612,7 @@ "flag-0.png" "flag-1.png" ) + (anim-fps 10) ) (tile (id 82) @@ -620,6 +623,7 @@ "coin2.png" ) (distro #t) + (anim-fps 10) ) (tile (id 83) @@ -640,7 +644,7 @@ (fullbox #t) (next-tile 84) (data 1) - (anim-speed 50) + (anim-fps 2) ) (tile (id 84) @@ -771,7 +775,7 @@ (next-tile 84) (editor-images "bonus-fireflower.png") (data 2) - (anim-speed 50) + (anim-fps 2) ) (tile (id 103) @@ -793,7 +797,7 @@ (next-tile 84) (editor-images "bonus-herring.png") (data 3) - (anim-speed 50) + (anim-fps 2) ) (tile (id 104) @@ -979,7 +983,7 @@ (next-tile 84) (editor-images "bonus-1up.png") (data 4) - (anim-speed 50) + (anim-fps 2) ) (tile (id 129) @@ -997,6 +1001,7 @@ "goal1-1.png" "goal1-1.png" ) + (anim-fps 10) ) (tile (id 130) @@ -1014,6 +1019,7 @@ "goal2-1.png" "goal2-1.png" ) + (anim-fps 10) ) (tile (id 131) @@ -1088,7 +1094,7 @@ (next-tile 84) (editor-images "bonus-iceflower.png") (data 5) - (anim-speed 50) + (anim-fps 2) ) (tile (id 141) @@ -1151,6 +1157,7 @@ "lava1-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 174) @@ -1161,6 +1168,7 @@ "lava2-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 175) @@ -1171,6 +1179,7 @@ "waterfall-trans1-1-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 176) @@ -1181,6 +1190,7 @@ "waterfall-trans1-2-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 177) @@ -1191,6 +1201,7 @@ "waterfall-trans1-3-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 178) @@ -1201,6 +1212,7 @@ "waterfall-trans1-4-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 179) @@ -1211,6 +1223,7 @@ "waterfall-trans2-1-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 180) @@ -1221,6 +1234,7 @@ "waterfall-trans2-2-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 181) @@ -1231,6 +1245,7 @@ "waterfall-trans2-3-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 182) @@ -1241,6 +1256,7 @@ "waterfall-trans2-4-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 183) @@ -1251,6 +1267,7 @@ "waterfall-trans3-1-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 184) @@ -1261,6 +1278,7 @@ "waterfall-trans3-2-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 185) @@ -1271,6 +1289,7 @@ "waterfall-trans3-3-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 186) @@ -1281,6 +1300,7 @@ "waterfall-trans3-4-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 187) @@ -1291,6 +1311,7 @@ "waterfall-trans4-1-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 188) @@ -1301,6 +1322,7 @@ "waterfall-trans4-2-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 189) @@ -1311,6 +1333,7 @@ "waterfall-trans4-3-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 190) @@ -1321,6 +1344,7 @@ "waterfall-trans4-4-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 191) @@ -1331,6 +1355,7 @@ "waterfall-trans5-1-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 192) @@ -1341,6 +1366,7 @@ "waterfall-trans5-2-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 193) @@ -1351,6 +1377,7 @@ "waterfall-trans5-3-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 194) @@ -1361,6 +1388,7 @@ "waterfall-trans5-4-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 195) @@ -1371,6 +1399,7 @@ "waterfall1-0-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 196) @@ -1381,6 +1410,7 @@ "waterfall1-5-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 197) @@ -1391,6 +1421,7 @@ "waterfall0-0-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 198) @@ -1401,6 +1432,7 @@ "waterfall0-1-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 199) @@ -1411,6 +1443,7 @@ "waterfall0-2-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 200) @@ -1427,6 +1460,7 @@ "waves-trans-2.png" ) (water #t) + (anim-fps 10) ) (tile (id 202) @@ -1520,6 +1554,7 @@ "waterfall1-1-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 276) @@ -1530,6 +1565,7 @@ "waterfall1-2-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 277) @@ -1540,6 +1576,7 @@ "waterfall1-3-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 278) @@ -1550,6 +1587,7 @@ "waterfall1-4-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 279) @@ -1560,6 +1598,7 @@ "waterfall2-1-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 280) @@ -1570,6 +1609,7 @@ "waterfall2-2-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 281) @@ -1580,6 +1620,7 @@ "waterfall2-3-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 282) @@ -1590,6 +1631,7 @@ "waterfall2-4-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 283) @@ -1600,6 +1642,7 @@ "waterfall3-1-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 284) @@ -1610,6 +1653,7 @@ "waterfall3-2-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 285) @@ -1620,6 +1664,7 @@ "waterfall3-3-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 286) @@ -1630,6 +1675,7 @@ "waterfall3-4-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 287) @@ -1640,6 +1686,7 @@ "waterfall4-1-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 288) @@ -1650,6 +1697,7 @@ "waterfall4-2-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 289) @@ -1660,6 +1708,7 @@ "waterfall4-3-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 290) @@ -1670,6 +1719,7 @@ "waterfall4-4-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 291) @@ -1680,6 +1730,7 @@ "waterfall5-1-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 292) @@ -1690,6 +1741,7 @@ "waterfall5-2-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 293) @@ -1700,6 +1752,7 @@ "waterfall5-3-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 294) @@ -1710,6 +1763,7 @@ "waterfall5-4-4.png" ) (water #t) + (anim-fps 10) ) (tile (id 295) @@ -1830,6 +1884,7 @@ "jungle12-2.png" ) (solid #t) + (anim-fps 10) ) (tile (id 313) @@ -2380,6 +2435,7 @@ ) (solid #t) (slope-type 2) + (data 2) ) (tile (id 1048) diff --git a/data/levels/test/animtiles.stl b/data/levels/test/animtiles.stl new file mode 100644 index 000000000..6614310fc --- /dev/null +++ b/data/levels/test/animtiles.stl @@ -0,0 +1,106 @@ +;; Generated by Flexlay Editor +(supertux-level + (version 2) + (name "No Name") + (author "No Author") + (time 999) + (sector + (name "main") + (width 30) + (height 20) + (gravity 10.000000) + (background (image "arctis.jpg") + (speed 0.5)) + (tilemap + (layer "background") + (solid #f) + (speed 1.000000) + (width 30) + (height 20) + (tiles + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 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0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 191 192 193 194 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 187 188 189 190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 183 184 185 186 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 179 180 181 182 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 175 176 177 178 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 61 61 61 61 61 61 61 61 61 61 61 61 61 275 276 277 278 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 174 174 174 174 174 174 174 174 174 174 174 174 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 173 173 173 173 173 173 173 173 173 173 173 173 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + )) + (camera + (mode "normal") + (path + )) + + ) + ) + +;; EOF ;; diff --git a/data/levels/test/bonusblock.stl b/data/levels/test/bonusblock.stl new file mode 100644 index 000000000..e23686a80 --- /dev/null +++ b/data/levels/test/bonusblock.stl @@ -0,0 +1,141 @@ +;; Generated by Flexlay Editor +(supertux-level + (version 2) + (name "No Name") + (author "No Author") + (time 999) + (sector + (name "main") + (width 30) + (height 30) + (gravity 10.000000) + (background (image "arctis.jpg") + (speed 0.5)) + (spawn-points + (name "main") + (x 100) + (y 170) + ) + (tilemap + (layer "background") + (solid #f) + (speed 1.000000) + (width 30) + (height 30) + (tiles + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 + 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 + 61 0 0 0 0 0 0 26 0 83 0 0 0 102 0 102 0 0 0 128 0 0 0 103 0 0 0 0 0 61 + 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 + 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 + 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 + 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 + )) + (tilemap + (layer "foreground") + (solid #f) + (speed 1.000000) + (width 30) + (height 30) + (tiles + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + )) + (camera + (mode "normal") + (path + )) + + ) + ) + +;; EOF ;; diff --git a/lib/video/drawing_context.cpp b/lib/video/drawing_context.cpp index f84949157..5c98f134d 100644 --- a/lib/video/drawing_context.cpp +++ b/lib/video/drawing_context.cpp @@ -31,9 +31,6 @@ using namespace SuperTux; DrawingContext::DrawingContext() { - transform.draw_effect = NONE_EFFECT; - transform.zoom = 1; - transform.alpha = 255; } DrawingContext::~DrawingContext() @@ -49,18 +46,17 @@ DrawingContext::draw_surface(const Surface* surface, const Vector& position, DrawingRequest request; request.type = SURFACE; - request.layer = layer; - request.request_data = const_cast (surface); request.pos = transform.apply(position); if(request.pos.x >= screen->w || request.pos.y >= screen->h || request.pos.x + surface->w < 0 || request.pos.y + surface->h < 0) return; - - request.drawing_effect = drawing_effect; - request.drawing_effect = transform.draw_effect | drawing_effect; + + request.layer = layer; + request.drawing_effect = transform.drawing_effect | drawing_effect; request.zoom = transform.zoom; request.alpha = transform.alpha; + request.request_data = const_cast (surface); drawingrequests.push_back(request); } @@ -74,9 +70,9 @@ DrawingContext::draw_surface_part(const Surface* surface, const Vector& source, DrawingRequest request; request.type = SURFACE_PART; - request.layer = layer; request.pos = transform.apply(dest); - request.drawing_effect = drawing_effect; + request.layer = layer; + request.drawing_effect = transform.drawing_effect | drawing_effect; request.alpha = transform.alpha; SurfacePartRequest* surfacepartrequest = new SurfacePartRequest(); @@ -96,9 +92,10 @@ DrawingContext::draw_text(Font* font, const std::string& text, DrawingRequest request; request.type = TEXT; - request.layer = layer; request.pos = transform.apply(position); - request.drawing_effect = drawing_effect; + request.layer = layer; + request.drawing_effect = transform.drawing_effect | drawing_effect; + request.zoom = transform.zoom; request.alpha = transform.alpha; TextRequest* textrequest = new TextRequest; @@ -124,8 +121,12 @@ DrawingContext::draw_gradient(Color top, Color bottom, int layer) DrawingRequest request; request.type = GRADIENT; - request.layer = layer; request.pos = Vector(0,0); + request.layer = layer; + + request.drawing_effect = transform.drawing_effect; + request.zoom = transform.zoom; + request.alpha = transform.alpha; GradientRequest* gradientrequest = new GradientRequest; gradientrequest->top = top; @@ -142,8 +143,12 @@ DrawingContext::draw_filled_rect(const Vector& topleft, const Vector& size, DrawingRequest request; request.type = FILLRECT; - request.layer = layer; request.pos = transform.apply(topleft); + request.layer = layer; + + request.drawing_effect = transform.drawing_effect; + request.zoom = transform.zoom; + request.alpha = transform.alpha; FillRectRequest* fillrectrequest = new FillRectRequest; fillrectrequest->size = size; @@ -360,7 +365,7 @@ DrawingContext::pop_transform() void DrawingContext::set_drawing_effect(int effect) { - transform.draw_effect = effect; + transform.drawing_effect = effect; } void diff --git a/lib/video/drawing_context.h b/lib/video/drawing_context.h index 6c7e7749d..03dce32e6 100644 --- a/lib/video/drawing_context.h +++ b/lib/video/drawing_context.h @@ -86,9 +86,9 @@ namespace SuperTux void do_drawing(); const Vector& get_translation() const - { return transform.translation; } + { return transform.translation; } Uint32 get_drawing_effect() const - { return transform.draw_effect; } + { return transform.drawing_effect; } void set_translation(const Vector& newtranslation) { transform.translation = newtranslation; } @@ -105,19 +105,22 @@ namespace SuperTux private: class Transform - { - public: - Vector translation; // only translation for now... + { + public: + Vector translation; + Uint32 drawing_effect; + float zoom; + int alpha; - Vector apply(const Vector& v) const - { - return v - translation; - } + Transform() + : drawing_effect(NONE_EFFECT), zoom(1), alpha(255) + { } - Uint32 draw_effect; - float zoom; - int alpha; - }; + Vector apply(const Vector& v) const + { + return v - translation; + } + }; /// the transform stack std::vector transformstack; @@ -156,14 +159,14 @@ namespace SuperTux struct DrawingRequest { + RequestType type; + Vector pos; + int layer; Uint32 drawing_effect; float zoom; int alpha; - RequestType type; - Vector pos; - void* request_data; bool operator<(const DrawingRequest& other) const diff --git a/lib/video/surface.cpp b/lib/video/surface.cpp index d9ab08253..8385766a5 100644 --- a/lib/video/surface.cpp +++ b/lib/video/surface.cpp @@ -58,12 +58,14 @@ SurfaceData::SurfaceData(const std::string& file_, bool use_alpha_) : type(LOAD), surface(0), file(file_), use_alpha(use_alpha_) {} -SurfaceData::SurfaceData(const std::string& file_, int x_, int y_, int w_, int h_, bool use_alpha_) +SurfaceData::SurfaceData(const std::string& file_, int x_, int y_, + int w_, int h_, bool use_alpha_) : type(LOAD_PART), surface(0), file(file_), use_alpha(use_alpha_), x(x_), y(y_), w(w_), h(h_) {} -SurfaceData::SurfaceData(Color top_gradient_, Color bottom_gradient_, int w_, int h_) +SurfaceData::SurfaceData(Color top_gradient_, Color bottom_gradient_, + int w_, int h_) : type(GRADIENT), surface(0), use_alpha(false), w(w_), h(h_) { top_gradient = top_gradient_; @@ -205,12 +207,12 @@ Surface::reload() void Surface::apply_filter(int filter, Color color) { -impl->apply_filter(filter, color); + impl->apply_filter(filter, color); -SurfaceData::Filter apply_filter; -apply_filter.type = filter; -apply_filter.color = color; -data.applied_filters.push_back(apply_filter); + SurfaceData::Filter apply_filter; + apply_filter.type = filter; + apply_filter.color = color; + data.applied_filters.push_back(apply_filter); } Surface::~Surface() @@ -431,22 +433,18 @@ SuperTux::sdl_surface_from_sdl_surface(SDL_Surface* sdl_surf, bool use_alpha) SDL_Surface* sdl_surface_from_gradient(Color top, Color bottom, int w, int h) { - SDL_Surface* sdl_surface; - - sdl_surface = SDL_CreateRGBSurface(screen->flags, w, h, + SDL_Surface* sdl_surface + = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, 0); - if(sdl_surface == NULL) + if(sdl_surface == 0) Termination::abort("Cannot create surface for the gradient", "SURFACE"); - if(top == bottom) - { + if(top == bottom) { SDL_FillRect(sdl_surface, NULL, SDL_MapRGB(sdl_surface->format, top.red, top.green, top.blue)); - } - else - { + } else { float redstep = (float(bottom.red)-float(top.red)) / float(h); float greenstep = (float(bottom.green)-float(top.green)) / float(h); float bluestep = (float(bottom.blue) - float(top.blue)) / float(h); @@ -455,15 +453,14 @@ sdl_surface_from_gradient(Color top, Color bottom, int w, int h) rect.x = 0; rect.w = w; rect.h = 1; - for(float y = 0; y < h; y++) - { + for(float y = 0; y < h; y++) { rect.y = (int)y; SDL_FillRect(sdl_surface, &rect, SDL_MapRGB(sdl_surface->format, - int(float(top.red) + redstep * y), - int(float(top.green) + greenstep * y), - int(float(top.blue) + bluestep * y))); - } + int(float(top.red) + redstep * y), + int(float(top.green) + greenstep * y), + int(float(top.blue) + bluestep * y))); } + } return sdl_surface; } @@ -516,23 +513,23 @@ SurfaceOpenGL::SurfaceOpenGL(const std::string& file, bool use_alpha) h = sdl_surface->h; } -SurfaceOpenGL::SurfaceOpenGL(const std::string& file_, int x_, int y_, int w_, int h_, bool use_alpha_) +SurfaceOpenGL::SurfaceOpenGL(const std::string& file_, int x_, int y_, + int w_, int h_, bool use_alpha_) { sdl_surface = sdl_surface_part_from_file(file_,x_,y_,w_,h_,use_alpha_); create_gl(sdl_surface, &gl_texture); - w = sdl_surface->w; - h = sdl_surface->h; + h = sdl_surface->h; } -SurfaceOpenGL::SurfaceOpenGL(Color top_gradient, Color bottom_gradient, int w, int h) +SurfaceOpenGL::SurfaceOpenGL(Color top_gradient, Color bottom_gradient, + int _w, int _h) { - sdl_surface = sdl_surface_from_gradient(top_gradient, bottom_gradient, w, h); + sdl_surface = sdl_surface_from_gradient(top_gradient, bottom_gradient,_w,_h); create_gl(sdl_surface, &gl_texture); - w = sdl_surface->w; - h = sdl_surface->h; + h = sdl_surface->h; } SurfaceOpenGL::~SurfaceOpenGL() @@ -892,18 +889,20 @@ SurfaceSDL::SurfaceSDL(const std::string& file, bool use_alpha) h = sdl_surface->h; } -SurfaceSDL::SurfaceSDL(const std::string& file, int x, int y, int w, int h, bool use_alpha) +SurfaceSDL::SurfaceSDL(const std::string& file, int x, int y, int _w, int _h, + bool use_alpha) { - sdl_surface = sdl_surface_part_from_file(file, x, y, w, h, use_alpha); + sdl_surface = sdl_surface_part_from_file(file, x, y, _w, _h, use_alpha); w = sdl_surface->w; - h = sdl_surface->h; + h = sdl_surface->h; } -SurfaceSDL::SurfaceSDL(Color top_gradient, Color bottom_gradient, int w, int h) +SurfaceSDL::SurfaceSDL(Color top_gradient, Color bottom_gradient, + int _w, int _h) { - sdl_surface = sdl_surface_from_gradient(top_gradient, bottom_gradient, w, h); + sdl_surface = sdl_surface_from_gradient(top_gradient, bottom_gradient,_w,_h); w = sdl_surface->w; - h = sdl_surface->h; + h = sdl_surface->h; } int diff --git a/src/Makefile.am b/src/Makefile.am index 35bd69769..10cfd76ff 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,6 +27,7 @@ supertux_SOURCES = camera.cpp \ object/oneup.h object/oneup.cpp \ object/flower.h object/flower.cpp \ object/growup.h object/growup.cpp \ + object/invisible_block.h object/invisible_block.cpp \ badguy/badguy.h badguy/badguy.cpp \ badguy/bomb.h badguy/bomb.cpp \ badguy/bouncing_snowball.h badguy/bouncing_snowball.cpp\ diff --git a/src/gameloop.cpp b/src/gameloop.cpp index c4b048565..004e3db2b 100644 --- a/src/gameloop.cpp +++ b/src/gameloop.cpp @@ -88,7 +88,6 @@ GameSession::GameSession(const std::string& levelname_, int mode, { current_ = this; - global_frame_counter = 0; game_pause = false; fps_fps = 0; @@ -718,7 +717,6 @@ GameSession::run() Uint32 lastticks = SDL_GetTicks(); fps_ticks = SDL_GetTicks(); - frame_timer.start(.025, true); while (exit_status == ES_NONE) { Uint32 ticks = SDL_GetTicks(); float elapsed_time = float(ticks - lastticks) / 1000.; @@ -728,10 +726,6 @@ GameSession::run() if(elapsed_time > .05) elapsed_time = .05; - if(frame_timer.check()) { - ++global_frame_counter; - } - /* Handle events: */ currentsector->player->input.old_fire = currentsector->player->input.fire; currentsector->player->input.old_up = currentsector->player->input.old_up; @@ -857,7 +851,7 @@ GameSession::drawstatus(DrawingContext& context) context.draw_text(white_text, _("TIME's UP"), Vector(screen->w/2, 0), CENTER_ALLIGN, LAYER_FOREGROUND1); } else if (time_left.get_timeleft() > TIME_WARNING - || (global_frame_counter % 10) < 5) { + || int(global_time * 2.5) % 2) { sprintf(str, " %d", int(time_left.get_timeleft())); context.draw_text(white_text, _("TIME"), Vector(screen->w/2, 0), CENTER_ALLIGN, LAYER_FOREGROUND1); diff --git a/src/gameloop.h b/src/gameloop.h index a5263d86f..1d01487e6 100644 --- a/src/gameloop.h +++ b/src/gameloop.h @@ -57,7 +57,6 @@ class GameSession { private: Uint32 fps_ticks; - Timer2 frame_timer; Timer2 endsequence_timer; Level* level; Sector* currentsector; diff --git a/src/leveleditor.cpp b/src/leveleditor.cpp index 81f0bfb59..0578d3703 100644 --- a/src/leveleditor.cpp +++ b/src/leveleditor.cpp @@ -44,7 +44,6 @@ LevelEditor::LevelEditor() show_grid = true; selection.clear(); - global_frame_counter = 0; selection_end = selection_ini = Vector(0,0); left_button = middle_button = mouse_moved = false; level = 0; @@ -232,7 +231,6 @@ else mouse_cursor->set_state(MC_NORMAL); -frame_timer.start(.25, true); done = false; while(!done) { @@ -534,10 +532,6 @@ if(tiles_board->is_hover() || tiles_layer->is_hover() || level_options->is_hover if(sector) { - if(frame_timer.check()) { - ++global_frame_counter; - } - // don't scroll before the start or after the level's end float width = sector->solids->get_width() * 32; float height = sector->solids->get_height() * 32; diff --git a/src/leveleditor.h b/src/leveleditor.h index 0527f7aa6..32099a202 100644 --- a/src/leveleditor.h +++ b/src/leveleditor.h @@ -129,7 +129,6 @@ private: float zoom; SDL_Event event; - Timer2 frame_timer; Timer2 level_name_timer; Surface *img_background_bt, *img_foreground_bt, *img_interactive_bt; diff --git a/src/particlesystem.cpp b/src/particlesystem.cpp index 5bda1bcc4..73a7331ea 100644 --- a/src/particlesystem.cpp +++ b/src/particlesystem.cpp @@ -140,7 +140,7 @@ CloudParticleSystem::CloudParticleSystem() particle->pos.x = rand() % int(virtual_width); particle->pos.y = rand() % int(virtual_height); particle->texture = cloudimage; - particle->speed = -float(250 + rand() % 200) / 1000.0; + particle->speed = -float(25 + rand() % 30); particles.push_back(particle); } diff --git a/src/player.cpp b/src/player.cpp index edbdce81b..2ecaaadc5 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -846,7 +846,7 @@ Player::draw(DrawingContext& context) get_pos(), layer); } } - else if (safe_timer.started() && global_frame_counter%2) + else if (safe_timer.started() && size_t(global_time*40)%2) ; // don't draw Tux else tux_body->draw(context, get_pos(), layer); @@ -854,7 +854,7 @@ Player::draw(DrawingContext& context) // Draw blinking star overlay if (invincible_timer.started() && (invincible_timer.get_timeleft() > TUX_INVINCIBLE_TIME_WARNING - || global_frame_counter % 3) + || size_t(global_time*20)%2) && !dying) { if (size == SMALL || duck) diff --git a/src/scene.h b/src/scene.h index 9ea2dc1c5..b8d55963c 100644 --- a/src/scene.h +++ b/src/scene.h @@ -47,6 +47,4 @@ PlayerStatus::BonusType string_to_bonus(const std::string& str); extern PlayerStatus player_status; -extern unsigned int global_frame_counter; - #endif /*SUPERTUX_SCENE_H*/ diff --git a/src/tile.cpp b/src/tile.cpp index af6757891..7c7204a82 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -100,7 +100,7 @@ std::vector create_surfaces(lisp_object_t* cur) } Tile::Tile() - : id(0), attributes(0), data(0), next_tile(0), anim_speed(25) + : id(0), attributes(0), data(0), next_tile(0), anim_fps(1) { } @@ -146,7 +146,7 @@ Tile::read(LispReader& reader) attributes |= GOAL; reader.read_int("data", data); - reader.read_int("anim-speed", anim_speed); + reader.read_float("anim-fps", anim_fps); reader.read_int("next-tile", next_tile); if(reader.read_int("slope-type", data)) { @@ -161,7 +161,7 @@ void Tile::draw(DrawingContext& context, const Vector& pos, int layer) const { if(images.size() > 1) { - size_t frame = ((global_frame_counter*25) / anim_speed) % images.size(); + size_t frame = size_t(global_time * anim_fps) % images.size(); context.draw_surface(images[frame], pos, layer); } else if (images.size() == 1) { context.draw_surface(images[0], pos, layer); diff --git a/src/tile.h b/src/tile.h index b34e67154..f943a2395 100644 --- a/src/tile.h +++ b/src/tile.h @@ -85,7 +85,7 @@ public: been collected or jumped at */ int next_tile; - int anim_speed; + float anim_fps; /** Draw a tile on the screen */ void draw(DrawingContext& context, const Vector& pos, int layer) const; diff --git a/src/title.cpp b/src/title.cpp index 8c59ccae9..e15011296 100644 --- a/src/title.cpp +++ b/src/title.cpp @@ -279,7 +279,6 @@ void draw_demo(float elapsed_time) world->play_music(LEVEL_MUSIC); - global_frame_counter++; tux->key_event((SDLKey) keymap.right,DOWN); if(random_timer.check()) { diff --git a/src/worldmap.cpp b/src/worldmap.cpp index 655710d8b..4bbc4b29d 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -179,8 +179,8 @@ TileManager::TileManager() tile->images.push_back(image); } - tile->anim_speed = 25; - reader.read_int("anim-speed", tile->anim_speed); + tile->anim_fps = 1; + reader.read_float("anim-fps", tile->anim_fps); if (id >= int(tiles.size())) @@ -454,8 +454,7 @@ Tile::draw(DrawingContext& context, Vector pos) if(images.size() > 1) { - size_t frame - = ((global_frame_counter*25) / anim_speed) % images.size(); + size_t frame = size_t(global_time * anim_fps) % images.size(); context.draw_surface(images[frame], pos, LAYER_TILES); } @@ -490,8 +489,6 @@ WorldMap::WorldMap() name = ""; music = "salcon.mod"; - global_frame_counter = 0; - total_stats.reset(); } @@ -831,10 +828,6 @@ std::cerr << "one way only\n"; void WorldMap::update(float delta) { - if(!frame_timer.check()) { - global_frame_counter++; - } - if (enter_level && !tux->is_moving()) { /* Check special tile action */ @@ -1184,7 +1177,6 @@ WorldMap::display() frame_rate.set_frame_limit(false); frame_rate.start(); - frame_timer.start(.25, true); DrawingContext context; while(!quit) diff --git a/src/worldmap.h b/src/worldmap.h index 45431d786..2018d85b2 100644 --- a/src/worldmap.h +++ b/src/worldmap.h @@ -60,7 +60,7 @@ public: void draw(DrawingContext& context, Vector pos); std::vector images; - int anim_speed; + float anim_fps; // Directions in which Tux is allowed to walk from this tile bool north; @@ -248,8 +248,6 @@ private: Statistics total_stats; void calculate_total_stats(); - Timer2 frame_timer; - public: WorldMap(); ~WorldMap(); -- 2.11.0