From 58bf708dc9f036b2c7d8d3edfdbfa62f0da3481a Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Sun, 5 Dec 2004 16:57:14 +0000 Subject: [PATCH] =?utf8?q?-Incorporated=20Marcin=20Ko=EF=BF=BD=EF=BF=BDcie?= =?utf8?q?lnicki=20patch=20that=20reintroduces=20the=20flying=20=20snowbal?= =?utf8?q?l,=20thanks=20-Changed=20worldmapfile=20format=20to=20support=20?= =?utf8?q?intro=20texts=20-Moved=20intro.txt=20extro.txt=20and=20extro-bon?= =?utf8?q?us.txt=20to=20levels/world1=20and=20=20levels/bonus1=20-Added=20?= =?utf8?q?a=20new=20text=20mode=20to=20the=20textfile=20system=20display?= =?utf8?q?=20that=20aligns=20the=20text=20at=20=20the=20left=20side.=20Thi?= =?utf8?q?s=20is=20alot=20easier=20to=20read=20than=20all=20text=20centere?= =?utf8?q?d.=20=20Still=20the=20current=20font=20is=20hard=20to=20read=20f?= =?utf8?q?or=20long=20texts=20and=20should=20be=20=20improved/replaced=20s?= =?utf8?q?omehow...=20-Use=20new=20translation=20system=20in=20the=20.txt?= =?utf8?q?=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit SVN-Revision: 2241 --- data/Jamfile | 4 +- data/credits.txt | 4 +- data/extro-bonus.txt | 25 -------- data/extro.txt | 110 --------------------------------- data/intro.txt | 97 ----------------------------- data/levels/bonus1/extro.txt | 27 +++++++++ data/levels/bonus1/worldmap.stwm | 2 +- data/levels/world1/de.po | 128 ++++++++++++++++++++++++++++++++++++++- data/levels/world1/extro.txt | 41 +++++++++++++ data/levels/world1/intro.txt | 27 +++++++++ data/levels/world1/worldmap.stwm | 3 +- lib/video/font.cpp | 25 ++++++-- src/badguy/badguy.cpp | 1 + src/badguy/jumpy.cpp | 11 ++++ src/badguy/jumpy.h | 1 + src/collision_grid.cpp | 15 ++--- src/collision_grid.h | 3 + src/gameloop.cpp | 6 -- src/sector.cpp | 38 +++++++++++- src/sector.h | 2 + src/worldmap.cpp | 101 +++++++++++++++--------------- src/worldmap.h | 3 + 22 files changed, 362 insertions(+), 312 deletions(-) delete mode 100644 data/extro-bonus.txt delete mode 100644 data/extro.txt delete mode 100644 data/intro.txt create mode 100644 data/levels/bonus1/extro.txt create mode 100644 data/levels/world1/extro.txt create mode 100644 data/levels/world1/intro.txt diff --git a/data/Jamfile b/data/Jamfile index 50f5115de..35c4b5143 100644 --- a/data/Jamfile +++ b/data/Jamfile @@ -35,9 +35,9 @@ LEVELPATHS = ; for p in $(LEVELPATHS) { - InstallData [ Wildcard $(p) : info *.stl *.stwm ] : $(p) ; + InstallData [ Wildcard $(p) : info *.stl *.stwm *.txt ] : $(p) ; - local translatable_lisp = [ Wildcard $(p) : info *.stl *.stwm ] ; + local translatable_lisp = [ Wildcard $(p) : info *.stl *.stwm *.txt ] ; SEARCH on $(translatable_lisp) = $(SEARCH_SOURCE) ; MakePot $(SUBDIR)/$(p)/messages.pot : $(translatable_lisp) ; XGETTEXT_FLAGS on $(SUBDIR)/$(p)/messages.pot += --language=Lisp ; diff --git a/data/credits.txt b/data/credits.txt index 5941d939c..dac5c9843 100644 --- a/data/credits.txt +++ b/data/credits.txt @@ -3,7 +3,7 @@ (background "oiltux.jpg") (text "-- SuperTux - - Milestone 1 + Milestone 1 -Maintainer @@ -213,4 +213,4 @@ Ver-nos-emos em breve na Milestone2!") - ) \ No newline at end of file + ) diff --git a/data/extro-bonus.txt b/data/extro-bonus.txt deleted file mode 100644 index d11778792..000000000 --- a/data/extro-bonus.txt +++ /dev/null @@ -1,25 +0,0 @@ --Congratulations! - - You have successfully finished - Bonus Island I - - - featuring levels contributed by - Jason W. Thompson - Torfi Gunnarsson - Abednego - Matr1x - - - If you didn't clear all levels yet, - find your way back home and take - another path. There is still more - challenge waiting for you! - - And there is a secret level to be - found as well... - - A big "Thank you" goes out to - everyone who contributed to this - release. We hope you enjoyed it! - diff --git a/data/extro.txt b/data/extro.txt deleted file mode 100644 index 247635860..000000000 --- a/data/extro.txt +++ /dev/null @@ -1,110 +0,0 @@ -; Ending text -(supertux-text - (background "extro.jpg") - (music "theme.mod") - (show-after "CREDITS") - - (text "-Entering Nolok's Throne Room! - - Tux ran into Nolok's throne room, - frantically searching for his beloved. - Alas, he found neither Penny nor Nolok - there, but instead, another note. - - \"Well done, Tux, well done. If you are - reading this, you have removed my - control over this icy fortress. But as - you can see, your beloved Penny is not - here. What you did not realize is that - this is just one of my many fortresses, - spread far across the lands! - - \"Tux, your ambition is most honorable, - but futile nonetheless. With every - fortress you conquer of mine, I will - escape to another, and take Penny with - me. Do not be silly... it is best that - you give up now.\" - - Tux was sadly leaving the room, when he - felt something beneath his foot... an - envelope, addressed to him! Inside was - a roughly sketched map with fortresses - drawn in various lands. On the corner - of the map was Penny's signature, a - drawing of the ice flower. - - Tux ran out of the fortress, map in - hand. No, he decided, he would not give - up. Penny was counting on him.") - -; Portuguese (European) by Ricardo Cruz - (text-pt_PT "-Entrando na Sala do Trono de Nolok! - - O Tux entra a correr na sala do trono de Nolok, - procurando freneticamente a sua amada. - Todavia, nem Penny, nem Nolok lá - estavam; em vez deles, outra carta. - - \"Muito bem, Tux, muito bem. Se estiveres a - ler isto é porque acabaste de remover - todo o meu poder sobre esta região gelada. Mas - como vês, a tua bela Penny não está - aqui. O que não te apercebeste é que - esta é apenas uma das várias fortalezas - que tenho espalhadas pelo reino! - - \"Tux, a tua intenção é honrosa... - mas fútil. Por cada fortaleza - que me conquistes, Escaparei - para outra, e levarei a Penny comigo. - Não sejas tonto... o melhor é mesmo - desistires agora.\" - - Tux abandona a sala tristemente, quando - sente algo debaixo do seu pé... um - envelope, endereçado a ele! Dentro estava - um esboço de um mapa com várias fortalezas - localizadas em vários pontos. No canto - do mapa estava a assinatura da Penny, o - desenho de uma flor de gelo. - - O Tux corre para fora da fortaleza, com o - mapa na mão. Não, ele decide, não vou - desistir. A Penny está a contar com ele.") - -; Italian (European) by Federico Asara - (text "-Entrando nella sala del trono di Nolok! - - Tux entro' correndo nella sala del trono di Nolok - cercando disperatamente la sua amata. - Ma lì non trovo' ne' lei ne' Nolok, - trovando invece un'altra nota. - - \"Ben fatto, Tux, ben fatto. Se starai - leggendo questa nota, avrai rimosso il - mio controllo da questa fortezza ghiacciata. - Ma come puoi vedere, la tua cara Penny - non e' qui. Non sei arrivato a pensare - che questa e' una delle mie tante fortezze, - sparse per tutte le terre! - - \"Tux, la tua ambizione e' onorabile, ma - anche futile. Per ogni mia fortezza - che conquisterai, io scappero' in un'altra, - e portero' Penny con me. Dai, non fare - lo stupido... e' meglio se ti arrendi - gia' da ora.\" - - Tux stava tristemente uscendo dalla sala, - quando egli senti' qualcosa sotto il suo - piede... una busta, indirizzata a lui! - Dentro c'era un abbozzo di mappa con - fortezze in varie terre. Nell'angolo della - mappa c'era la firma di Penny, un disegno - del suo fiore ghiacciato. - - Tux usci' correndo dalla fortezza, portando - con se la mappa. No, ormai ha deciso, lui - non si arrendera'. Penny si fida di lui!") - ) diff --git a/data/intro.txt b/data/intro.txt deleted file mode 100644 index 8008d5b75..000000000 --- a/data/intro.txt +++ /dev/null @@ -1,97 +0,0 @@ -; Introduction text -(supertux-text - (background "arctis.jpg") - - (text "-Penny gets captured! - - Tux and Penny were out having a nice - picnic on the ice fields of Antarctica. - Suddenly, a creature jumped from - behind an ice bush, there was a flash, - and Tux fell asleep! - - When Tux wakes up, he finds that Penny - is missing. Where she lay before now - lies a letter. \"Tux, my arch enemy!\" - says the letter. \"I have captured - your beautiful Penny and have taken her - to my fortress. The path to my fortress - is littered with my minions. Give up on - the thought of trying to reclaim her, - you haven't a chance! -Nolok\" - - Tux looks and see Nolok's fortress in - the distance. Determined to save his - beloved Penny, he begins his journey.") - -; Portuguese (European) by Ricardo Cruz - (text-pt_PT "-A Penny foi capturada! - - O Tux e a Penny foram fazer um piquenique - nos campos de gelo da Antártida. - De repente, uma criatura surge de - trás de um arbusto gelado, dá-se um clarão, - e o Tux perde os sentidos! - - Ao acordar, o Tux verifica que a sua - Penny desapareceu. No seu lugar - está uma carta. \"Tux, meu arqui-inimigo!\" - diz a carta. \"Eu capturei a tua - preciosa Penny e levei-a para - a minha fortaleza. O caminho para esta - está atolhado com os meus guerreiros. Desiste - sequer de pensares em resgatá-la, - porque não tens hipótese! -Nolok\" - - O Tux olha e vê a fortaleza de Nolok - ao longe. Determinado em salvar a sua - amada Penny, ele inicia a sua viagem.") - -; Italian (European) by Federico Asara - (text-it_IT "-Penny viene catturata! - - Tux e Penny stavano facendo un bel picnic - nelle distese ghiacciate dell'Antarctico. - All'improvviso, una creatura salto fuori - da un cespuglio ghiacciato, ci fu un lampo - di luce, e Tux svenne! - - Quando Tux si risveglia, nota che Penny - e' scomparsa. Al suo posto giace una - lettera. \"Tux, mio arci-nemico!\" - c'e' - scritto nella lettera. \"Ho catturato - la tua cara Penny e l'ho portata nella mia - fortezza. La strada e' piena di miei - servitori. Percio' arrenditi e non pensare - neanche di riuscire a salvarla, non - hai alcuna possibilita'! -Nolok\" - - Tux vede la fortezza di Nolok in - lontananza. Determinato a salvare la sua - amata Penny, comincia il suo viaggio.") - -; German by Marek Moeckel - (text-de_DE "-Penny ist verschwunden! - - Tux und Penny saßen gemütlich beim Picknick - in den eisigen Ebenen der Antarktis. - Plötzlich sprang eine dunkle Kreatur hinter - einem Felsen hervor. Tux sah einen grellen - Blitz, dann wurde er ohnmächtig. - - Als er aufwachte, bemerkte er dass Penny - verschwunden war. Wo sie eben noch saß, lag - nun ein Zettel, auf dem stand: \"Tux, mein - Erzfeind! Ich habe deine Freundin Penny - entführt und halte sie in meiner Festung - gefangen. Der Weg dorthin ist übersäht von - finsteren Kreaturen, die auf mein Kommando - hören! Versuche gar nicht erst, Penny zu - retten, denn du hast keine Chance! -Nolok\" - - Tux blickte von dem Brief auf und sah Noloks - Festung in der Ferne. Fest entschlossen - seine geliebte Penny zu retten, machte - er sich auf die Reise.") -) - diff --git a/data/levels/bonus1/extro.txt b/data/levels/bonus1/extro.txt new file mode 100644 index 000000000..f613385f5 --- /dev/null +++ b/data/levels/bonus1/extro.txt @@ -0,0 +1,27 @@ +(supertux-text + (background "actis.jpg") + (text (_ "-Congratulations! + +#You have successfully finished +#Bonus Island I + + featuring levels contributed by + Jason W. Thompson + Torfi Gunnarsson + Abednego + Matr1x + + +#If you didn't clear all levels yet, +#find your way back home and take +#another path. There is still more +#challenge waiting for you! + +#And there is a secret level to be +#found as well... + +#A big "Thank you" goes out to +#everyone who contributed to this +#release. We hope you enjoyed it!)) +) + diff --git a/data/levels/bonus1/worldmap.stwm b/data/levels/bonus1/worldmap.stwm index 9044557ae..34d506f1a 100644 --- a/data/levels/bonus1/worldmap.stwm +++ b/data/levels/bonus1/worldmap.stwm @@ -71,7 +71,7 @@ (x 30) (y 39)) (level (name "/bonus-level4.stl") - (extro-filelevel "extro-bonus.txt") + (extro-filelevel "extro.txt") (x 32) (y 46)) (level (name "bonus-level5.stl") diff --git a/data/levels/world1/de.po b/data/levels/world1/de.po index f0192d98c..e9b554397 100644 --- a/data/levels/world1/de.po +++ b/data/levels/world1/de.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: world 1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2004-12-02 02:10+0100\n" +"POT-Creation-Date: 2004-12-05 17:38+0100\n" "PO-Revision-Date: 2004-12-02 02:25+0100\n" "Last-Translator: \n" "Language-Team: German \n" @@ -17,6 +17,57 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" +#: data/levels/world1/intro.txt:5 +msgid "" +"-Penny gets captured!\n" +"\n" +"#Tux and Penny were out having a nice\n" +"#picnic on the ice fields of Antarctica.\n" +"#Suddenly, a creature jumped from\n" +"#behind an ice bush, there was a flash,\n" +"#and Tux fell asleep!\n" +"\n" +"#When Tux wakes up, he finds that Penny\n" +"#is missing. Where she lay before now\n" +"#lies a letter. \"Tux, my arch enemy!\"\n" +"#says the letter. \"I have captured\n" +"#your beautiful Penny and have taken her\n" +"#to my fortress. The path to my fortress\n" +"#is littered with my minions. Give up on\n" +"#the thought of trying to reclaim her,\n" +"#you haven't a chance! -Nolok\"\n" +"\n" +"#Tux looks and see Nolok's fortress in\n" +"#the distance. Determined to save his\n" +"#beloved Penny, he begins his journey." +msgstr "" +"-Penny ist verschwunden!\n" +"\n" +"#Tux und Penny sassen gemütlich beim Picknick\n" +"#in den eisigen Ebenen der Antarktis.\n" +"#Plötzlich sprang eine dunkle Kreatur hinter\n" +"#einem Felsen hervor. Tux sah einen grellen\n" +"#Blitz, dann wurde er ohnmächtig.\n" +"\n" +"#Als er aufwachte bemerkte er, dass Penny\n" +"#verschwunden war. Wo sie eben noch gesessen\n" +"#hatte lag jetzt ein Zettel:\n" +"\n" +"#\"Tux, mein Erzfeind!\n" +"#Ich habe deine Freundinn Penny entführt und\n" +"#halte sie in meiner Festung gefangen. Den Weg\n" +"#dorthin bewachen meine finsteren Kreaturen!\n" +"#Versuche gar nicht erst sie zu retten, du\n" +"#hast keine Chance! -Nolok\"\n" +"\n" +"#Tux blickte auf und sah Noloks Festung in\n" +"#der Ferne. Fest entschlossen seine gelibte\n" +"#Penny zu retten machte er sich auf den Weg.\n" + +#: data/levels/world1/worldmap.stwm:4 +msgid "Icyisland" +msgstr "" + #: data/levels/world1/level1.stl:5 msgid "Welcome to Antarctica" msgstr "Willkommen in Antarktika" @@ -24,3 +75,78 @@ msgstr "Willkommen in Antarktika" #: data/levels/world1/level2.stl:5 msgid "The Journey Begins" msgstr "Die Reise Beginnt" + +#: data/levels/world1/level3.stl:5 +msgid "Via Nostalgica" +msgstr "" + +#: data/levels/world1/extro.txt:7 +#, fuzzy +msgid "" +"-Entering Nolok's Throne Room!\n" +"\n" +"#Tux ran into Nolok's throne room,\n" +"#frantically searching for his beloved.\n" +"#Alas, he found neither Penny nor Nolok\n" +"#there, but instead, another note.\n" +"\n" +"#\"Well done, Tux, well done. If you are\n" +"#reading this, you have removed my\n" +"#control over this icy fortress. But as\n" +"#you can see, your beloved Penny is not\n" +"#here. What you did not realize is that\n" +"#this is just one of my many fortresses,\n" +"#spread far across the lands!\n" +"\n" +"#\"Tux, your ambition is most honorable,\n" +"#but futile nonetheless. With every\n" +"#fortress you conquer of mine, I will\n" +"#escape to another, and take Penny with\n" +"#me. Do not be silly... it is best that\n" +"#you give up now.\"\n" +"\n" +"#Tux was sadly leaving the room, when he\n" +"#felt something beneath his foot... an\n" +"#envelope, addressed to him! Inside was\n" +"#a roughly sketched map with fortresses\n" +"#drawn in various lands. On the corner\n" +"#of the map was Penny's signature, a\n" +"#drawing of the ice flower.\n" +"\n" +"#Tux ran out of the fortress, map in\n" +"#hand. No, he decided, he would not give\n" +"#up. Penny was counting on him." +msgstr "" +"-In Noloks Thronsaal\n" +"#Tux betrat Noloks Thronsaal und\n" +"#suchte verzweifelt nach seiner Geliebten,\n" +"#leider konnte er weder Penny noch Nolok\n" +"#dort entdecken, stattdessen fand er eine\n" +"#weitere Nachricht.\n" +"\n" +"#\"Gut gemaacht mein leiber Tux, sehr gut.\n" +"#Wenn du dies hier liest, hast du diese\n" +"#eisige Festung von mir befreit. Aber wie\n" +"#du siehst ist deine geliebte Penny nicht\n" +"#hier. Hast du nicht gemerkt, dass dies\n" +"#nur eine meiner vielen Festungen ist,\n" +"#die über die ganze Welt verteilt sind!\n" +"\n" +"#\"Tux, dein Bestreben ist ehrenwert, und\n" +"#dennoch vergeblich. Mit jeder meiner\n" +"#Festungen die du eroberst, werde ich zu\n" +"#einer weiteren fliehen. Sei nicht dumm,\n" +"#es wäre das beste jetzt aufzugeben.\n" +"\n" +"#Tux verliess traurig den Sall, als etwas\n" +"#unter seinem Fuss raschelte...\n" +"#Ein Briefumschlag mit seinem Namen!\n" +"#In dem Umschlag war eine grobe Karte,\n" +"#die Festungen in verschiedenen Ländern\n" +"#zeigte. Auf der Rückseite der Karte war\n" +"#Pennys Zeichen, das Bild einer Eisblume.\n" +"\n" +"#Tux nahm die Karte in die Hand und rannte\n" +"#aus der Festung. Nein, er würde nicht\n" +"#einfach aufgeben. Penny verliess sich auf\n" +"#ihn.\n" diff --git a/data/levels/world1/extro.txt b/data/levels/world1/extro.txt new file mode 100644 index 000000000..4e4d83ebf --- /dev/null +++ b/data/levels/world1/extro.txt @@ -0,0 +1,41 @@ +; Ending text +(supertux-text + (background "extro.jpg") + (music "theme.mod") + (show-after "CREDITS") + + (text (_ "-Entering Nolok's Throne Room! + +#Tux ran into Nolok's throne room, +#frantically searching for his beloved. +#Alas, he found neither Penny nor Nolok +#there, but instead, another note. + +#\"Well done, Tux, well done. If you are +#reading this, you have removed my +#control over this icy fortress. But as +#you can see, your beloved Penny is not +#here. What you did not realize is that +#this is just one of my many fortresses, +#spread far across the lands! + +#\"Tux, your ambition is most honorable, +#but futile nonetheless. With every +#fortress you conquer of mine, I will +#escape to another, and take Penny with +#me. Do not be silly... it is best that +#you give up now.\" + +#Tux was sadly leaving the room, when he +#felt something beneath his foot... an +#envelope, addressed to him! Inside was +#a roughly sketched map with fortresses +#drawn in various lands. On the corner +#of the map was Penny's signature, a +#drawing of the ice flower. + +#Tux ran out of the fortress, map in +#hand. No, he decided, he would not give +#up. Penny was counting on him.")) +) + diff --git a/data/levels/world1/intro.txt b/data/levels/world1/intro.txt new file mode 100644 index 000000000..57490589a --- /dev/null +++ b/data/levels/world1/intro.txt @@ -0,0 +1,27 @@ +; Introduction text +(supertux-text + (background "arctis.jpg") + + (text (_ "-Penny gets captured! + +#Tux and Penny were out having a nice +#picnic on the ice fields of Antarctica. +#Suddenly, a creature jumped from +#behind an ice bush, there was a flash, +#and Tux fell asleep! + +#When Tux wakes up, he finds that Penny +#is missing. Where she lay before now +#lies a letter. \"Tux, my arch enemy!\" +#says the letter. \"I have captured +#your beautiful Penny and have taken her +#to my fortress. The path to my fortress +#is littered with my minions. Give up on +#the thought of trying to reclaim her, +#you haven't a chance! -Nolok\" + +#Tux looks and see Nolok's fortress in +#the distance. Determined to save his +#beloved Penny, he begins his journey.")) +) + diff --git a/data/levels/world1/worldmap.stwm b/data/levels/world1/worldmap.stwm index d79b09af4..27ec3ffbb 100644 --- a/data/levels/world1/worldmap.stwm +++ b/data/levels/world1/worldmap.stwm @@ -1,10 +1,11 @@ ;; Generated with Flexlay Editor (supertux-worldmap (properties - (name "Icyisland") + (name (_ "Icyisland")) (name-pt_PT "Ilha Gelada") (name-de "Eisige Insel") (name-es "Isla de hielo") + (intro-filename "intro.txt") (music "salcon.mod") (start_pos_x 4) (start_pos_y 5)) diff --git a/lib/video/font.cpp b/lib/video/font.cpp index 3ae918da2..12d96c741 100644 --- a/lib/video/font.cpp +++ b/lib/video/font.cpp @@ -260,6 +260,7 @@ void SuperTux::display_text_file(const std::string& file, float scroll_speed, int done = 0; float scroll = 0; float speed = scroll_speed / 50; + float left_border = 50; DrawingContext context; SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); @@ -316,18 +317,32 @@ void SuperTux::display_text_file(const std::string& file, float scroll_speed, } Font* font = 0; + bool center = true; switch(names[i][0]) { case ' ': font = small_font; break; case '\t': font = normal_font; break; case '-': font = heading_font; break; case '*': font = reference_font; break; - default: font = reference_font; break; + case '#': font = normal_font; center = false; break; + default: + break; } - - context.draw_text(font, - names[i].substr(1, names[i].size()-1), - Vector(screen->w/2, screen->h + y - scroll), CENTER_ALLIGN, LAYER_FOREGROUND1); + + if(font) { + if(center) { + context.draw_text(font, + names[i].substr(1, names[i].size()-1), + Vector(screen->w/2, screen->h + y - scroll), + CENTER_ALLIGN, LAYER_FOREGROUND1); + } else { + context.draw_text(font, + names[i].substr(1, names[i].size()-1), + Vector(left_border, screen->h + y - scroll), + LEFT_ALLIGN, LAYER_FOREGROUND1); + } + } + y += font->get_height() + ITEMS_SPACE; } diff --git a/src/badguy/badguy.cpp b/src/badguy/badguy.cpp index f95f2015e..4a209783c 100644 --- a/src/badguy/badguy.cpp +++ b/src/badguy/badguy.cpp @@ -155,6 +155,7 @@ BadGuy::kill_squished(Player& player) { SoundManager::get()->play_sound(IDToSound(SND_SQUISH), get_pos(), player.get_pos()); + physic.enable_gravity(true); physic.set_velocity_x(0); physic.set_velocity_y(0); set_state(STATE_SQUISHED); diff --git a/src/badguy/jumpy.cpp b/src/badguy/jumpy.cpp index 6739a54a7..779d81e90 100644 --- a/src/badguy/jumpy.cpp +++ b/src/badguy/jumpy.cpp @@ -47,3 +47,14 @@ Jumpy::hit(const CollisionHit& chit) return CONTINUE; } + +void +Jumpy::active_action(float elapsed_time) +{ + BadGuy::active_action(elapsed_time); + + dir = Sector::current()->player->get_pos().x > get_pos().x + ? RIGHT : LEFT; + //FIXME: add middle and up here + sprite->set_action(dir == LEFT ? "left-down" : "right-down"); +} diff --git a/src/badguy/jumpy.h b/src/badguy/jumpy.h index eaeafa652..f65d5fcfc 100644 --- a/src/badguy/jumpy.h +++ b/src/badguy/jumpy.h @@ -12,6 +12,7 @@ public: HitResponse collision_badguy(BadGuy& other, const CollisionHit& hit); void write(lisp::Writer& writer); + void active_action(float); private: HitResponse hit(const CollisionHit& hit); diff --git a/src/collision_grid.cpp b/src/collision_grid.cpp index 9e11b6073..c3b27698b 100644 --- a/src/collision_grid.cpp +++ b/src/collision_grid.cpp @@ -4,11 +4,13 @@ #include "collision_grid.h" #include "special/collision.h" #include "sector.h" +#include "collision_grid_iterator.h" static const float DELTA = .001; CollisionGrid::CollisionGrid(float newwidth, float newheight) - : width(newwidth), height(newheight), cell_width(128), cell_height(128) + : width(newwidth), height(newheight), cell_width(128), cell_height(128), + iterator_timestamp(0) { cells_x = size_t(width / cell_width) + 1; cells_y = size_t(height / cell_height) + 1; @@ -116,8 +118,8 @@ CollisionGrid::move_object(MovingObject* object) void CollisionGrid::check_collisions() { - for(Objects::iterator i = objects.begin(); i != objects.end(); ++i) { - ObjectWrapper* wrapper = *i; + CollisionGridIterator iter(*this, Sector::current()->get_active_region()); + while(ObjectWrapper* wrapper = iter.next_wrapper()) { MovingObject* object = wrapper->object; if(!object->is_valid()) continue; @@ -140,8 +142,7 @@ CollisionGrid::check_collisions() void CollisionGrid::collide_object(ObjectWrapper* wrapper) { - static int timestamp = 0; - timestamp++; + iterator_timestamp++; const Rectangle& bbox = wrapper->object->bbox; for(float y = bbox.p1.y; y < bbox.p2.y; y += cell_height) { @@ -158,13 +159,13 @@ CollisionGrid::collide_object(ObjectWrapper* wrapper) entry = entry->next) { ObjectWrapper* wrapper2 = entry->object_wrapper; // only check each object once (even if it is in multiple cells) - if(wrapper2->timestamp == timestamp) + if(wrapper2->timestamp == iterator_timestamp) continue; // don't collide with objects we already collided with if(wrapper2->id <= wrapper->id) continue; - wrapper->timestamp = timestamp; + wrapper->timestamp = iterator_timestamp; collide_object_object(wrapper, wrapper2); } } diff --git a/src/collision_grid.h b/src/collision_grid.h index fe3f8314f..8a507d142 100644 --- a/src/collision_grid.h +++ b/src/collision_grid.h @@ -25,6 +25,8 @@ public: void check_collisions(); private: + friend class CollisionGridIterator; + struct ObjectWrapper { MovingObject* object; @@ -58,6 +60,7 @@ private: float height; float cell_width; float cell_height; + int iterator_timestamp; }; extern CollisionGrid* bla; diff --git a/src/gameloop.cpp b/src/gameloop.cpp index e793a1954..275c42fa6 100644 --- a/src/gameloop.cpp +++ b/src/gameloop.cpp @@ -964,12 +964,6 @@ bool process_load_game_menu() stream << slot; std::string slotfile = st_save_dir + "/slot" + stream.str() + ".stsg"; - if (access(slotfile.c_str(), F_OK) != 0) - { - shrink_fade(Vector(screen->w/2,screen->h/2), 600); - draw_intro(); - } - fadeout(256); DrawingContext context; context.draw_text(white_text, "Loading...", diff --git a/src/sector.cpp b/src/sector.cpp index 00819823b..063772e53 100644 --- a/src/sector.cpp +++ b/src/sector.cpp @@ -43,6 +43,7 @@ #include "resources.h" #include "statistics.h" #include "collision_grid.h" +#include "collision_grid_iterator.h" #include "special/collision.h" #include "math/rectangle.h" #include "math/aatriangle.h" @@ -55,6 +56,7 @@ #include "badguy/snowball.h" #include "badguy/bouncing_snowball.h" #include "badguy/flame.h" +#include "badguy/flyingsnowball.h" #include "badguy/mriceblock.h" #include "badguy/mrbomb.h" #include "badguy/dispenser.h" @@ -133,6 +135,8 @@ Sector::parse_object(const std::string& name, const lisp::Lisp& reader) return new BouncingSnowball(reader); } else if(name == "flame") { return new Flame(reader); + } else if(name == "flyingsnowball") { + return new FlyingSnowBall(reader); } else if(name == "mriceblock") { return new MrIceBlock(reader); } else if(name == "mrbomb") { @@ -466,11 +470,28 @@ Sector::get_best_spawn_point(Vector pos) return best_reset_point; } +Rectangle +Sector::get_active_region() +{ + return Rectangle( + camera->get_translation() - Vector(1600, 1200), + camera->get_translation() + Vector(1600, 1200)); +} + void Sector::action(float elapsed_time) { player->check_bounds(camera); - + +#if 0 + CollisionGridIterator iter(*grid, get_active_region()); + while(MovingObject* object = iter.next()) { + if(!object->is_valid()) + continue; + + object->action(elapsed_time); + } +#else /* update objects */ for(GameObjects::iterator i = gameobjects.begin(); i != gameobjects.end(); ++i) { @@ -480,7 +501,8 @@ Sector::action(float elapsed_time) object->action(elapsed_time); } - +#endif + /* Handle all possible collisions. */ collision_handler(); update_game_objects(); @@ -555,7 +577,16 @@ Sector::draw(DrawingContext& context) { context.push_transform(); context.set_translation(camera->get_translation()); - + +#if 0 + CollisionGridIterator iter(*grid, get_active_region()); + while(MovingObject* object = iter.next()) { + if(!object->is_valid()) + continue; + + object->draw(context); + } +#else for(GameObjects::iterator i = gameobjects.begin(); i != gameobjects.end(); ++i) { GameObject* object = *i; @@ -564,6 +595,7 @@ Sector::draw(DrawingContext& context) object->draw(context); } +#endif context.pop_transform(); } diff --git a/src/sector.h b/src/sector.h index 5fb49f6ef..5f31dc96e 100644 --- a/src/sector.h +++ b/src/sector.h @@ -139,6 +139,8 @@ public: // TODO make this private again typedef std::vector GameObjects; GameObjects gameobjects; + Rectangle get_active_region(); + private: void fix_old_tiles(); diff --git a/src/worldmap.cpp b/src/worldmap.cpp index 18469174d..af6742148 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -49,6 +49,8 @@ Menu* worldmap_menu = 0; +static const float TUXSPEED = 200; + namespace WorldMapNS { Direction reverse_dir(Direction direction) @@ -220,8 +222,8 @@ Tux::action(float delta) } else { - // Let tux walk a few pixels (20 pixel/sec) - offset += 20.0f * delta; + // Let tux walk + offset += TUXSPEED * delta; if (offset > 32) { // We reached the next tile, so we check what to do now @@ -349,6 +351,7 @@ WorldMap::WorldMap() name = ""; music = "salcon.mod"; + intro_displayed = false; total_stats.reset(); } @@ -393,6 +396,7 @@ WorldMap::load_map() const lisp::Lisp* props = iter.lisp(); props->get("name", name); props->get("music", music); + props->get("intro-filename", intro_filename); props->get("start_pos_x", start_x); props->get("start_pos_y", start_y); } else if(iter.item() == "special-tiles") { @@ -827,14 +831,13 @@ WorldMap::update(float delta) } /* The porpose of the next checking is that if the player lost the level (in case there is one), don't show anything */ - if(level_finished) - { - if (!level->extro_filename.empty()) - { + if(level_finished) { + if (!level->extro_filename.empty()) { // Display a text file - display_text_file(level->extro_filename, SCROLL_SPEED_MESSAGE, - white_big_text , white_text, white_small_text, blue_text ); - } + std::string filename = levels_path + level->extro_filename; + display_text_file(filename, SCROLL_SPEED_MESSAGE, + white_big_text , white_text, white_small_text, blue_text ); + } if (!level->next_worldmap.empty()) { @@ -1035,50 +1038,47 @@ WorldMap::display() song = SoundManager::get()->load_music(datadir + "/music/" + music); SoundManager::get()->play_music(song); - FrameRate frame_rate(10); - frame_rate.set_frame_limit(false); - - frame_rate.start(); + if(!intro_displayed && intro_filename != "") { + std::string filename = levels_path + intro_filename; + display_text_file(filename, SCROLL_SPEED_MESSAGE, + white_big_text, white_text, white_small_text, blue_text); + intro_displayed = true; + } + Uint32 lastticks = SDL_GetTicks(); DrawingContext context; - while(!quit) - { - float delta = frame_rate.get(); - - delta *= 1.3f; - - if (delta > 10.0f) - delta = .3f; - - frame_rate.update(); - - Vector tux_pos = tux->get_pos(); - if (1) - { - offset.x = -tux_pos.x + screen->w/2; - offset.y = -tux_pos.y + screen->h/2; - - if (offset.x > 0) offset.x = 0; - if (offset.y > 0) offset.y = 0; + while(!quit) { + Uint32 ticks = SDL_GetTicks(); + float elapsed_time = float(ticks - lastticks) / 1000; + global_time += elapsed_time; + lastticks = ticks; + + // 40 fps minimum + if(elapsed_time > .025) + elapsed_time = .025; + + Vector tux_pos = tux->get_pos(); + + offset.x = -tux_pos.x + screen->w/2; + offset.y = -tux_pos.y + screen->h/2; - if (offset.x < screen->w - width*32) offset.x = screen->w - width*32; - if (offset.y < screen->h - height*32) offset.y = screen->h - height*32; - } + if (offset.x > 0) offset.x = 0; + if (offset.y > 0) offset.y = 0; - draw(context, offset); - get_input(); - update(delta); + if (offset.x < screen->w - width*32) offset.x = screen->w - width*32; + if (offset.y < screen->h - height*32) offset.y = screen->h - height*32; + + draw(context, offset); + get_input(); + update(elapsed_time); - if(Menu::current()) - { - Menu::current()->draw(context); - mouse_cursor->draw(context); - } - - context.do_drawing(); - - SDL_Delay(20); + if(Menu::current()) { + Menu::current()->draw(context); + mouse_cursor->draw(context); } + + context.do_drawing(); + } } void @@ -1110,6 +1110,7 @@ WorldMap::savegame(const std::string& filename) writer.write_string("title", std::string(name + " - " + nb_solved_levels_str+"/"+total_levels_str)); writer.write_string("map", map_filename); + writer.write_bool("intro-displayed", intro_displayed); writer.write_int("lives", player_status.lives); writer.write_int("distros", player_status.lives); writer.write_int("max-score-multiplier", player_status.max_score_multiplier); @@ -1163,6 +1164,7 @@ WorldMap::loadgame(const std::string& filename) savegame->get("map", map_filename); load_map(); + savegame->get("intro-displayed", intro_displayed); savegame->get("lives", player_status.lives); savegame->get("distros", player_status.distros); savegame->get("max-score-multiplier", player_status.max_score_multiplier); @@ -1232,8 +1234,3 @@ WorldMap::loadmap(const std::string& filename) } } // namespace WorldMapNS - -/* Local Variables: */ -/* mode:c++ */ -/* End: */ - diff --git a/src/worldmap.h b/src/worldmap.h index 0403e2f62..01d0bfa26 100644 --- a/src/worldmap.h +++ b/src/worldmap.h @@ -199,6 +199,9 @@ private: Vector offset; std::string savegame_file; + + std::string intro_filename; + bool intro_displayed; void get_level_title(Level& level); -- 2.11.0