[Tux4kids-commits] r582 - in tuxmath/branches/mathcards_newarch: data/missions mingw nsis src
cheezmeister-guest at alioth.debian.org
cheezmeister-guest at alioth.debian.org
Sun Aug 3 22:19:38 UTC 2008
Author: cheezmeister-guest
Date: 2008-08-03 22:19:37 +0000 (Sun, 03 Aug 2008)
New Revision: 582
Added:
tuxmath/branches/mathcards_newarch/data/missions/campaign/
tuxmath/branches/mathcards_newarch/src/campaign.c
tuxmath/branches/mathcards_newarch/src/campaign.h
Modified:
tuxmath/branches/mathcards_newarch/mingw/tuxmath.cbp
tuxmath/branches/mathcards_newarch/nsis/tuxmath.nsi
tuxmath/branches/mathcards_newarch/nsis/tuxmath_with_conf.nsi
tuxmath/branches/mathcards_newarch/src/Makefile.am
tuxmath/branches/mathcards_newarch/src/credits.c
tuxmath/branches/mathcards_newarch/src/credits.h
tuxmath/branches/mathcards_newarch/src/fileops.h
tuxmath/branches/mathcards_newarch/src/game.c
tuxmath/branches/mathcards_newarch/src/game.h
tuxmath/branches/mathcards_newarch/src/mathcards.c
tuxmath/branches/mathcards_newarch/src/titlescreen.c
Log:
Merged trunk into mathcards branch (better late than never). Will iron out flaws before a merge back into trunk.
Copied: tuxmath/branches/mathcards_newarch/data/missions/campaign (from rev 578, tuxmath/trunk/data/missions/campaign)
Modified: tuxmath/branches/mathcards_newarch/mingw/tuxmath.cbp
===================================================================
--- tuxmath/branches/mathcards_newarch/mingw/tuxmath.cbp 2008-08-03 04:14:42 UTC (rev 581)
+++ tuxmath/branches/mathcards_newarch/mingw/tuxmath.cbp 2008-08-03 22:19:37 UTC (rev 582)
@@ -63,6 +63,14 @@
<Add library="SDL_ttf" />
</Linker>
</Target>
+ <Target title="lol">
+ <Option output="tuxmath" prefix_auto="1" extension_auto="1" />
+ <Option type="0" />
+ <Option compiler="gcc" />
+ <Compiler>
+ <Add option="-g" />
+ </Compiler>
+ </Target>
</Build>
<Compiler>
<Add option="-Wall" />
@@ -81,72 +89,178 @@
</Unit>
<Unit filename="../src/ConvertUTF.c">
<Option compilerVar="CC" />
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
</Unit>
- <Unit filename="../src/ConvertUTF.h" />
+ <Unit filename="../src/ConvertUTF.h">
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
+ </Unit>
<Unit filename="../src/SDL_extras.c">
<Option compilerVar="CC" />
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
</Unit>
- <Unit filename="../src/SDL_extras.h" />
+ <Unit filename="../src/SDL_extras.h">
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
+ </Unit>
<Unit filename="../src/audio.c">
<Option compilerVar="CC" />
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
</Unit>
- <Unit filename="../src/compiler.h" />
+ <Unit filename="../src/compiler.h">
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
+ </Unit>
<Unit filename="../src/credits.c">
<Option compilerVar="CC" />
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
</Unit>
- <Unit filename="../src/credits.h" />
+ <Unit filename="../src/credits.h">
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
+ </Unit>
<Unit filename="../src/exercise_mathcards.c">
<Option compilerVar="CC" />
<Option target="WinRelease" />
</Unit>
<Unit filename="../src/fileops.c">
<Option compilerVar="CC" />
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
</Unit>
- <Unit filename="../src/fileops.h" />
+ <Unit filename="../src/fileops.h">
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
+ </Unit>
<Unit filename="../src/game.c">
<Option compilerVar="CC" />
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
</Unit>
- <Unit filename="../src/game.h" />
- <Unit filename="../src/gettext.h" />
+ <Unit filename="../src/game.h">
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
+ </Unit>
+ <Unit filename="../src/gettext.h">
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
+ </Unit>
<Unit filename="../src/highscore.c">
<Option compilerVar="CC" />
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
</Unit>
- <Unit filename="../src/highscore.h" />
+ <Unit filename="../src/highscore.h">
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
+ </Unit>
<Unit filename="../src/lessons.c">
<Option compilerVar="CC" />
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
</Unit>
- <Unit filename="../src/lessons.h" />
+ <Unit filename="../src/lessons.h">
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
+ </Unit>
<Unit filename="../src/loaders.c">
<Option compilerVar="CC" />
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
</Unit>
<Unit filename="../src/mathcards.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="../src/mathcards.h" />
+ <Unit filename="../src/multiplayer.h" />
<Unit filename="../src/options.c">
<Option compilerVar="CC" />
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
</Unit>
- <Unit filename="../src/options.h" />
+ <Unit filename="../src/options.h">
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
+ </Unit>
<Unit filename="../src/pixels.c">
<Option compilerVar="CC" />
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
</Unit>
- <Unit filename="../src/pixels.h" />
+ <Unit filename="../src/pixels.h">
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
+ </Unit>
<Unit filename="../src/scandir.c">
<Option compilerVar="CC" />
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
</Unit>
- <Unit filename="../src/scandir.h" />
+ <Unit filename="../src/scandir.h">
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
+ </Unit>
<Unit filename="../src/setup.c">
<Option compilerVar="CC" />
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
</Unit>
- <Unit filename="../src/setup.h" />
+ <Unit filename="../src/setup.h">
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
+ </Unit>
<Unit filename="../src/titlescreen.c">
<Option compilerVar="CC" />
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
</Unit>
- <Unit filename="../src/titlescreen.h" />
+ <Unit filename="../src/titlescreen.h">
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
+ </Unit>
<Unit filename="../src/tuxmath.c">
<Option compilerVar="CC" />
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
</Unit>
- <Unit filename="../src/tuxmath.h" />
+ <Unit filename="../src/tuxmath.h">
+ <Option target="WinDebug" />
+ <Option target="WinRelease" />
+ <Option target="NixDebug" />
+ </Unit>
<Unit filename="../src/tuxmathadmin.c">
<Option compilerVar="CC" />
<Option target="<{~None~}>" />
Modified: tuxmath/branches/mathcards_newarch/nsis/tuxmath.nsi
===================================================================
--- tuxmath/branches/mathcards_newarch/nsis/tuxmath.nsi 2008-08-03 04:14:42 UTC (rev 581)
+++ tuxmath/branches/mathcards_newarch/nsis/tuxmath.nsi 2008-08-03 22:19:37 UTC (rev 582)
@@ -3,7 +3,7 @@
# modified for tuxmath by Yves Combe (yves at ycombe.net)
# modified more for tuxmath by David Bruce <dbruce at tampabay.rr.com>
-!define PKG_VERSION "1.6.0"
+!define PKG_VERSION "1.6.3"
!define PKG_PREFIX "tuxmath"
!define APP_PREFIX "TuxMath"
Modified: tuxmath/branches/mathcards_newarch/nsis/tuxmath_with_conf.nsi
===================================================================
--- tuxmath/branches/mathcards_newarch/nsis/tuxmath_with_conf.nsi 2008-08-03 04:14:42 UTC (rev 581)
+++ tuxmath/branches/mathcards_newarch/nsis/tuxmath_with_conf.nsi 2008-08-03 22:19:37 UTC (rev 582)
@@ -2,7 +2,7 @@
# with a few tiny modifications by Phil Harper(philh at theopencd.org)
# modified for tuxmath by Yves Combe (yves at ycombe.net)
-!define PKG_VERSION "1.6.0"
+!define PKG_VERSION "1.6.3"
!define PKG_PREFIX "tuxmath"
!define APP_PREFIX "TuxMath"
Modified: tuxmath/branches/mathcards_newarch/src/Makefile.am
===================================================================
--- tuxmath/branches/mathcards_newarch/src/Makefile.am 2008-08-03 04:14:42 UTC (rev 581)
+++ tuxmath/branches/mathcards_newarch/src/Makefile.am 2008-08-03 22:19:37 UTC (rev 582)
@@ -32,6 +32,7 @@
loaders.c \
audio.c \
mathcards.c \
+ campaign.c \
fileops.c \
ConvertUTF.c \
SDL_extras.c \
@@ -51,6 +52,7 @@
options.h \
setup.h \
titlescreen.h \
+ campaign.h \
tuxmath.h \
ConvertUTF.h \
SDL_extras.h \
Copied: tuxmath/branches/mathcards_newarch/src/campaign.c (from rev 578, tuxmath/trunk/src/campaign.c)
===================================================================
--- tuxmath/branches/mathcards_newarch/src/campaign.c (rev 0)
+++ tuxmath/branches/mathcards_newarch/src/campaign.c 2008-08-03 22:19:37 UTC (rev 582)
@@ -0,0 +1,122 @@
+/*
+ * campaign.c - handle TuxMath's 'Mission mode'
+ *
+ * Author: B. Luchen
+ */
+
+#include "campaign.h"
+
+
+void briefPlayer(int stage); //show text introducing the given stage
+void readStageSettings(int stage);
+void readRoundSettings(int stage, int round);
+
+char* stagenames[NUM_STAGES] = {"cadet", "scout", "ranger", "ace", "commando"};
+
+void start_campaign()
+{
+ int i, j;
+ int gameresult = 0, endcampaign = 0;
+ char roundmessage[10];
+
+ printf("Entering start_campaign()\n");
+
+
+ for (i = 0; i < NUM_STAGES; ++i)
+ {
+ printf("Stage %s\n", stagenames[i]);
+ briefPlayer(i);
+ for (j = 1; j <= NUM_ROUNDS; ++j)
+ {
+ printf("Round %d\n", j);
+
+ read_named_config_file("campaign/campaign");
+ readStageSettings(i);
+ readRoundSettings(i, j);
+
+ snprintf(roundmessage, 10, "Round %d", j);
+ game_set_start_message(roundmessage, "", "", "");
+
+
+ MC_PrintMathOptions(stdout, 0);
+ printf("Starting game...\n");
+ gameresult = game();
+ if (gameresult == GAME_OVER_WON)
+ ;
+ else if (gameresult == GAME_OVER_LOST)
+ {
+ //TODO game over sequence
+ endcampaign = 1;
+ }
+ else if (gameresult == GAME_OVER_ERROR)
+ {
+ tmdprintf("Error!\n");
+ endcampaign = 1;
+ }
+ else
+ {
+ printf("gameresult = %d\n", gameresult);
+ endcampaign = 0;
+ }
+
+ if (endcampaign)
+ return;
+
+ }
+ //bonus round
+ readStageSettings(i);
+ readRoundSettings(i, -1);
+ game_set_start_message("Bonus", "", "", "");
+ game();
+ }
+}
+
+void briefPlayer(int stage)
+{
+ SDL_FillRect(screen, NULL, 0);
+ //TransWipe(black, RANDOM_WIPE, 10, 20);
+
+ static char* sprites[] = {
+ "sprites/tux_helmet_yellowd.png",
+ "sprites/tux_helmet_greend.png",
+ "sprites/tux_helmet_blued.png",
+ "sprites/tux_helmet_redd.png",
+ "sprites/tux_helmet_blackd.png"
+ };
+ SDL_Surface* icon = NULL;
+ SDL_Rect textarea = screen->clip_rect;
+ SDL_Surface* loadedsprite = LoadImage(sprites[stage], IMG_REGULAR|IMG_NOT_REQUIRED);
+
+ if (loadedsprite)
+ {
+ icon = zoom(loadedsprite, loadedsprite->w*3, loadedsprite->h*3);
+ textarea.x = icon->w;
+ textarea.y = icon->h;
+ textarea.w = screen->w - icon->w;
+ textarea.h = screen->h - icon->h;
+ }
+ tmdprintf("Briefing\n");
+ SDL_BlitSurface(icon, NULL, screen, NULL);
+ scroll_text(briefings[stage], textarea, 1);
+ tmdprintf("Finished briefing\n");
+
+ SDL_FreeSurface(loadedsprite);
+ SDL_FreeSurface(icon);
+}
+
+void readStageSettings(int stage)
+{
+ static char fn[PATH_MAX];
+ snprintf(fn,PATH_MAX, "campaign/%s/%s", stagenames[stage], stagenames[stage]);
+ read_named_config_file(fn);
+}
+
+void readRoundSettings(int stage, int round)
+{
+ static char fn[PATH_MAX];
+ if (round == -1)
+ snprintf(fn, PATH_MAX, "campaign/%s/bonus", stagenames[stage]);
+ else
+ snprintf(fn,PATH_MAX, "campaign/%s/round%d", stagenames[stage], round);
+ read_named_config_file(fn);
+}
Copied: tuxmath/branches/mathcards_newarch/src/campaign.h (from rev 578, tuxmath/trunk/src/campaign.h)
===================================================================
--- tuxmath/branches/mathcards_newarch/src/campaign.h (rev 0)
+++ tuxmath/branches/mathcards_newarch/src/campaign.h 2008-08-03 22:19:37 UTC (rev 582)
@@ -0,0 +1,254 @@
+#ifndef CAMPAIGN_H
+#define CAMPAIGN_H
+
+#include "tuxmath.h"
+#include "credits.h"
+#include "titlescreen.h"
+#include "SDL_extras.h"
+#include "game.h"
+#include "fileops.h"
+
+#define TESTING_CAMPAIGN
+
+#define NUM_STAGES 5
+#define NUM_ROUNDS 3
+
+
+static char* briefings[NUM_STAGES][100] = {
+ //cadet
+ {
+ "-[Esc] to skip",
+ "Mission One: Careful Cadet",
+ "--------------------------",
+ "Welcome, Tux!",
+ "",
+ "Congratulations on your graduation from the ",
+ "Math Command Training Acedemy. ",
+ "",
+ "Your arrival to the Galactic Math Command Fleet",
+ "comes just in time. The distant star Mathematica",
+ "has gone supernova, and parts of its solar",
+ "system are now traveling toward the planet FOSS.",
+ "",
+ "Mathematican asteroids are made of a material",
+ "called Undotrium, a mysterious metal that is",
+ "known to be very hard to destroy. But Galactic",
+ "scientists think they have found a way to do",
+ "so. Powerful computers connected to a Lambda",
+ "Laser can use numbers to locate Undotrium comets,",
+ "aim and shoot a perfect beam that will turn it",
+ "into harmless snow. But first, you need to look",
+ "closely at the comet and tell the Lambda Laser",
+ "Computer what number it needs to use. There are",
+ "many different types of comets, and it is up to",
+ "up to you to figure out these numbers!",
+ "",
+ "Tux, your first mission as a Cadet will be to",
+ "help the peaceful penguins of FOSS. The penguins",
+ "are afraid to leave their igloos, and they need",
+ "Math Command help to keep them safe. Igloos can",
+ "protect penguins from Undotrium, but they will",
+ "melt if they're hit more than once, and then",
+ "the penguin will be without a home. Do not let",
+ "that happen!",
+ "",
+ "-IMPORANT",
+ "There is one more thing you should know. Certain",
+ "comets are made of a more powerful type of",
+ "Undotrium. You will know these comets when you",
+ "see them, by their red color. If you can shoot",
+ "a red comet, you may be able to use it to build",
+ "additional igloos."
+ "",
+ "",
+ "Good luck, Cadet.",
+ NULL
+ },
+ //scout
+ {
+ "-[Esc] to skip",
+ "Mission Two: Smart Scout",
+ "------------------------",
+ "Great job, Tux. Your performance on FOSS was",
+ "brilliant and the penguins give you their thanks.",
+ "After such a show of skill and smarts, we feel",
+ "that your training as a Cadet must be complete.",
+ "We are pleased to promote you to the rank of",
+ "Galactic Math Scout. As a gift for your",
+ "accomplishment, you are getting your own Lambda",
+ "Laser Computer. And it will come in handy...",
+ "You need to go on another mission right away!",
+ "",
+ "Already, another wave of comets is headed toward",
+ "FOSS. This time, things will not be so easy.",
+ "Radar scans of the new comets show signs of",
+ "subtractive Undotrium. Before, you have seen",
+ "comets such as \"2+3=5\". Now you will begin to",
+ "see \"5-2=3\" and \"5-2=3\". Subtractive",
+ "Undotrium is the opposite of normal Undotrium,",
+ "just like subtraction is the opposite of",
+ "addition. Don't let it trick you!",
+ "",
+ "Sometimes, you may need to figure out a very",
+ "large subtractive comet. The best strategy for",
+ "doing so is to start at the lower number and",
+ "count upward until you reach the higher number.",
+ "The number you count will be the answer, or as",
+ "we call it in the Fleet, the difference.",
+ "",
+ "You can do it, Tux! Show us how good you are.",
+ NULL
+ },
+ //ranger
+ {
+ "-[Esc] to skip",
+ "Mission Three: Royal Ranger",
+ "---------------------------",
+ "You've done it again. The Penguin Emperor, his",
+ "majesty the Great Auk, has heard of your math",
+ "skills and wants to congratulate you himself.",
+ "You have been invited to the Royal Igloo for a",
+ "celebration, where the Emperor will personally",
+ "offer a token of gratitude. He tells us it's a",
+ "surprise.",
+ "",
+ "-........",
+ "-@**>##;7^^PLEaSe StaND bY",
+ "**EMERGENCY ROYAL TRANSMISSION**",
+ "-Help! Save us! We....comets.....the penguins...",
+ "-...must come to...if....don't....go",
+ "**END OF TRANSMISSION**",
+ "",
+ "It sounds like the Royal Igloo is in trouble.",
+ "We weren't able to decode the whole transmission,",
+ "but the Emperor definitely said that there were",
+ "more comets. We are sending you in right away.",
+ "",
+ "Intel shows a new strain of Undotrium comets that",
+ "are many times larger than the ones you have seen",
+ "already. These multiplicative comets are made of",
+ "huge amounts of additive Undotrium. To solve them",
+ "you will need to add over and over again. Just",
+ "one comet can have a question like 3*6, which is",
+ "the same as 3+3+3+3+3+3!",
+ "",
+ "Be careful, Tux. We have also picked up signs of",
+ "comets that are very different from the ones",
+ "we've seen before. They have numbers that are",
+ "less than zero. These negative numbers do",
+ "strange things to addition and subtraction. If",
+ "a negative number is added, it is really",
+ "subtracted, and if it is subtracted, it's really",
+ "added.",
+ //TODO better explanation of negatives
+ "Also, if two numbers are multiplied and one of",
+ "them is negative, the answer will be negative",
+ "also. But if both numbers are negative, the",
+ "answer is positive! Be careful.",
+ "",
+ "We are making you a Ranger right away, and we",
+ "hope that you will give the Emperor and his",
+ "citizens extra care. We know you will do so.",
+ NULL
+ },
+ //ace
+ {
+ "-[Esc] to skip",
+ "Mission Four: Imperial Ace",
+ "--------------------------",
+ "You did it, Tux! The Emperor and the penguins of",
+ "FOSS are safe once more. His majesty would like",
+ "to speak to you.",
+ "",
+ "-Please stand by...",
+ "**OFFICIAL ROYAL TRANSMISSION**",
+ "-Thank you, Tux. The planet FOSS will forever be",
+ "-grateful. Please honor us tonight and join our",
+ "-celebration. I would like to personally give",
+ "-you the designation of imperial Ace. You've done",
+ "-well, and you are truly deserving.",
+ "**END OF TRANSMISSION**",
+ "",
+ "Bravo, Tux! The rank of Ace is the highest honor",
+ "a Math Command pilot can get. It can only come",
+ "from the Emperor himself! We will leave you to",
+ "your celebration. When you are finished, there",
+ "is more to do. Your mission, should you choose",
+ "to accept it, is to end the menace of all these",
+ "Mathematican comets once and for all.",
+ "",
+ "Our scientists have investigated the cause of",
+ "the repeated assault of comets: these aren't",
+ "coming from Mathematica anymore. A portion of",
+ "the original Mathematican asteroids passed",
+ "through Recursa Minor, a small but interesting",
+ "solar system that multiplies and replicates",
+ "anything that comes near it.",
+ "",
+ "You must travel into Recursa Minor to destroy",
+ "the rest of the asteroids before more copies",
+ "come out of there and threaten our people. To",
+ "make sure there aren't extra copies of YOU,",
+ "we will let you borrow the Singleton, an advanced",
+ "space ship the Galactic scientists wish to test",
+ "out. There should only ever be one Singleton.",
+ "",
+ "Tux, you will have to destroy asteroids that have",
+ "never come out of Recursa Minor: divisive",
+ "Undotrium asteroids. Don't be fooled by the",
+ "fancy symbol, \"%\". Division is just backwards",
+ "multiplication, or repeated subtraction. If you",
+ "subtract the divisor (the second number) from",
+ "the dividend over and over again, and put up a",
+ "finger every time you do, when you hit zero, the",
+ "number of fingers you're holding up will be the",
+ "answer. It's called the quotient, and it's the",
+ "only thing that will let you shoot divisive",
+ "Undotrium.",
+ "",
+ "Finish this, Tux. You're our Ace.",
+ NULL
+ },
+ //commando
+ {
+ "-[Esc] to skip",
+ "Final Mission: Computing Commando",
+ "---------------------------------",
+ "The penguins came along with you? I see. Those",
+ "penguins were copies of the ones from FOSS. The",
+ "Singleton was not perfect after all. ",
+ "",
+ "The ship is yours, Tux. Our scientists need to",
+ "start from scratch. Something about not",
+ "remembering how to build another Singleton.",
+ "",
+ "You've done well; there have been no more comet",
+ "assaults since you left FOSS. However, there are",
+ "still more asteroids deep in Recursa Minor,",
+ "orbiting the Moon of Infinite Recursion. The Moon",
+ "has mashed different comets into something far,",
+ "far nastier than what was originally there.",
+ "They're made of different types of Undotrium, and",
+ "to destroy them, you will need to figure out the",
+ "answer to each type. First to multiplication and",
+ "division. Then do addition and subtraction. We",
+ "have two examples:",
+ "-5*2+7 = 10+7 = 17",
+ "-8/4*3*2 = 2*3*2 = 6*2 = 12",
+ "Notice that in the first question, we do 5*2=10",
+ "first, because multiplication comes before",
+ "division.",
+ "In the second question, since there is division",
+ "and multiplication, we start on the left and go",
+ "right. If you go the other way, you will get the",
+ "wrong answer!",
+ "",
+ "This is it, Tux. Succeed here and the galaxy is",
+ "safe again. It's time to go Commando.",
+ NULL
+ },
+};
+
+void start_campaign();
+
+#endif // CAMPAIGN_H
Modified: tuxmath/branches/mathcards_newarch/src/credits.c
===================================================================
--- tuxmath/branches/mathcards_newarch/src/credits.c 2008-08-03 04:14:42 UTC (rev 581)
+++ tuxmath/branches/mathcards_newarch/src/credits.c 2008-08-03 22:19:37 UTC (rev 582)
@@ -27,8 +27,8 @@
#include "options.h"
#include "fileops.h"
#include "setup.h"
+#include "credits.h"
-
char * credit_text[] = {
"-TUX, OF MATH COMMAND", /* '-' at beginning makes highlighted: */
"COPYRIGHT 2001-2006",
@@ -94,23 +94,6 @@
"",
"-WEBSITE",
"WWW.TUX4KIDS.COM",
- "", /* The following blanks cause the screen to scroll to complete blank: */
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
NULL
};
@@ -354,7 +337,7 @@
};
-void draw_text(char * str, int offset);
+void draw_text(char * str, SDL_Rect dest);
int line;
@@ -363,10 +346,7 @@
int credits(void)
{
int done, quit, scroll;
- SDL_Rect src, dest;
- SDL_Event event;
- Uint32 last_time, now_time;
- SDLKey key;
+ SDL_Rect subscreen, dest;
/* Clear window: */
@@ -390,97 +370,115 @@
quit = 0;
scroll = 0;
line = 0;
+
+ subscreen.x = 0;
+ subscreen.y = images[IMG_TITLE]->h;
+ subscreen.w = screen->w;
+ subscreen.h = screen->h - images[IMG_TITLE]->h;
+ quit = scroll_text(credit_text, subscreen, 2);
- do
- {
- last_time = SDL_GetTicks();
-
-
- /* Handle any incoming events: */
- while (SDL_PollEvent(&event) > 0)
- {
- if (event.type == SDL_QUIT)
- {
- /* Window close event - quit! */
-
- quit = 1;
- done = 1;
- }
- else if (event.type == SDL_KEYDOWN)
- {
- key = event.key.keysym.sym;
-
- if (key == SDLK_ESCAPE)
- {
- /* Escape key - quit! */
-
- done = 1;
- }
- }
- else if (event.type == SDL_MOUSEBUTTONDOWN)
- {
- done = 1;
- }
- }
+ /* Return the chosen command: */
+
+ return quit;
+}
-
- /* Scroll: */
-
- src.x = 0;
- src.y = (images[IMG_TITLE]->h) + 2;
- src.w = screen->w;
- src.h = screen->h - (images[IMG_TITLE]->h);
-
- dest.x = 0;
- dest.y = (images[IMG_TITLE]->h);
- dest.w = src.w;
- dest.h = src.h;
-
+int scroll_text(char* text[], SDL_Rect subscreen, int speed)
+{
+ int done = 0, quit = 0, scroll = 0, clearing = 0;
+ SDL_Event event;
+ SDL_Rect src, dest;
+ Uint32 last_time = SDL_GetTicks(), now_time;
+
+ line = 0;
+
+ do
+ {
+ /* Handle any incoming events: */
+ while (SDL_PollEvent(&event) > 0)
+ {
+ if (event.type == SDL_QUIT)
+ {
+ /* Window close event - quit! */
+
+ quit = 1;
+ done = 1;
+ }
+ else if (event.type == SDL_KEYDOWN)
+ {
+ if (event.key.keysym.sym == SDLK_ESCAPE)
+ {
+ /* Escape key - quit! */
+ done = 1;
+ }
+ }
+ else if (event.type == SDL_MOUSEBUTTONDOWN)
+ {
+ done = 1;
+ }
+ }
+
+
+ /* Scroll: */
+
+ src = dest = subscreen;
+ src.y += speed; //amount to scroll by
+
SDL_BlitSurface(screen, &src, screen, &dest);
+
+ dest.x = subscreen.x;
+ dest.y = subscreen.y + subscreen.h - speed;
+ dest.w = subscreen.w;
+ dest.h = speed;
+
+ SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, 0, 0, 0));
+
+ ++scroll;
- dest.x = 0;
- dest.y = (screen->h) - 2;
- dest.w = screen->w;
- dest.h = 2;
-
- SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, 0, 0, 0));
-
-
- scroll++;
-
- draw_text(credit_text[line], scroll);
-
-
- if (scroll >= 9)
+ if (clearing) //scroll/check, but don't display any more text
{
- scroll = 0;
- line++;
-
- if (credit_text[line] == NULL)
+ if (scroll > subscreen.h / speed)
done = 1;
}
-
-
- SDL_Flip(screen);
-
-
- /* Pause (keep frame-rate event) */
-
- now_time = SDL_GetTicks();
- if (now_time < last_time + (1000 / 20))
- {
- SDL_Delay(last_time + (1000 / 20) - now_time);
+ else
+ {
+ dest.x = subscreen.x + subscreen.w / 2;
+ dest.y = subscreen.y + (subscreen.h - scroll * speed);
+ dest.w = 1;
+ dest.h = 1;
+ draw_text(text[line], dest);
+
+
+ if (scroll * speed >= TTF_FontHeight(default_font) )
+ {
+ scroll = 0;
+ line++;
+
+ if (text[line] == NULL) //end of text
+ {
+ clearing = 1; //scroll to blank
+ }
+ else
+ tmdprintf("text[line]: %s\n", text[line]);
+ }
+ }
+
+
+ SDL_Flip(screen);
+
+
+ /* Pause (keep frame-rate event) */
+
+ now_time = SDL_GetTicks();
+ if (now_time < last_time + (1000 / 20))
+ {
+ SDL_Delay(last_time + (1000 / 20) - now_time);
}
- }
- while (!done);
-
-
- /* Return the chosen command: */
-
- return quit;
-}
-
-
+ last_time = SDL_GetTicks();
+ }
+ while (!done);
+ return quit;
+}
+#if 0
void draw_text(char * str, int offset)
{
int i, c, x, y, cur_x, start, hilite;
@@ -503,7 +501,7 @@
cur_x = (screen->w - ((strlen(str) - start) * 18)) / 2;
for (i = start; i < strlen(str); i++)
- {
+ {
c = -1;
if (str[i] >= '0' && str[i] <= '9')
@@ -558,3 +556,53 @@
cur_x = cur_x + 18;
}
}
+
+#else
+
+//FIXME it's possible that generating the surface every frame taxes
+//slower machines. If so consider returning the surface to be used
+//as long as it's needed.
+void draw_text(char* str, SDL_Rect dest)
+{
+ int hloffset = 0;
+ SDL_Color col;
+ SDL_Surface* surf = NULL;
+ if (!str || *str == '\0')
+ return;
+
+ tmdprintf("Entering draw_text(%s)\n", str);
+
+ if (str[0] == '-') //highlight text
+ {
+ hloffset = 1;
+ col.r = 128;
+ col.g = 192;
+ col.b = 255 - (40);
+ }
+ else //normal color
+ {
+ col.r = 255 - (line % 256);
+ col.g = 255 / 2;
+ col.b = (line * line * 2) % 256;
+ }
+
+#ifndef SDL_Pango
+ surf = TTF_RenderUTF8_Blended(default_font, str+hloffset, col);
+#else
+ if( context != NULL)
+ {
+ SDLPango_SetDefaultColor(context, MATRIX_TRANSPARENT_BACK_BLACK_LETTER);
+ SDLPango_SetText(context, t, -1);
+ surf = SDLPango_CreateSurfaceDraw(context);
+ }
+ else {
+ surf = TTF_RenderUTF8_Blended(default_font, str+hloffset, col);
+ }
+#endif
+
+ dest.x -= surf->w / 2; //center text
+ SDL_BlitSurface(surf, NULL, screen, &dest);
+ SDL_FreeSurface(surf);
+ tmdprintf("done\n");
+}
+#endif
Modified: tuxmath/branches/mathcards_newarch/src/credits.h
===================================================================
--- tuxmath/branches/mathcards_newarch/src/credits.h 2008-08-03 04:14:42 UTC (rev 581)
+++ tuxmath/branches/mathcards_newarch/src/credits.h 2008-08-03 22:19:37 UTC (rev 582)
@@ -21,5 +21,5 @@
#define CREDITS_H
int credits(void);
-
+int scroll_text(char* text[], SDL_Rect subscreen, int speed);
#endif
Modified: tuxmath/branches/mathcards_newarch/src/fileops.h
===================================================================
--- tuxmath/branches/mathcards_newarch/src/fileops.h 2008-08-03 04:14:42 UTC (rev 581)
+++ tuxmath/branches/mathcards_newarch/src/fileops.h 2008-08-03 22:19:37 UTC (rev 582)
@@ -13,6 +13,9 @@
Copyright: See COPYING file that comes with this distribution (briefly, GNU GPL)
*/
+#ifndef FILEOPS_H
+#define FILEOPS_H
+
#include "tuxmath.h"
/* Flag basically telling whether or not to allow admin-level */
@@ -256,3 +259,4 @@
int load_sound_data();
#endif
+#endif
Modified: tuxmath/branches/mathcards_newarch/src/game.c
===================================================================
--- tuxmath/branches/mathcards_newarch/src/game.c 2008-08-03 04:14:42 UTC (rev 581)
+++ tuxmath/branches/mathcards_newarch/src/game.c 2008-08-03 22:19:37 UTC (rev 582)
@@ -127,7 +127,9 @@
SDL_Surface* current_bkgd()
{ return screen->flags & SDL_FULLSCREEN ? scaled_bkgd : bkgd; }
-static game_message s1, s2, s3, s4, s5;
+static game_message s1, s2, s3, s4, s5;
+static int start_message_chosen = 0;
+
typedef struct {
int x_is_blinking;
@@ -221,7 +223,7 @@
if (Opts_HelpMode()) {
game_handle_help();
game_cleanup();
- return 0;
+ return GAME_OVER_OTHER;
}
@@ -457,10 +459,23 @@
else
{
/* return to title() screen: */
- return 0;
+ return game_status;
}
}
+/*
+Set one to four lines of text to display at the game's start. Eventually
+this should stylishly fade out over the first few moments of the game.
+*/
+void game_set_start_message(const char* m1, const char* m2,
+ const char* m3, const char* m4)
+{
+ game_set_message(&s1, m1, screen->w / 2 - 40, RES_Y * 0 / 4);
+ game_set_message(&s2, m2, screen->w / 2 - 40, RES_Y * 1 / 4);
+ game_set_message(&s3, m3, screen->w / 2 - 40, RES_Y * 2 / 4);
+ game_set_message(&s4, m4, screen->w / 2 - 40, RES_Y * 3 / 4);
+ start_message_chosen = 1;
+}
int game_initialize(void)
{
@@ -626,11 +641,14 @@
tux_anim_frame = 0;
// Initialize the messages
- game_clear_message(&s1);
- game_clear_message(&s2);
- game_clear_message(&s3);
- game_clear_message(&s4);
game_clear_message(&s5);
+ if (!start_message_chosen)
+ {
+ game_clear_message(&s1);
+ game_clear_message(&s2);
+ game_clear_message(&s3);
+ game_clear_message(&s4);
+ }
help_controls.x_is_blinking = 0;
help_controls.extra_life_is_blinking = 0;
@@ -898,6 +916,7 @@
{
msg->x = x;
msg->y = y;
+ msg->alpha = SDL_ALPHA_OPAQUE;
strncpy(msg->message,txt,GAME_MESSAGE_LENGTH);
}
@@ -920,6 +939,7 @@
else
rect.x = msg->x; // left justified
rect.y = msg->y;
+ SDL_SetAlpha(surf, SDL_SRCALPHA, msg->alpha);
SDL_BlitSurface(surf, NULL, screen, &rect);
SDL_FreeSurface(surf);
//SDL_UpdateRect(screen, rect.x, rect.y, rect.w, rect.h);
@@ -1201,6 +1221,13 @@
if (level_start_wait <= 0)
return;
+ //dim start messages
+ s1.alpha -= SDL_ALPHA_OPAQUE / LEVEL_START_WAIT_START;
+ s2.alpha -= SDL_ALPHA_OPAQUE / LEVEL_START_WAIT_START;
+ s3.alpha -= SDL_ALPHA_OPAQUE / LEVEL_START_WAIT_START;
+ s4.alpha -= SDL_ALPHA_OPAQUE / LEVEL_START_WAIT_START;
+ tmdprintf("alpha = %d\n", s1.alpha);
+
level_start_wait--;
if (level_start_wait > LEVEL_START_WAIT_START / 4)
tux_img = IMG_TUX_RELAX1;
@@ -1738,7 +1765,6 @@
}
}
-/* FIXME consider splitting this into smaller functions e.g. draw_comets(), etc. */
void game_draw(void)
{
SDL_Rect dest;
@@ -2181,6 +2207,7 @@
/* determine if game won (i.e. all questions in mission answered correctly): */
if (MC_MissionAccomplished())
{
+ tmdprintf("Mission accomplished!\n");
return GAME_OVER_WON;
}
Modified: tuxmath/branches/mathcards_newarch/src/game.h
===================================================================
--- tuxmath/branches/mathcards_newarch/src/game.h 2008-08-03 04:14:42 UTC (rev 581)
+++ tuxmath/branches/mathcards_newarch/src/game.h 2008-08-03 22:19:37 UTC (rev 582)
@@ -86,6 +86,7 @@
typedef struct {
int x,y;
+ int alpha;
char message[GAME_MESSAGE_LENGTH];
} game_message;
@@ -136,6 +137,7 @@
};
int game(void);
+void game_set_start_message(const char*, const char*, const char*, const char*);
/* draw_nums() is used in options.c so need extern linkage */
void draw_nums(const char* str, int x, int y);
Modified: tuxmath/branches/mathcards_newarch/src/mathcards.c
===================================================================
--- tuxmath/branches/mathcards_newarch/src/mathcards.c 2008-08-03 04:14:42 UTC (rev 581)
+++ tuxmath/branches/mathcards_newarch/src/mathcards.c 2008-08-03 22:19:37 UTC (rev 582)
@@ -1231,6 +1231,9 @@
MC_MathQuestion** tmp_vect = NULL;
int i = 0;
+ if (!old_list || !*old_list) //invalid/empty list
+ return 0;
+
int old_length = list_length(old_tmp);
/* set random seed: */
Modified: tuxmath/branches/mathcards_newarch/src/titlescreen.c
===================================================================
--- tuxmath/branches/mathcards_newarch/src/titlescreen.c 2008-08-03 04:14:42 UTC (rev 581)
+++ tuxmath/branches/mathcards_newarch/src/titlescreen.c 2008-08-03 22:19:37 UTC (rev 582)
@@ -31,6 +31,7 @@
#include "options.h"
#include "fileops.h"
#include "game.h"
+#include "campaign.h"
#include "mathcards.h"
#include "setup.h" //for cleanup()
#include "credits.h"
@@ -1608,7 +1609,27 @@
}
break;
}
+#ifdef TESTING_CAMPAIGN
+ case SDLK_c:
+ {
+ start_campaign();
+ RecalcTitlePositions();
+ RecalcMenuPositions(&n_entries_per_screen,
+ n_menu_entries,
+ &menu_opts,
+ set_custom_menu_opts,
+ &menu_button_rect,
+ &menu_sprite_rect,
+ &menu_text_rect,
+ &back_button_rect,
+ &back_sprite_rect,
+ &back_text_rect,
+ &left_arrow_rect,
+ &right_arrow_rect);
+ redraw = 1;
+ }
+#endif
default:
{
/* Some other key - do nothing. */
More information about the Tux4kids-commits
mailing list