From: Charles McGarvey Date: Tue, 12 Jan 2010 00:12:51 +0000 (-0700) Subject: simplified win32 installer build script X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=b357615aba1dbde81e3c6999366604e6001010a7;p=chaz%2Fyoink simplified win32 installer build script --- diff --git a/COPYING b/COPYING index d0975dc..1948e77 100644 --- a/COPYING +++ b/COPYING @@ -55,7 +55,7 @@ Copyright: (c) 2000-2004 Unicode, Inc. Copyright: (c) 2002 Bob Pendleton License: LGPL-2.1 - Portion: libpng12-0.dll + Portion: libpng-3.dll Source: http://www.libpng.org/pub/png/libpng.html Copyright: (c) 2004, 2006-2009 Glenn Randers-Pehrson License: libpng @@ -85,7 +85,7 @@ Copyright: (c) 2009 Chris Robinson Copyright: (c) 2003 Neil Carter License: zlib-libpng - Portion: SDL.dll, SDL_image.dll + Portion: SDL.dll Source: http://www.libsdl.org/ Copyright: (c) 2009 Sam Lantinga et al. License: LGPL-2.1 diff --git a/README b/README index 529d3d6..6f5e024 100644 --- a/README +++ b/README @@ -31,12 +31,12 @@ this simple, fast-moving action game to a wider audience. b) Requirements boost headers +libpng libvorbis Lua OpenAL OpenGL SDL -SDL_image (with libpng support) c) License diff --git a/configure.ac b/configure.ac index 7ee82d3..054c4ac 100644 --- a/configure.ac +++ b/configure.ac @@ -10,11 +10,10 @@ AC_INIT([Yoink], [0.1], [chaz@dogcows.com], [yoink]) AC_CANONICAL_TARGET -AC_CONFIG_SRCDIR([src/GameLayer.cc]) +AC_CONFIG_SRCDIR([src/version.c]) AC_CONFIG_MACRO_DIR([m4]) AM_INIT_AUTOMAKE -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) # @@ -139,7 +138,7 @@ fi if test x$threads = xyes then AC_DEFINE([USE_THREADS], 1, - [Define to 1 if you want to use threads for parallel tasks.]) + [Define to 1 if you want to use threads when applicable.]) fi if test x$gtk = xyes @@ -149,7 +148,7 @@ then elif test x$qt4 = xyes then AC_DEFINE([USE_QT4], 1, - [Define to 1 if you want to use QT info/error dialogs.]) + [Define to 1 if you want to use QT4 info/error dialogs.]) fi AC_DEFINE_UNQUOTED([YOINK_LOGLEVEL], [$log_level], @@ -267,14 +266,14 @@ AC_SEARCH_LIBS([alEnable], [openal OpenAL32],, [missing=yes echo "***** Missing libopenal ($website) *****"]) -##### SDL_image ##### -website="http://www.libsdl.org/projects/SDL_image/" -AC_CHECK_HEADERS([SDL/SDL_image.h],, +##### libpng ##### +website="http://www.libpng.org/pub/png/libpng.html" +AC_CHECK_HEADERS([png.h],, [missing=yes - echo "***** Missing SDL_image header ($website) *****"]) -AC_SEARCH_LIBS([IMG_Load], [SDL_image],, + echo "***** Missing libpng header ($website) *****"]) +AC_SEARCH_LIBS([png_sig_cmp], [png],, [missing=yes - echo "***** Missing libSDL_image ($website) *****"]) + echo "***** Missing libpng ($website) *****"]) ##### libvorbis ##### website="http://www.xiph.org/downloads/" @@ -331,14 +330,13 @@ fi # -# Find the data files to install. +# Find the game resources to install. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -DATA_FILES=$(echo $(cd data; \ - find . -name "*.lua" \ - -o -name "*.ogg" \ - -o -name "*.png" \ - -o -name "yoinkrc")) +DATA_FILES=$(echo $(cd data && find . -name "*.lua" \ + -o -name "*.ogg" \ + -o -name "*.png" \ + -o -name "yoinkrc")) AC_SUBST([DATA_FILES]) @@ -354,7 +352,7 @@ AC_CONFIG_FILES([Makefile if test x$WIN32 = xyes then - AC_CONFIG_FILES([win32/Makefile win32/mkpackage.sh]) + AC_CONFIG_FILES([win32/Makefile win32/mkpackage.sh win32/yoink.nsi]) fi diff --git a/data/scenes/Classic.lua b/data/scenes/Classic.lua index e8ba272..5709632 100644 --- a/data/scenes/Classic.lua +++ b/data/scenes/Classic.lua @@ -3,6 +3,9 @@ -- created by Neil Carter -- converted to Lua by Charles McGarvey +LogInfo("-----", "Scene: Classic", "Created by Neil Carter", + "Converted to Lua by Charles McGarvey", "-----") + -- Scene API: -- -- Functions: @@ -28,7 +31,7 @@ SetBounds({-5, 0, -6}, {45, 15, 7}) -- Front ResetTransform() -Translate(-5, 0, 5) +Translate(-5, 0, 2) SetTexture("TowerBlock1") DrawTilemap({ width = 5, @@ -52,7 +55,7 @@ DrawTilemap({ ResetTransform() Rotate(Y, 90) -Translate(0, 0, 5) +Translate(0, 0, 2) DrawTilemap({ width = 5, surface = RIGHT, @@ -76,7 +79,7 @@ DrawTilemap({ ResetTransform() Rotate(X, 90) -Translate(-5, 15, 0) +Translate(-5, 15, -3) DrawTilemap({ width = 5, surface = TOP, @@ -93,6 +96,7 @@ DrawTilemap({ if detail > LOW then ResetTransform() + Translate(0, 0, -3) DrawTilemap({ width = 7, 2, 2, 2, 2, 2, 2, 2, @@ -108,7 +112,7 @@ if detail > LOW then ResetTransform() Rotate(Y, 90) - Translate(7, 0, 0) + Translate(7, 0, -3) DrawTilemap({ width = 6, 2, 2, 2, 2, 2, 2, @@ -124,7 +128,7 @@ if detail > LOW then ResetTransform() Rotate(X, 90) - Translate(-2, 8, -6) + Translate(-2, 8, -9) DrawTilemap({ width = 9, 3, 3, 3, 3, 3, 3, 3, 3, 3, @@ -142,7 +146,7 @@ end ResetTransform() Rotate(Y, -90) -Translate(10, 0, 1) +Translate(10, 0, -2) SetTexture("Building") DrawTilemap({ width = 4, @@ -157,7 +161,7 @@ DrawTilemap({ ResetTransform() Rotate(Y, -90) -Translate(13, 0, 1) +Translate(13, 0, -2) DrawTilemap({ width = 4, surface = RIGHT, @@ -170,7 +174,7 @@ DrawTilemap({ -- Front wall ResetTransform() -Translate(10, 0, 5) +Translate(10, 0, 2) DrawTilemap({ width = 3, 15, 7, 16, @@ -182,7 +186,7 @@ DrawTilemap({ ResetTransform() Rotate(X, 135) Scale(1, 1.5, 1.5) -Translate(10, 5, 3) +Translate(10, 5, 0) DrawTilemap({ width = 3, 13, 13, 13, @@ -191,7 +195,7 @@ DrawTilemap({ -- Finial ResetTransform() -Translate(10, 5, 3) +Translate(10, 5, -0.00001) DrawTilemap({ width = 3, 18, 18, 18}) @@ -214,7 +218,7 @@ DrawTilemap({ ResetTransform() Rotate(X, 90) -Translate(-3, 0, 0) +Translate(-3, 0, -3) SetTexture("Scenery") DrawTilemap({ width = 13, @@ -232,7 +236,7 @@ DrawTilemap({ if detail > MEDIUM then ResetTransform() Scale(8, 1, 1) - Translate(1, -0.5, 5) + Translate(1, -0.5, 2) DrawTile({ 2, u_scale = 8}) @@ -241,7 +245,7 @@ if detail > MEDIUM then ResetTransform() Scale(8, 1, 1) - Translate(1, -0.5, 1) + Translate(1, -0.5, -2) DrawTile({ 2, u_scale = 8 @@ -252,7 +256,7 @@ if detail > MEDIUM then ResetTransform() Scale(4, 1, 1) Rotate(Y, -90) - Translate(1, -0.5, 1) + Translate(1, -0.5, -2) DrawTile({ 2, u_scale = 4 @@ -263,7 +267,7 @@ if detail > MEDIUM then ResetTransform() Scale(4, 1, 1) Rotate(Y, -90) - Translate(9, -0.5, 1) + Translate(9, -0.5, -2) DrawTile({ 2, u_scale = 4 @@ -273,7 +277,7 @@ if detail > MEDIUM then ResetTransform() Scale(11, 1, 1) - Translate(7, 0, 0) + Translate(7, 0, -3) DrawTile({ 4, u_scale = 11 @@ -287,7 +291,7 @@ end if detail > LOW then ResetTransform() - Translate(19, 0, 0) + Translate(19, 0, -3) SetTexture("Building") DrawTilemap({ width = 4, @@ -302,7 +306,7 @@ if detail > LOW then ResetTransform() Rotate(Y, -90) - Translate(19, 0, -3) + Translate(19, 0, -6) DrawTilemap({ width = 3, 15, 1, 16, @@ -314,7 +318,7 @@ if detail > LOW then ResetTransform() Rotate(Y, -90) - Translate(23, 0, -3) + Translate(23, 0, -6) DrawTilemap({ width = 3, 15, 0, 16, @@ -328,7 +332,7 @@ if detail > LOW then Rotate(X, 135) Scale(1, 1.5, 1.5) Rotate(Y, -90) - Translate(21, 6, -3) + Translate(21, 6, -6) DrawTilemap({ width = 3, 13, 13, 13, @@ -340,7 +344,7 @@ if detail > LOW then Rotate(X, -135) Scale(1, 1.5, 1.5) Rotate(Y, -90) - Translate(21, 6, -3) + Translate(21, 6, -6) DrawTilemap({ width = 3, 13, 13, 13, @@ -350,7 +354,7 @@ if detail > LOW then ResetTransform() Rotate(Y, -90) - Translate(21, 6, -3) + Translate(21, 6, -6) DrawTilemap({ width = 3, 18, 18, 18}) @@ -363,7 +367,7 @@ end ResetTransform() Rotate(X, 90) -Translate(10, 0, 0) +Translate(10, 0, -3) SetTexture("Scenery") DrawTilemap({ width = 3, @@ -380,7 +384,7 @@ DrawTilemap({ ResetTransform() Rotate(X, 90) -Translate(13, 0, 0) +Translate(13, 0, -3) DrawTilemap({ width = 8, surface = TOP, @@ -397,7 +401,7 @@ DrawTilemap({ if detail > MEDIUM then ResetTransform() Scale(12, 1, 1) - Translate(14, -0.5, 5) + Translate(14, -0.5, 2) DrawTile({ 2, u_scale = 12 @@ -407,7 +411,7 @@ if detail > MEDIUM then ResetTransform() Scale(4, 1, 1) - Translate(14, -0.5, 1) + Translate(14, -0.5, -2) DrawTile({ 2, u_scale = 4 @@ -416,7 +420,7 @@ if detail > MEDIUM then -- Front grass next to door ResetTransform() - Translate(13, -0.5, 3) + Translate(13, -0.5, 0) DrawTile({ 2, u_scale = 1 @@ -425,7 +429,7 @@ if detail > MEDIUM then -- Back grass next to door ResetTransform() - Translate(13, -0.5, 2) + Translate(13, -0.5, -1) DrawTile({ 2, u_scale = 1 @@ -435,7 +439,7 @@ if detail > MEDIUM then ResetTransform() Rotate(Y, -90) - Translate(14, -0.5, 1) + Translate(14, -0.5, -2) DrawTilemap({ width = 4, 2, -1, 2, 2}) @@ -444,7 +448,7 @@ if detail > MEDIUM then ResetTransform() Rotate(Y, -90) - Translate(18, -0.5, 0) + Translate(18, -0.5, -3) DrawTile({ 2, u_scale = 1 @@ -454,7 +458,7 @@ if detail > MEDIUM then ResetTransform() Rotate(Y, -90) - Translate(24, -0.5, 0) + Translate(24, -0.5, -3) DrawTile({ 2, u_scale = 1 @@ -464,7 +468,7 @@ if detail > MEDIUM then ResetTransform() Scale(4, 1, 1) - Translate(19, -0.5, 4) + Translate(19, -0.5, 1) DrawTile({ 2, u_scale = 4 @@ -474,7 +478,7 @@ if detail > MEDIUM then ResetTransform() Scale(4, 1, 1) - Translate(19, -0.5, 2) + Translate(19, -0.5, -1) DrawTile({ 2, u_scale = 4 @@ -485,7 +489,7 @@ if detail > MEDIUM then ResetTransform() Scale(2, 1, 1) Rotate(Y, -90) - Translate(19, -0.5, 2) + Translate(19, -0.5, -1) DrawTile({ 2, u_scale = 2 @@ -496,7 +500,7 @@ if detail > MEDIUM then ResetTransform() Scale(2, 1, 1) Rotate(Y, -90) - Translate(23, -0.5, 2) + Translate(23, -0.5, -1) DrawTile({ 2, u_scale = 2 @@ -507,7 +511,7 @@ end ResetTransform() Rotate(X, 90) -Translate(21, 0, 0) +Translate(21, 0, -3) DrawTilemap({ width = 7, surface = TOP, @@ -524,7 +528,7 @@ DrawTilemap({ if detail > MEDIUM then ResetTransform() Scale(4, 1, 1) - Translate(24, 0, 0) + Translate(24, 0, -3) DrawTile({ 4, u_scale = 4 @@ -534,7 +538,7 @@ if detail > MEDIUM then ResetTransform() Scale(4, 1, 1) - Translate(24, -0.5, 1) + Translate(24, -0.5, -2) DrawTile({ 2, u_scale = 4 @@ -545,7 +549,7 @@ if detail > MEDIUM then ResetTransform() Scale(2, 1, 1) Rotate(Y, -90) - Translate(26, -0.5, 5) + Translate(26, -0.5, 2) DrawTile({ 2, u_scale = 2 @@ -556,7 +560,7 @@ if detail > MEDIUM then ResetTransform() Scale(2, 1, 1) Rotate(Y, -90) - Translate(35, -0.5, 5) + Translate(35, -0.5, 2) DrawTile({ 2, u_scale = 2 @@ -566,7 +570,7 @@ if detail > MEDIUM then ResetTransform() Scale(5, 1, 1) - Translate(35, -0.5, 5) + Translate(35, -0.5, 2) DrawTile({ 2, u_scale = 5 @@ -576,7 +580,7 @@ if detail > MEDIUM then ResetTransform() Scale(6, 1, 1) - Translate(34, -0.5, 1) + Translate(34, -0.5, -2) DrawTile({ 2, u_scale = 6 @@ -586,7 +590,7 @@ if detail > MEDIUM then ResetTransform() Rotate(Y, -90) - Translate(34, -0.5, 0) + Translate(34, -0.5, -3) DrawTile({ 2, u_scale = 1 @@ -597,7 +601,7 @@ end ResetTransform() Rotate(X, 90) -Translate(28, 0, 4) +Translate(28, 0, 1) DrawTilemap({ width = 5, surface = TOP, @@ -609,7 +613,7 @@ DrawTilemap({ ResetTransform() Rotate(X, 90) -Translate(33, 0, 0) +Translate(33, 0, -3) DrawTilemap({ width = 10, surface = TOP, @@ -627,7 +631,7 @@ DrawTilemap({ -- Front ResetTransform() -Translate(28, 0, 4) +Translate(28, 0, 1) SetTexture("TowerBlock1") DrawTilemap({ width = 5, @@ -643,7 +647,7 @@ DrawTilemap({ ResetTransform() Rotate(Y, 90) -Translate(33, 0, 4) +Translate(33, 0, 1) DrawTilemap({ width = 6, surface = RIGHT, @@ -659,7 +663,7 @@ DrawTilemap({ ResetTransform() Rotate(Y, 90) -Translate(28, 0, 4) +Translate(28, 0, 1) DrawTilemap({ width = 6, surface = LEFT, @@ -675,7 +679,7 @@ DrawTilemap({ ResetTransform() Rotate(X, 90) -Translate(28, 7, -2) +Translate(28, 7, -5) DrawTilemap({ width = 5, surface = TOP, @@ -692,7 +696,7 @@ DrawTilemap({ -- Front ResetTransform() -Translate(40, 0, 5) +Translate(40, 0, 2) DrawTilemap({ width = 5, 2, 2, 2, 2, 2, @@ -715,7 +719,7 @@ DrawTilemap({ ResetTransform() Rotate(Y, 90) -Translate(40, 0, 5) +Translate(40, 0, 2) DrawTilemap({ width = 5, surface = LEFT, @@ -739,7 +743,7 @@ DrawTilemap({ ResetTransform() Rotate(X, 90) -Translate(40, 15, 0) +Translate(40, 15, -3) DrawTilemap({ width = 5, surface = TOP, @@ -753,7 +757,7 @@ DrawTilemap({ -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ResetTransform() -Translate(-0.32, -0.28, -24) +Translate(-0.32, -0.28, -27) Scale(105, 52, 1) SetTexture("BackgroundFar") DrawTile() @@ -774,21 +778,20 @@ SetTexture("Trees") if detail > LOW then ResetTransform() Scale(3) - Translate(7.75, -0.1, 0.5) + Translate(7.75, -0.1, -2.5) DrawTile(1) end -- Center courtyard ResetTransform() ---Translate(610, -2.5, 85) Scale(3) -Translate(19, -0.1, 2.5) +Translate(19, -0.1, -0.5) DrawTile(0) ResetTransform() Scale(3) -Translate(20.25, -0.1, 3.5) +Translate(20.25, -0.1, 0.5) DrawTile(1) -- Right courtyard @@ -796,27 +799,22 @@ DrawTile(1) if detail > LOW then ResetTransform() Scale(3) - Translate(34, -0.1, 0.25) + Translate(34, -0.1, -2.75) DrawTile(1) ResetTransform() Scale(3) - Translate(36, -0.1, -0.5) + Translate(36, -0.1, -3.5) DrawTile(0) ResetTransform() Scale(3) - Translate(37, -0.1, 0.75) + Translate(37, -0.1, -2.25) DrawTile(1) end -function GetZCoord(x, y) - return 3.00001 -end - - -- Functions: -- DisplayText(text, seconds) -- Yield(seconds) @@ -829,23 +827,27 @@ end -- BeginNewWave() -- Events: +-- Think() is called periodically -- BadGuyDied(enemy) --- PlayedDied(player) --- SceneLoaded() +-- HeroineDied(player) -- Globals: -- numberOfBadGuys +--do + --SpawnHeroine({5, 5}) + --local waveNum = BeginNewWave() + --PopulateScene(waveNum) +--end + + -- Events --------- Event = {} -function Event:SceneLoaded() - SpawnHeroine({500, 500}) - local waveNum = BeginNewWave() - PopulateScene(waveNum) +function Event:Think() end function Event:BadGuyDied(enemy) @@ -887,7 +889,7 @@ function PopulateScene(waveNum) end function RandomSpawnPlace() - return {500, 500} + return {5, 5} end function RandomSkillLevel() @@ -895,5 +897,5 @@ function RandomSkillLevel() end --- vim: tw=80 ts=4 +-- vim: ts=4 sw=4 tw=80 diff --git a/data/textures/Particles.png b/data/textures/Particles.png index 3d8695f..659fae5 100644 Binary files a/data/textures/Particles.png and b/data/textures/Particles.png differ diff --git a/data/yoinkrc b/data/yoinkrc index 5660ffa..79fa707 100644 --- a/data/yoinkrc +++ b/data/yoinkrc @@ -50,12 +50,12 @@ resizable = true -- that make up the video mode. A typical value is 800,600 for a size of -- 800x600 pixels with millions of colors (the third number is optional). -videomode = {1024, 786} +videomode = {800, 600} -- Set whether or not the cursor will be visible when you mouse over the -- display of the game. -showcursor = false +showcursor = true -- Set whether or not the drawing should use two buffers. This results in -- a higher quality animation. You should usually leave this as true. diff --git a/doc/licenses/MIT b/doc/licenses/MIT index 0ee603d..4110670 100644 --- a/doc/licenses/MIT +++ b/doc/licenses/MIT @@ -1,14 +1,20 @@ Copyright (c) -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, -publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE -FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/extra/yoink.ebuild b/extra/yoink.ebuild index ce20adb..3646f82 100644 --- a/extra/yoink.ebuild +++ b/extra/yoink.ebuild @@ -17,10 +17,11 @@ KEYWORDS="amd64 ~ppc x86" IUSE="debug double-precision gtk qt4 threads" RDEPEND="dev-lang/lua + media-libs/libpng media-libs/libsdl[opengl] media-libs/libvorbis media-libs/openal - media-libs/sdl-image[png] + virtual/glu virtual/opengl" DEPEND="${RDEPEND} dev-libs/boost diff --git a/src/Animation.cc b/src/Animation.cc index 593f44e..598361b 100644 --- a/src/Animation.cc +++ b/src/Animation.cc @@ -167,7 +167,7 @@ class Animation::Impl std::string filePath = Animation::getPath(getName()); script.importBaseLibrary(); - importLogPrintFunction(script); + importLogFunctions(script); importAnimationBindings(script); if (script.doFile(filePath) != Mf::Script::SUCCESS) diff --git a/src/Character.cc b/src/Character.cc index 3022c31..52a13e6 100644 --- a/src/Character.cc +++ b/src/Character.cc @@ -79,7 +79,7 @@ private: Character::Character(const std::string& name) : - tilemap(name), + tilemap("Particles"), animation(name) { mState.init(); @@ -108,9 +108,9 @@ void Character::update(Mf::Scalar t, Mf::Scalar dt) animation.update(t, dt); - Mf::Vector3 center(mState.position[0], mState.position[1], mZCoord); - Mf::Vector3 a(mState.position[0] - 0.5, mState.position[1] - 0.5, mZCoord); - Mf::Vector3 b(mState.position[0] + 0.5, mState.position[1] + 0.5, mZCoord); + Mf::Vector3 center(mState.position[0], mState.position[1], 0.0); + Mf::Vector3 a(mState.position[0] - 0.5, mState.position[1] - 0.5, 0.0); + Mf::Vector3 b(mState.position[0] + 0.5, mState.position[1] + 0.5, 0.0); mAabb.init(a, b); mSphere.init(center, a); @@ -139,23 +139,18 @@ void Character::draw(Mf::Scalar alpha) const glBegin(GL_TRIANGLE_FAN); glTexCoord(coords[0], coords[1]); - glVertex(position[0]-s, position[1]-s, mZCoord); + glVertex(position[0]-s, position[1]-s); glTexCoord(coords[2], coords[3]); - glVertex(position[0]+s, position[1]-s, mZCoord); + glVertex(position[0]+s, position[1]-s); glTexCoord(coords[4], coords[5]); - glVertex(position[0]+s, position[1]+s, mZCoord); + glVertex(position[0]+s, position[1]+s); glTexCoord(coords[6], coords[7]); - glVertex(position[0]-s, position[1]+s, mZCoord); + glVertex(position[0]-s, position[1]+s); glEnd(); } -void Character::setZCoord(Mf::Scalar z) -{ - mZCoord = z; -} - -int Character::getOctant(const Mf::Aabb<3>& aabb) const +/*int Character::getOctant(const Mf::Aabb<3>& aabb) const { int octantNum = -1; @@ -263,6 +258,7 @@ int Character::getOctant(const Mf::Aabb<3>& aabb) const return octantNum; } +*/ void Character::addImpulse(Mf::Vector2 impulse) diff --git a/src/Character.hh b/src/Character.hh index 2173422..6507906 100644 --- a/src/Character.hh +++ b/src/Character.hh @@ -34,7 +34,6 @@ #include #include #include -#include #include #include @@ -52,7 +51,7 @@ typedef boost::shared_ptr CharacterP; * includes the heroine herself and the bad guys. */ -class Character : public Mf::RigidBody2, public Mf::OctreeInsertable +class Character : public Mf::RigidBody2 { public: @@ -62,20 +61,14 @@ public: virtual void update(Mf::Scalar t, Mf::Scalar dt); virtual void draw(Mf::Scalar alpha) const; - void setZCoord(Mf::Scalar z); - void addImpulse(Mf::Vector2 impulse); void addForce(Mf::Vector2 force); void setPosition(Mf::Vector2 position); - virtual int getOctant(const Mf::Aabb<3>& aabb) const; + //virtual int getOctant(const Mf::Aabb<3>& aabb) const; Tilemap tilemap; Animation animation; - -private: - - mutable Mf::Scalar mZCoord; }; diff --git a/src/GameLayer.cc b/src/GameLayer.cc index 3f5a7a8..0ed249c 100644 --- a/src/GameLayer.cc +++ b/src/GameLayer.cc @@ -42,25 +42,10 @@ #endif - -Mf::Scalar GameLayer::getZCoord(const Mf::Vector2& position) const -{ - Mf::Scalar z; - - mState.script.getGlobalTable().pushField("GetZCoord"); - mState.script.push(position[0]); - mState.script.push(position[1]); - mState.script.call(2, 1); - mState.script.getTop().get(z); - mState.script.pop(); - - return z; -} - void GameLayer::loadSceneLoader() { mState.script.importStandardLibraries(); - importLogPrintFunction(mState.script); + importLogFunctions(mState.script); std::string loaderPath = Scene::getPath("loader"); if (loaderPath == "") @@ -101,6 +86,18 @@ void GameLayer::advanceScene() throw Mf::Exception(Mf::ErrorCode::SCRIPT_ERROR, str); } + + mState.script.getGlobalTable().pushField("Event"); + if (mState.script[-1].isTable()) + { + mState.script[-1].pushField("Think"); + mState.script.set("Think", Mf::Script::REGISTRY); + mState.script.pop(2); + } + else + { + mState.script.pop(); + } } } @@ -121,11 +118,14 @@ GameLayer::GameLayer() : loadSceneLoader(); advanceScene(); // load the first scene + mThinkTimer.init(boost::bind(&GameLayer::thinkTimer, this), + 0.1, Mf::Timer::REPEAT); + mState.heroine = Heroine::alloc(); - mState.heroine->animation.startSequence("FlyDiagonallyUp"); + mState.heroine->animation.startSequence("GreenDiamond"); Mf::Scalar a[6] = {0.0, 1.5, -0.5, 3.0, -2.0, 1.0}; - mState.interp.init(a, 2.0, Mf::Interpolator::OSCILLATE); + mState.interp.init(a, 5.0, Mf::Interpolator::OSCILLATE); setProjection(); } @@ -155,12 +155,19 @@ void GameLayer::update(Mf::Engine& engine, Mf::Scalar t, Mf::Scalar dt) mState.scene->checkForCollision(*mState.heroine); mState.camera.setPosition(Mf::Vector3(-mState.heroine->getState().position[0], - -mState.heroine->getState().position[1], -9)); + -mState.heroine->getState().position[1], -6)); //mState.camera.lookAt(Mf::promote(mState.heroine->getState().position)); mRay.point = mState.heroine->getState().position; } +void GameLayer::thinkTimer() +{ + mState.script.getRegistryTable().pushField("Think"); + if (mState.script[-1].isFunction()) mState.script.call(); + else mState.script.pop(); +} + void GameLayer::rayTimer() { @@ -186,9 +193,9 @@ void GameLayer::rayTimer() { hits.front().normal.normalize(); mRay.solve(point, hits.front().distance); - Mf::logDebug << "scene: d = " << hits.front().distance << std::endl; - Mf::logDebug << " P = " << point << std::endl; - Mf::logDebug << " n = " << hits.front().normal << std::endl; + Mf::logInfo << "scene: d = " << hits.front().distance << std::endl; + Mf::logInfo << " P = " << point << std::endl; + Mf::logInfo << " n = " << hits.front().normal << std::endl; } } @@ -205,7 +212,6 @@ void GameLayer::draw(Mf::Engine& engine, Mf::Scalar alpha) const mState.scene->drawIfVisible(alpha, mState.camera.getFrustum()); - mState.heroine->setZCoord(getZCoord(mState.heroine->getState().position)); mState.heroine->draw(alpha); mRay.draw(); @@ -242,6 +248,12 @@ bool GameLayer::handleEvent(Mf::Engine& engine, const Mf::Event& event) cml::rad(-10.0)); return true; } + else if (event.key.keysym.sym == SDLK_r) + { + loadSceneLoader(); + advanceScene(); + return true; + } return mState.heroine->handleEvent(event); case SDL_KEYUP: diff --git a/src/GameLayer.hh b/src/GameLayer.hh index 4e0a84f..73b6a23 100644 --- a/src/GameLayer.hh +++ b/src/GameLayer.hh @@ -80,9 +80,7 @@ public: struct State { - // the script object must be mutable because some script functions must be - // called during draw - mutable Mf::Script script; + Mf::Script script; std::vector sceneList; HeroineP heroine; @@ -98,12 +96,14 @@ private: void loadSceneLoader(); void advanceScene(); - Mf::Scalar getZCoord(const Mf::Vector2& position) const; + void thinkTimer(); void setProjection(); void setProjection(Mf::Scalar width, Mf::Scalar height); State mState; + Mf::Timer mThinkTimer; + Mf::SoundStream mMusic; Mf::Sound mPunchSound; diff --git a/src/Heroine.cc b/src/Heroine.cc index a70b798..5df1031 100644 --- a/src/Heroine.cc +++ b/src/Heroine.cc @@ -33,7 +33,7 @@ Heroine::Heroine() : - Character("Heroine") {} + Character("Effects") {} void Heroine::update(Mf::Scalar t, Mf::Scalar dt) diff --git a/src/MainLayer.cc b/src/MainLayer.cc index 0b2ef36..4037736 100644 --- a/src/MainLayer.cc +++ b/src/MainLayer.cc @@ -77,6 +77,7 @@ void MainLayer::update(Mf::Engine& engine, Mf::Scalar t, Mf::Scalar dt) { // this is the only layer left on the stack //engine.push(TitleLayer::alloc()); + engine.clear(); } } @@ -270,12 +271,10 @@ int main(int argc, char* argv[]) atexit(goodbye); -#if YOINK_LOGLEVEL >= 4 - Mf::Log::setLevel(Mf::Log::DEBUGG); -#elif YOINK_LOGLEVEL >= 3 +#if YOINK_LOGLEVEL >= 3 Mf::Log::setLevel(Mf::Log::INFO); #elif YOINK_LOGLEVEL >= 2 - Mf::Log::setLevel(Mf::Log::SCRIPT); + Mf::Log::setLevel(Mf::Log::WARNING); #elif YOINK_LOGLEVEL >= 1 Mf::Log::setLevel(Mf::Log::ERROR); #elif YOINK_LOGLEVEL diff --git a/src/Makefile.am b/src/Makefile.am index 766d4ce..ee59088 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -31,6 +31,8 @@ libmoof_a_SOURCES = \ Moof/Frustum.hh \ Moof/Hash.cc \ Moof/Hash.hh \ + Moof/Image.cc \ + Moof/Image.hh \ Moof/Interpolator.hh \ Moof/Layer.hh \ Moof/Library.hh \ diff --git a/src/Moof/Engine.cc b/src/Moof/Engine.cc index ccfaf81..56e98b9 100644 --- a/src/Moof/Engine.cc +++ b/src/Moof/Engine.cc @@ -73,7 +73,7 @@ public: { char vdName[128]; SDL_VideoDriverName(vdName, sizeof(vdName)); - logDebug << "initialized SDL; using video driver `" + logInfo << "initialized SDL; using video driver `" << vdName << "'" << std::endl; } @@ -94,7 +94,7 @@ public: else { alcMakeContextCurrent(mAlContext); - logDebug << "opened sound device `" + logInfo << "opened sound device `" << alcGetString(mAlDevice, ALC_DEFAULT_DEVICE_SPECIFIER) << "'" << std::endl; } @@ -282,7 +282,7 @@ public: { ASSERT(layer && "cannot push null layer"); mStack.push_front(layer); - logDebug << "stack: " << mStack.size() + logInfo << "stack: " << mStack.size() << " [pushed " << layer.get() << "]" << std::endl; layer->pushed(mInterface); } @@ -294,7 +294,7 @@ public: LayerP layer = mStack.front(); mStack.pop_front(); - logDebug << "stack: " << mStack.size() + logInfo << "stack: " << mStack.size() << " [popped " << layer.get() << "]" << std::endl; layer->popped(mInterface); @@ -324,7 +324,7 @@ public: for (it = layers.begin(); it != layers.end(); ++it) { (*it)->popped(mInterface); - logDebug << "stack: " << mStack.size() + logInfo << "stack: " << mStack.size() << " [popped " << (*it).get() << "]" << std::endl; } @@ -341,7 +341,7 @@ public: { mStack.clear(); mStackIt = mStack.begin(); - logDebug("stack: 0 [cleared]"); + logInfo("stack: 0 [cleared]"); } diff --git a/src/Moof/Image.cc b/src/Moof/Image.cc new file mode 100644 index 0000000..31d6b02 --- /dev/null +++ b/src/Moof/Image.cc @@ -0,0 +1,325 @@ + +/******************************************************************************* + + Copyright (c) 2009, Charles McGarvey + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*******************************************************************************/ + +#include // FILE +#include // strncmp + +#include +#include + +#include "Image.hh" +#include "Library.hh" +#include "Log.hh" + + +namespace Mf { + + +class Image::Impl : public Library +{ +public: + + explicit Impl(const std::string& name, bool flipped = false) : + Library(name), + mContext(0), + mPixels(0) + { + init(getName(), flipped); + } + + ~Impl() + { + SDL_FreeSurface(mContext); + delete[] mPixels; + } + + + void flip() + { + unsigned char* pixels = (Uint8*)(mContext->pixels); + + unsigned pitch = mContext->pitch; + unsigned char line[pitch]; + + int yBegin = 0; + int yEnd = mContext->h - 1; + + if (SDL_MUSTLOCK(mContext)) SDL_LockSurface(mContext); + while (yBegin < yEnd) + { + memcpy(line, pixels + pitch * yBegin, pitch); + memcpy(pixels + pitch * yBegin, pixels + pitch * yEnd, pitch); + memcpy(pixels + pitch * yEnd, line, pitch); + yBegin++; + yEnd--; + } + if (SDL_MUSTLOCK(mContext)) SDL_UnlockSurface(mContext); + } + + void setAsIcon() const + { + SDL_WM_SetIcon(mContext, 0); + } + + + SDL_Surface* mContext; + char* mPixels; + + unsigned mDepth; + GLuint mColorMode; + + std::string mComment; + + +private: + + bool init(const std::string& filePath, bool flipped) + { + logInfo("opening image file..."); + FILE* fp = fopen(filePath.c_str(), "rb"); + if (!fp) return false; + + png_byte signature[8]; + size_t bytesRead; + + png_infop pngInfo = 0; + png_infop pngInfoEnd = 0; + png_structp pngObj = 0; + + int width; + int height; + int pitch; + int bpp; + int channels; + + png_byte colors; + png_bytepp rows = 0; + + png_textp texts = 0; + int numTexts; + + logInfo("checking signature..."); + bytesRead = fread(signature, 1, sizeof(signature), fp); + logInfo << "reading " << bytesRead << " bytes of signature" << std::endl; + if (bytesRead < sizeof(signature) || + png_sig_cmp(signature, 0, sizeof(signature)) != 0) goto cleanup; + + logInfo("creating png structures..."); + pngObj = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0); + if (!pngObj) goto cleanup; + + pngInfo = png_create_info_struct(pngObj); + if (!pngInfo) goto cleanup; + + pngInfoEnd = png_create_info_struct(pngObj); + if (!pngInfoEnd) goto cleanup; + + logInfo("setting up long jump..."); + if (setjmp(png_jmpbuf(pngObj))) goto cleanup; + + png_init_io(pngObj, fp); + png_set_sig_bytes(pngObj, sizeof(signature)); + png_read_info(pngObj, pngInfo); + + bpp = png_get_bit_depth(pngObj, pngInfo); + logInfo << "texture bpp: " << bpp << std::endl; + colors = png_get_color_type(pngObj, pngInfo); + switch (colors) + { + case PNG_COLOR_TYPE_PALETTE: + png_set_palette_to_rgb(pngObj); + break; + + case PNG_COLOR_TYPE_GRAY: + if (bpp < 8) png_set_gray_1_2_4_to_8(pngObj); + break; + + case PNG_COLOR_TYPE_GRAY_ALPHA: + png_set_gray_to_rgb(pngObj); + break; + } + + if (bpp == 16) png_set_strip_16(pngObj); + + png_read_update_info(pngObj, pngInfo); + + bpp = png_get_bit_depth(pngObj, pngInfo); + channels = png_get_channels(pngObj, pngInfo); + mDepth = bpp * channels; + + logInfo << "texture channels: " << channels << std::endl; + if (channels == 3) mColorMode = GL_RGB; + else mColorMode = GL_RGBA; + + // read comments + png_get_text(pngObj, pngInfo, &texts, &numTexts); + logInfo << "num texts: " << numTexts << std::endl; + for (int i = 0; i < numTexts; ++i) + { + if (strncmp(texts[i].key, "Comment", 7) == 0) + { + mComment = texts[i].text; + break; + } + } + + width = png_get_image_width(pngObj, pngInfo); + height = png_get_image_height(pngObj, pngInfo); + + pitch = png_get_rowbytes(pngObj, pngInfo); + mPixels = new char[width * pitch]; + + rows = new png_bytep[height]; + if (flipped) + { + for (int i = 0; i < height; ++i) + { + rows[height - 1 - i] = (png_bytep)(mPixels + i * channels * width); + } + } + else + { + for (int i = 0; i < height; ++i) + { + rows[i] = (png_bytep)(mPixels + i * channels * width); + } + } + + png_read_image(pngObj, rows); + png_read_end(pngObj, 0); + + mContext = SDL_CreateRGBSurfaceFrom + ( + mPixels, + width, + height, + bpp * channels, + pitch, +#if SDL_BYTEORDER == SDL_LIL_ENDIAN + 0x000000FF, + 0x0000FF00, + 0x00FF0000, + 0xFF000000 +#else + 0xFF000000, + 0x00FF0000, + 0x0000FF00, + 0x000000FF +#endif + ); + + cleanup: + + logInfo("cleaning up..."); + delete[] rows; + png_destroy_read_struct(pngObj ? &pngObj : 0, + pngInfo ? &pngInfo : 0, + pngInfoEnd ? &pngInfoEnd : 0); + fclose(fp); + + return mContext; + } +}; + + +Image::Image(const std::string& name) : + // pass through + mImpl(Image::Impl::getInstance(name)) {} + + +bool Image::isValid() const +{ + return mImpl->mContext; +} + +int Image::getWidth() const +{ + return mImpl->mContext->w; +} + +int Image::getHeight() const +{ + return mImpl->mContext->h; +} + +unsigned Image::getDepth() const +{ + return mImpl->mDepth; +} + +unsigned Image::getPitch() const +{ + return mImpl->mContext->pitch; +} + +GLuint Image::getColorMode() const +{ + return mImpl->mColorMode; +} + +std::string Image::getComment() const +{ + return mImpl->mComment; +} + +const char* Image::getPixels() const +{ + return mImpl->mPixels; +} + +char* Image::getPixels() +{ + return mImpl->mPixels; +} + + +void Image::flip() +{ + // pass through + mImpl->flip(); +} + +void Image::setAsIcon() const +{ + // pass through + mImpl->setAsIcon(); +} + + + +std::string Image::getPath(const std::string& name) +{ + std::string path = Resource::getPath("images/" + name + ".png"); + return path; +} + + +} // namespace Mf + +/** vim: set ts=4 sw=4 tw=80: *************************************************/ + diff --git a/src/Moof/Image.hh b/src/Moof/Image.hh new file mode 100644 index 0000000..5f7c5a3 --- /dev/null +++ b/src/Moof/Image.hh @@ -0,0 +1,79 @@ + +/******************************************************************************* + + Copyright (c) 2009, Charles McGarvey + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*******************************************************************************/ + +#ifndef _MOOF_IMAGE_HH_ +#define _MOOF_IMAGE_HH_ + +#include + +#include +#include + + +namespace Mf { + + +class Image : public Resource +{ +public: + + explicit Image(const std::string& name); + + bool isValid() const; + + int getWidth() const; + int getHeight() const; + + unsigned getDepth() const; + unsigned getPitch() const; + GLuint getColorMode() const; + + std::string getComment() const; + + const char* getPixels() const; + char* getPixels(); + + void flip(); + + void setAsIcon() const; + + static std::string getPath(const std::string& name); + +private: + + class Impl; + boost::shared_ptr mImpl; +}; + + +} // namespace Mf + +#endif // _MOOF_IMAGE_HH_ + +/** vim: set ts=4 sw=4 tw=80: *************************************************/ + diff --git a/src/Moof/Log.cc b/src/Moof/Log.cc index 2ea6c57..9809771 100644 --- a/src/Moof/Log.cc +++ b/src/Moof/Log.cc @@ -57,18 +57,17 @@ std::ostream& nullLog(nullLog_); Log logError(Log::ERRORR, " error: "); Log logWarning(Log::WARNING, "warning: "); Log logInfo(Log::INFO, " info: "); -Log logDebug(Log::DEBUGG, " debug: "); -static int logScript_(Script& script) +static int logScript_(Script& script, Log::Level level) { - static Log logScript(Log::SCRIPT, " script: "); + static Log* logs[] = {0, &logError, &logWarning, &logInfo}; Script::Slot param = script[1]; while (!param.isNone()) { - logScript(param); + (*logs[level])(param); ++param.index; } @@ -76,9 +75,12 @@ static int logScript_(Script& script) } -void importLogPrintFunction(Script& script) +void importLogFunctions(Script& script) { - script.importFunction("print", logScript_); + script.importFunction("LogError", boost::bind(logScript_, _1, Log::ERRORR)); + script.importFunction("LogWarning", boost::bind(logScript_, _1, Log::WARNING)); + script.importFunction("LogInfo", boost::bind(logScript_, _1, Log::INFO)); + script.importFunction("print", boost::bind(logScript_, _1, Log::INFO)); } diff --git a/src/Moof/Log.hh b/src/Moof/Log.hh index c7ee507..96585a1 100644 --- a/src/Moof/Log.hh +++ b/src/Moof/Log.hh @@ -64,12 +64,10 @@ public: enum Level { - NONE = -1, ///< Disable all logging. - ERRORR = 1, ///< Log only errors. - WARNING = 2, ///< Log warnings and errors. - SCRIPT = 3, ///< Log messages from Lua, too. - INFO = 4, ///< Log info, warnings, errors. - DEBUGG = 5, ///< Log all messages. + NONE = 0, ///< Disable all logging. + ERRORR = 1, ///< Log only errors. + WARNING = 2, ///< Log warnings and errors. + INFO = 3, ///< Log everything. }; static void setLevel(Level level); @@ -104,7 +102,6 @@ extern std::ostream& nullLog; extern Log logError; extern Log logWarning; extern Log logInfo; -extern Log logDebug; template @@ -116,7 +113,7 @@ inline std::ostream& operator << (Log& logObj, const T& item) class Script; -void importLogPrintFunction(Script& script); +void importLogFunctions(Script& script); } // namespace Mf diff --git a/src/Moof/Math.hh b/src/Moof/Math.hh index 05aa9ec..45c6e90 100644 --- a/src/Moof/Math.hh +++ b/src/Moof/Math.hh @@ -102,6 +102,47 @@ inline Vector3 promote(const Vector2& vec, Scalar extra = 0.0) } +template +inline R convert(const P& p) +{ + return R(p); +} + +template <> +inline Vector3 convert(const Vector4& vec) +{ + return Vector3(vec[0], vec[1], vec[2]); +} + +template <> +inline Vector2 convert(const Vector3& vec) +{ + return Vector2(vec[0], vec[1]); +} + +template <> +inline Vector4 convert(const Vector3& vec) +{ + return Vector4(vec[0], vec[1], vec[2], SCALAR(0.0)); +} + +template <> +inline Vector3 convert(const Vector2& vec) +{ + return Vector3(vec[0], vec[1], SCALAR(0.0)); +} + +template +struct cast +{ + cast(const P& p) : param(p) {} + template + operator R() { return convert(param); } +private: + const P& param; +}; + + const Scalar EPSILON = SCALAR(0.000001); diff --git a/src/Moof/ModalDialog.hh b/src/Moof/ModalDialog.hh index 9b3820a..f630cb6 100644 --- a/src/Moof/ModalDialog.hh +++ b/src/Moof/ModalDialog.hh @@ -92,7 +92,26 @@ struct ModalDialog break; } -#if USE_GTK +#if defined(_WIN32) || defined(__WIN32__) + + int iconType; + switch (type) + { + case WARNING: + iconType = MB_ICONWARNING; + break; + case CRITICAL: + iconType = MB_ICONERROR; + break; + default: + iconType = MB_ICONINFORMATION; + break; + } + + MessageBox(0, (text1 + "\n" + text2).c_str(), title.c_str(), + MB_OK | iconType); + +#elif USE_GTK int argc = 0; char** argv; @@ -126,7 +145,7 @@ struct ModalDialog gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); // FIXME - this doesn't seem to actually remove the window from the - // screen when it closes, not sure why... + // screen when it closes #elif USE_QT4 diff --git a/src/Moof/Octree.hh b/src/Moof/Octree.hh index 4657aec..301b420 100644 --- a/src/Moof/Octree.hh +++ b/src/Moof/Octree.hh @@ -79,7 +79,7 @@ class Octree : public Entity void printSize() { - logDebug << "size of node " << objects.size() << std::endl; + logInfo << "size of node " << objects.size() << std::endl; } void getAll(std::list& insertables) const @@ -194,7 +194,7 @@ private: } else { - logDebug("getting all the rest..."); + logInfo("getting all the rest..."); getAll(insertables, node); } } @@ -357,9 +357,9 @@ public: void getNearbyObjects(std::list& insertables, const OctreeInsertable& entity) const { - logDebug("--- GETTING NEARBY"); + logInfo("--- GETTING NEARBY"); getNearbyObjects(insertables, entity, mTree.root()); - logDebug("---"); + logInfo("---"); savedObj = &entity; } }; diff --git a/src/Moof/Ray.hh b/src/Moof/Ray.hh index 23ebd76..5a693d2 100644 --- a/src/Moof/Ray.hh +++ b/src/Moof/Ray.hh @@ -70,6 +70,7 @@ struct Ray : public Drawable void draw(Scalar alpha = 0.0) const { Vector end = point + 1000.0 * direction; + // TODO this is kinda cheesy Mf::Texture::resetBind(); glBegin(GL_LINES); diff --git a/src/Moof/Script.hh b/src/Moof/Script.hh index 05b9da9..9e8827a 100644 --- a/src/Moof/Script.hh +++ b/src/Moof/Script.hh @@ -789,7 +789,7 @@ public: * is any number of return values, depending on the callee). */ - Result call(int nargs, int nresults = LUA_MULTRET) + Result call(int nargs = 0, int nresults = LUA_MULTRET) { return (Result)lua_pcall(mState, nargs, nresults, 0); } @@ -916,8 +916,7 @@ inline std::ostream& operator << (std::ostream& stream, } else { - stream << slot.getTypeName() - << " (" << slot.getIdentifier() << ")" << std::endl; + stream << slot.getTypeName() << " (" << slot.getIdentifier() << ")"; } return stream; diff --git a/src/Moof/Settings.cc b/src/Moof/Settings.cc index c5c3734..9f0538b 100644 --- a/src/Moof/Settings.cc +++ b/src/Moof/Settings.cc @@ -88,7 +88,7 @@ void Settings::loadFromFiles(const std::vector& filePaths) { std::string str; mScript[-1].get(str); - logInfo(str); + logWarning(str); mScript.clear(); } } diff --git a/src/Moof/Settings.hh b/src/Moof/Settings.hh index 2a2a926..d31b57d 100644 --- a/src/Moof/Settings.hh +++ b/src/Moof/Settings.hh @@ -50,12 +50,10 @@ class Settings { public: - Settings() : - mGlobals(mScript.getGlobalTable()), - mTop(mScript[-1]) + Settings() { mScript.importBaseLibrary(); - importLogPrintFunction(mScript); + importLogFunctions(mScript); } ~Settings(); @@ -79,7 +77,6 @@ public: private: Script mScript; - Script::Slot mGlobals, mTop; std::string mUserFile; }; @@ -88,17 +85,20 @@ private: template bool Settings::get(const std::string& key, T& value) { + Script::Slot top = mScript[-1]; + Script::Slot globals = mScript.getGlobalTable(); + std::vector fields; boost::split(fields, key, boost::is_any_of(".")); - mGlobals.pushCopy(); + globals.pushCopy(); std::vector::iterator it; for (it = fields.begin(); it != fields.end(); ++it) { - if (mTop.isTable()) + if (top.isTable()) { - mTop.pushField(*it); + top.pushField(*it); } else { @@ -107,7 +107,7 @@ bool Settings::get(const std::string& key, T& value) } } - bool got = mTop.get(value); + bool got = top.get(value); mScript.clear(); return got; } diff --git a/src/Moof/Texture.cc b/src/Moof/Texture.cc index 61cabd2..22d3f15 100644 --- a/src/Moof/Texture.cc +++ b/src/Moof/Texture.cc @@ -26,16 +26,15 @@ *******************************************************************************/ -#include // memcpy +#include // FILE +#include // strncmp #include -#include -#include - #include "Dispatch.hh" #include "Engine.hh" #include "Exception.hh" +#include "Image.hh" #include "Library.hh" #include "Log.hh" #include "OpenGL.hh" @@ -50,8 +49,8 @@ namespace Mf { * which is worth having in memory. The image data itself is not worth keeping * in memory if the texture has been loaded to GL, but the name of the resource * is retained so that it can be reloaded if necessary. The implementation is a - * mippleton so that multiple texture objects can share the same internal - * objects and avoid having duplicate textures loaded to GL. + * library so that multiple texture objects can share the same internal objects + * and avoid having duplicate textures loaded to GL. */ class Texture::Impl : public Library @@ -103,29 +102,6 @@ class Texture::Impl : public Library return value; } - - static void flipSurface(SDL_Surface* image) - { - unsigned char* pixels = (Uint8*)(image->pixels); - - unsigned pitch = image->pitch; - unsigned char line[pitch]; - - int yBegin = 0; - int yEnd = image->h - 1; - - if (SDL_MUSTLOCK(image)) SDL_LockSurface(image); - while (yBegin < yEnd) - { - memcpy(line, pixels + pitch * yBegin, pitch); - memcpy(pixels + pitch * yBegin, pixels + pitch * yEnd, pitch); - memcpy(pixels + pitch * yEnd, line, pitch); - yBegin++; - yEnd--; - } - if (SDL_MUSTLOCK(image)) SDL_UnlockSurface(image); - } - public: /** @@ -134,7 +110,8 @@ public: explicit Impl(const std::string& name) : Library(name), - mContext(0), + //mContext(0), + mImage(Texture::getPath(getName())), mWidth(0), mHeight(0), mMode(0), @@ -158,11 +135,6 @@ public: ~Impl() { - if (mContext) - { - SDL_FreeSurface(mContext); - } - unloadFromGL(); } @@ -174,6 +146,7 @@ public: * method makes them ready. */ + /* static SDL_Surface* prepareImageForGL(SDL_Surface* surface) { int w = powerOfTwo(surface->w); @@ -234,6 +207,7 @@ public: return image; } + */ /** * Use SDL_image to load images from file. A surface with the image data is @@ -243,42 +217,17 @@ public: void loadFromFile() { - SDL_Surface* surface; - - surface = IMG_Load(Texture::getPath(getName()).c_str()); - - if (!surface) + if (!mImage.isValid()) { logWarning << "texture not found: " << getName() << std::endl; - throw Exception(ErrorCode::FILE_NOT_FOUND, getName()); - } - - SDL_Surface* temp = prepareImageForGL(surface); - SDL_FreeSurface(surface); - - if (!temp) - { - throw Exception(ErrorCode::UNKNOWN_IMAGE_FORMAT, getName()); - } - - if (temp->format->BytesPerPixel == 3) - { - mMode = GL_RGB; - } - else if (temp->format->BytesPerPixel == 4) - { - mMode = GL_RGBA; - } - else - { - SDL_FreeSurface(temp); - throw Exception(ErrorCode::UNKNOWN_IMAGE_FORMAT, getName()); + throw Exception(ErrorCode::RESOURCE_NOT_FOUND, getName()); } - mWidth = temp->w; - mHeight = temp->h; + mImage.flip(); - mContext = temp; + mWidth = mImage.getWidth(); + mHeight = mImage.getHeight(); + mMode = mImage.getColorMode(); } @@ -295,7 +244,7 @@ public: return; } - if (!mContext) loadFromFile(); + //if (!mContext) loadFromFile(); glGenTextures(1, &mObject); glBindTexture(GL_TEXTURE_2D, mObject); @@ -307,18 +256,18 @@ public: 0, mMode, //3, - mContext->w, - mContext->h, + mWidth, + mHeight, 0, mMode, GL_UNSIGNED_BYTE, - mContext->pixels + mImage.getPixels() ); setProperties(); - SDL_FreeSurface(mContext); - mContext = 0; + //SDL_FreeSurface(mContext); + //mContext = 0; } @@ -378,7 +327,7 @@ public: } - SDL_Surface* mContext; + Image mImage; unsigned mWidth; ///< Horizontal dimension of the image. unsigned mHeight; ///< Vertical dimension. diff --git a/src/Moof/Transition.hh b/src/Moof/Transition.hh index 07addc3..5f8a248 100644 --- a/src/Moof/Transition.hh +++ b/src/Moof/Transition.hh @@ -121,7 +121,7 @@ public: void draw(Engine& engine, Scalar alpha) const { Scalar a = mInterp.getState(alpha); - logDebug << "transition state: " << a << std::endl; + logInfo << "transition state: " << a << std::endl; //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/src/Moof/Video.cc b/src/Moof/Video.cc index eeec47e..e4579fb 100644 --- a/src/Moof/Video.cc +++ b/src/Moof/Video.cc @@ -26,11 +26,10 @@ *******************************************************************************/ -#include - #include "Dispatch.hh" #include "Engine.hh" #include "Exception.hh" +#include "Image.hh" #include "Log.hh" #include "Settings.hh" #include "Video.hh" @@ -173,12 +172,8 @@ void Video::setIcon() { if (mAttribs.icon != "") { - SDL_Surface* icon = IMG_Load(mAttribs.icon.c_str()); - if (icon) - { - SDL_WM_SetIcon(icon, 0); - SDL_FreeSurface(icon); - } + Image icon(mAttribs.icon); + icon.setAsIcon(); } } diff --git a/src/Scene.cc b/src/Scene.cc index a45b1fb..43bdf02 100644 --- a/src/Scene.cc +++ b/src/Scene.cc @@ -415,7 +415,7 @@ struct Scene::Impl : public Mf::Library Mf::Vector2 tr = Mf::demote(vertices[height][width]); mLines.push_back(Mf::Line<2>(bl, tr)); - Mf::logDebug("new line"); + Mf::logInfo("new line"); } return 0; diff --git a/src/Tilemap.cc b/src/Tilemap.cc index c45d169..dc3785a 100644 --- a/src/Tilemap.cc +++ b/src/Tilemap.cc @@ -66,7 +66,7 @@ struct Tilemap::Impl : public Mf::Library std::string filePath = Tilemap::getPath(getName()); script.importStandardLibraries(); - importLogPrintFunction(script); + importLogFunctions(script); bindScriptConstants(script); if (script.doFile(filePath) != Mf::Script::SUCCESS) diff --git a/tools/unix2dos b/tools/unix2dos index 31fa7c6..3c171e5 100755 --- a/tools/unix2dos +++ b/tools/unix2dos @@ -9,9 +9,9 @@ then sed 's/\r*$/\r/' "$1" >$TMPFILE if [ ! "$2" ]; then - cp -f "$TMPFILE" "$1" + mv -f "$TMPFILE" "$1" else - cp -f "$TMPFILE" "$2" + mv -f "$TMPFILE" "$2" fi rm -f "$TMPFILE" else diff --git a/win32/mkpackage.sh.in b/win32/mkpackage.sh.in index e6dffa2..d3b28ee 100644 --- a/win32/mkpackage.sh.in +++ b/win32/mkpackage.sh.in @@ -6,458 +6,53 @@ # This was blatantly yoinked and adapted from the Wormux Project. # +# Paths +SCRIPT="$PWD/yoink.nsi" +BUILD_DIR="$PWD/build" +ROOT_DIR="$PWD/.." + # Programs MAKENSIS="@MAKENSIS@" STRIP="@STRIP@" - -# Anchor paths -ROOT_DIR="$PWD/.." - -# Stuff -COMPRESSION="/solid lzma" -DEST="tmp-yoink-win32" -SCRIPT="$DEST/yoink.nsi" -OUT_FILE=${1:-yoinksetup-@VERSION@.exe} +UNIX2DOS="$ROOT_DIR/tools/unix2dos" # DLL dependencies -DLLS="SDL SDL_image zlib1 libpng12-0 OpenAL32 libvorbis-0 libogg-0" -DLLS="$DLLS libvorbisfile-3 lua51" +DLLS="libogg-0 libpng-3 libvorbis-0 libvorbisfile-3 lua51 OpenAL32 SDL zlib1" # Prepare -${STRIP:-strip} "$ROOT_DIR/src/yoink.exe" -rm -rf "$DEST" -mkdir -p "$DEST" - - -# -# Set installer definitions and strings. -#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -HKLM_PATH='SOFTWARE\Games\Yoink' -UNINSTALL_KEY='SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Yoink' -APP_PATHS_KEY='SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\yoink.exe' -START_RUN_KEY='SOFTWARE\Microsoft\Windows\CurrentVersion\Run' - - -PROMPT1="Not enough rights to install, aborting. :-(" -PROMPT2="Unable to uninstall the currently installed version of Yoink. The new version will be installed without removing the currently installed version." - -SEC_INSTALL="Install Yoink!" -SEC_INSTALL_DESC="Installs Yoink to your computer." -SEC_UNINSTALL="Uninstall previous version." -SEC_SHORTCUTS="Install Shortcuts." -SEC_SHORTCUTS_DESC="Install shortcuts at various locations." -SEC_SHORTCUT1="Place a shortcut on the desktop." -SEC_SHORTCUT2="Place a shortcut in the start menu." -SEC_SHORTCUT3="Place an uninstall shortcut in the start menu." - -WEBSITE_LINK="Visit the Yoink website" - - -# -# Begin output of installer script. -#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -cat > "$SCRIPT" <