From 6853fdb5e762a838e09f0ec36f5dc779bed31c92 Mon Sep 17 00:00:00 2001 From: nick Date: Sat, 19 Apr 2008 18:04:03 +0000 Subject: [PATCH] Start moving to separate PNG images git-svn-id: http://svn.nickg.me.uk/work/lander@347 a97b1542-0b21-0410-a459-e47997c36f34 --- trunk/Makefile.am | 4 +- trunk/config.rpath | 666 +++++++++++++++++++++++++++++++++++++ trunk/configure.ac | 13 +- trunk/data/Makefile.am | 4 + trunk/data/images/ship.png | Bin 0 -> 586 bytes trunk/po/en_GB.po | 46 +-- trunk/po/lander.pot | 44 +-- trunk/src/Image.cpp | 92 +++++ trunk/src/Image.hpp | 38 +++ trunk/src/Main.cpp | 14 + trunk/src/Makefile.am | 11 +- trunk/src/Menu.cpp | 1 - trunk/src/Menu.hpp | 1 + trunk/src/Platform.hpp | 2 + 14 files changed, 881 insertions(+), 55 deletions(-) create mode 100755 trunk/config.rpath create mode 100644 trunk/data/Makefile.am create mode 100644 trunk/data/images/ship.png create mode 100644 trunk/src/Image.cpp create mode 100644 trunk/src/Image.hpp diff --git a/trunk/Makefile.am b/trunk/Makefile.am index 400032f..ce0e414 100644 --- a/trunk/Makefile.am +++ b/trunk/Makefile.am @@ -1,5 +1,7 @@ -SUBDIRS = po src +SUBDIRS = po data src ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = config.rpath m4/ChangeLog + + diff --git a/trunk/config.rpath b/trunk/config.rpath new file mode 100755 index 0000000..c547c68 --- /dev/null +++ b/trunk/config.rpath @@ -0,0 +1,666 @@ +#! /bin/sh +# Output a system dependent set of variables, describing how to set the +# run time search path of shared libraries in an executable. +# +# Copyright 1996-2007 Free Software Foundation, Inc. +# Taken from GNU libtool, 2001 +# Originally by Gordon Matzigkeit , 1996 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# The first argument passed to this file is the canonical host specification, +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld +# should be set by the caller. +# +# The set of defined variables is at the end of this script. + +# Known limitations: +# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer +# than 256 bytes, otherwise the compiler driver will dump core. The only +# known workaround is to choose shorter directory names for the build +# directory and/or the installation directory. + +# All known linkers require a `.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a +shrext=.so + +host="$1" +host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + +# Code taken from libtool.m4's _LT_CC_BASENAME. + +for cc_temp in $CC""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'` + +# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC. + +wl= +if test "$GCC" = yes; then + wl='-Wl,' +else + case "$host_os" in + aix*) + wl='-Wl,' + ;; + darwin*) + case $cc_basename in + xlc*) + wl='-Wl,' + ;; + esac + ;; + mingw* | cygwin* | pw32* | os2*) + ;; + hpux9* | hpux10* | hpux11*) + wl='-Wl,' + ;; + irix5* | irix6* | nonstopux*) + wl='-Wl,' + ;; + newsos6) + ;; + linux* | k*bsd*-gnu) + case $cc_basename in + icc* | ecc*) + wl='-Wl,' + ;; + pgcc | pgf77 | pgf90) + wl='-Wl,' + ;; + ccc*) + wl='-Wl,' + ;; + como) + wl='-lopt=' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + wl='-Wl,' + ;; + esac + ;; + esac + ;; + osf3* | osf4* | osf5*) + wl='-Wl,' + ;; + rdos*) + ;; + solaris*) + wl='-Wl,' + ;; + sunos4*) + wl='-Qoption ld ' + ;; + sysv4 | sysv4.2uw2* | sysv4.3*) + wl='-Wl,' + ;; + sysv4*MP*) + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + wl='-Wl,' + ;; + unicos*) + wl='-Wl,' + ;; + uts4*) + ;; + esac +fi + +# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS. + +hardcode_libdir_flag_spec= +hardcode_libdir_separator= +hardcode_direct=no +hardcode_minus_L=no + +case "$host_os" in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; +esac + +ld_shlibs=yes +if test "$with_gnu_ld" = yes; then + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + # Unlike libtool, we use -rpath here, not --rpath, since the documented + # option of GNU ld is called -rpath, not --rpath. + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + case "$host_os" in + aix3* | aix4* | aix5*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs=no + fi + ;; + amigaos*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we cannot use + # them. + ld_shlibs=no + ;; + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + cygwin* | mingw* | pw32*) + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + interix[3-9]*) + hardcode_direct=no + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + gnu* | linux* | k*bsd*-gnu) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + netbsd*) + ;; + solaris*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs=no + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' + else + ld_shlibs=no + fi + ;; + esac + ;; + sunos4*) + hardcode_direct=yes + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + esac + if test "$ld_shlibs" = no; then + hardcode_libdir_flag_spec= + fi +else + case "$host_os" in + aix3*) + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$GCC" = yes; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + else + aix_use_runtimelinking=no + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix5*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + fi + hardcode_direct=yes + hardcode_libdir_separator=':' + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + hardcode_direct=unsupported + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + ;; + esac + fi + # Begin _LT_AC_SYS_LIBPATH_AIX. + echo 'int main () { return 0; }' > conftest.c + ${CC} ${LDFLAGS} conftest.c -o conftest + aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` + if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` + fi + if test -z "$aix_libpath"; then + aix_libpath="/usr/lib:/lib" + fi + rm -f conftest.c conftest + # End _LT_AC_SYS_LIBPATH_AIX. + if test "$aix_use_runtimelinking" = yes; then + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + else + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + fi + fi + ;; + amigaos*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # see comment about different semantics on the GNU ld section + ld_shlibs=no + ;; + bsdi[45]*) + ;; + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + libext=lib + ;; + darwin* | rhapsody*) + hardcode_direct=no + if test "$GCC" = yes ; then + : + else + case $cc_basename in + xlc*) + ;; + *) + ld_shlibs=no + ;; + esac + fi + ;; + dgux*) + hardcode_libdir_flag_spec='-L$libdir' + ;; + freebsd1*) + ld_shlibs=no + ;; + freebsd2.2*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + freebsd2*) + hardcode_direct=yes + hardcode_minus_L=yes + ;; + freebsd* | dragonfly*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + hpux9*) + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + hpux10*) + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + fi + ;; + hpux11*) + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + case $host_cpu in + hppa*64*|ia64*) + hardcode_direct=no + ;; + *) + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + irix5* | irix6* | nonstopux*) + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + netbsd*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + newsos6) + hardcode_direct=yes + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + openbsd*) + if test -f /usr/libexec/ld.so; then + hardcode_direct=yes + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + else + case "$host_os" in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi + else + ld_shlibs=no + fi + ;; + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + osf3*) + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + osf4* | osf5*) + if test "$GCC" = yes; then + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + # Both cc and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + hardcode_libdir_separator=: + ;; + solaris*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + sunos4*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + ;; + sysv4) + case $host_vendor in + sni) + hardcode_direct=yes # is this really true??? + ;; + siemens) + hardcode_direct=no + ;; + motorola) + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + ;; + sysv4.3*) + ;; + sysv4*MP*) + if test -d /usr/nec; then + ld_shlibs=yes + fi + ;; + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + ;; + sysv5* | sco3.2v5* | sco5v6*) + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + hardcode_libdir_separator=':' + ;; + uts4*) + hardcode_libdir_flag_spec='-L$libdir' + ;; + *) + ld_shlibs=no + ;; + esac +fi + +# Check dynamic linker characteristics +# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER. +# Unlike libtool.m4, here we don't care about _all_ names of the library, but +# only about the one the linker finds when passed -lNAME. This is the last +# element of library_names_spec in libtool.m4, or possibly two of them if the +# linker has special search rules. +library_names_spec= # the last element of library_names_spec in libtool.m4 +libname_spec='lib$name' +case "$host_os" in + aix3*) + library_names_spec='$libname.a' + ;; + aix4* | aix5*) + library_names_spec='$libname$shrext' + ;; + amigaos*) + library_names_spec='$libname.a' + ;; + beos*) + library_names_spec='$libname$shrext' + ;; + bsdi[45]*) + library_names_spec='$libname$shrext' + ;; + cygwin* | mingw* | pw32*) + shrext=.dll + library_names_spec='$libname.dll.a $libname.lib' + ;; + darwin* | rhapsody*) + shrext=.dylib + library_names_spec='$libname$shrext' + ;; + dgux*) + library_names_spec='$libname$shrext' + ;; + freebsd1*) + ;; + freebsd* | dragonfly*) + case "$host_os" in + freebsd[123]*) + library_names_spec='$libname$shrext$versuffix' ;; + *) + library_names_spec='$libname$shrext' ;; + esac + ;; + gnu*) + library_names_spec='$libname$shrext' + ;; + hpux9* | hpux10* | hpux11*) + case $host_cpu in + ia64*) + shrext=.so + ;; + hppa*64*) + shrext=.sl + ;; + *) + shrext=.sl + ;; + esac + library_names_spec='$libname$shrext' + ;; + interix[3-9]*) + library_names_spec='$libname$shrext' + ;; + irix5* | irix6* | nonstopux*) + library_names_spec='$libname$shrext' + case "$host_os" in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;; + *) libsuff= shlibsuff= ;; + esac + ;; + esac + ;; + linux*oldld* | linux*aout* | linux*coff*) + ;; + linux* | k*bsd*-gnu) + library_names_spec='$libname$shrext' + ;; + knetbsd*-gnu) + library_names_spec='$libname$shrext' + ;; + netbsd*) + library_names_spec='$libname$shrext' + ;; + newsos6) + library_names_spec='$libname$shrext' + ;; + nto-qnx*) + library_names_spec='$libname$shrext' + ;; + openbsd*) + library_names_spec='$libname$shrext$versuffix' + ;; + os2*) + libname_spec='$name' + shrext=.dll + library_names_spec='$libname.a' + ;; + osf3* | osf4* | osf5*) + library_names_spec='$libname$shrext' + ;; + rdos*) + ;; + solaris*) + library_names_spec='$libname$shrext' + ;; + sunos4*) + library_names_spec='$libname$shrext$versuffix' + ;; + sysv4 | sysv4.3*) + library_names_spec='$libname$shrext' + ;; + sysv4*MP*) + library_names_spec='$libname$shrext' + ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + library_names_spec='$libname$shrext' + ;; + uts4*) + library_names_spec='$libname$shrext' + ;; +esac + +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' +escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"` +shlibext=`echo "$shrext" | sed -e 's,^\.,,'` +escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` +escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` +escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` + +LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FZT01FZU(%pXi00007bV*G`2iOD? z5fc}BO=m#>00GKLL_t(o!_}8NPQ)+}hQBen1YJ%*LqmfUB!q;J5E2K#+tAR^(9o}5}=_-!e&E~^*XyeMv7!RvHyR@^NOGZi<4rvQzZNp4SO8u zGw2Jb0}VYV82qV5;B^2A!!L^ox%b1C^^=-UER{f)$WK_n3A*3o%clWWh(a~KZ_M`s z&xz*IezzPy0BP1xG!YJfv*JF~H#hu`C~$&qm*YpkriJ!45o}T@n&!%N`OSG0dHaI# z0dHHkiLeQ5mE$S-_~_m1DUY0Y<0IwWz>~Vc&Dd1Homf_b&!VCew18zM+v5$la1-}Pk;0U45L=lL9oPC(LRo)sC#jaZL5p zrJ6hENUu_\n" "Language-Team: English (British)\n" @@ -16,10 +16,26 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: src/Main.cpp:103 +#: src/HighScores.cpp:194 +msgid "Press SPACE or FIRE to return" +msgstr "Press SPACE or FIRE to return" + +#: src/HighScores.cpp:209 +msgid "Well done - You got a high score" +msgstr "Well done - You got a high score" + +#: src/HighScores.cpp:219 +msgid "Press ENTER or FIRE to continue" +msgstr "Press ENTER or FIRE to continue" + +#: src/HighScores.cpp:228 #, c-format -msgid "Runtime Error: %s\n" -msgstr "Runtime Error: %s\n" +msgid "Name? %s" +msgstr "Name? %s" + +#: src/Menu.cpp:241 +msgid "LUNAR LANDER" +msgstr "LUNAR LANDER" #: src/Game.cpp:652 msgid "Press SPACE to continue" @@ -47,23 +63,7 @@ msgstr "Game Over" msgid "Paused" msgstr "Paused" -#: src/HighScores.cpp:194 -msgid "Press SPACE or FIRE to return" -msgstr "Press SPACE or FIRE to return" - -#: src/HighScores.cpp:209 -msgid "Well done - You got a high score" -msgstr "Well done - You got a high score" - -#: src/HighScores.cpp:219 -msgid "Press ENTER or FIRE to continue" -msgstr "Press ENTER or FIRE to continue" - -#: src/HighScores.cpp:228 +#: src/Main.cpp:103 #, c-format -msgid "Name? %s" -msgstr "Name? %s" - -#: src/Menu.cpp:241 -msgid "LUNAR LANDER" -msgstr "LUNAR LANDER" +msgid "Runtime Error: %s\n" +msgstr "Runtime Error: %s\n" diff --git a/trunk/po/lander.pot b/trunk/po/lander.pot index daa24ba..fc1d5c1 100644 --- a/trunk/po/lander.pot +++ b/trunk/po/lander.pot @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" +"Project-Id-Version: lander 0.9\n" "Report-Msgid-Bugs-To: nick@cakesniffer.co.uk\n" -"POT-Creation-Date: 2008-04-19 14:59+0100\n" +"POT-Creation-Date: 2008-04-19 17:46+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -16,9 +16,25 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: src/Main.cpp:103 +#: src/HighScores.cpp:194 +msgid "Press SPACE or FIRE to return" +msgstr "" + +#: src/HighScores.cpp:209 +msgid "Well done - You got a high score" +msgstr "" + +#: src/HighScores.cpp:219 +msgid "Press ENTER or FIRE to continue" +msgstr "" + +#: src/HighScores.cpp:228 #, c-format -msgid "Runtime Error: %s\n" +msgid "Name? %s" +msgstr "" + +#: src/Menu.cpp:241 +msgid "LUNAR LANDER" msgstr "" #: src/Game.cpp:652 @@ -47,23 +63,7 @@ msgstr "" msgid "Paused" msgstr "" -#: src/HighScores.cpp:194 -msgid "Press SPACE or FIRE to return" -msgstr "" - -#: src/HighScores.cpp:209 -msgid "Well done - You got a high score" -msgstr "" - -#: src/HighScores.cpp:219 -msgid "Press ENTER or FIRE to continue" -msgstr "" - -#: src/HighScores.cpp:228 +#: src/Main.cpp:103 #, c-format -msgid "Name? %s" -msgstr "" - -#: src/Menu.cpp:241 -msgid "LUNAR LANDER" +msgid "Runtime Error: %s\n" msgstr "" diff --git a/trunk/src/Image.cpp b/trunk/src/Image.cpp new file mode 100644 index 0000000..0e2f77c --- /dev/null +++ b/trunk/src/Image.cpp @@ -0,0 +1,92 @@ +/* Image.cpp -- Wrapper for loading and displaying images + * Copyright (C) 2008 Nick Gasson + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "Image.hpp" + +#include + +Image::Image(const char *file) +{ + SDL_Surface *surface = IMG_Load(LocateResource(file)); + if (NULL == surface) { + ostringstream os; + os << "Failed to load image " << IMG_GetError(); + throw runtime_error(os.str()); + } + + // Load the image into an OpenGL texture + if (surface->w & (surface->w - 1) != 0) + cerr << "Warning: " << file << " width not a power of 2" << endl; + if (surface->h & (surface->h - 1) != 0) + cerr << "Warning: " << file << " height not a power of 2" << endl; + + int ncols = surface->format->BytesPerPixel; + GLenum texture_format; + if (ncols == 4) { + // Contains an alpha channel + if (surface->format->Rmask == 0x000000ff) + texture_format = GL_RGBA; + else + texture_format = GL_BGRA; + } + else if (ncols == 3) { + if (surface->format->Rmask == 0x000000ff) + texture_format = GL_RGB; + else + texture_format = GL_BGR; + } + else { + ostringstream os; + os << "Unsupported image colour format: " << file; + throw runtime_error(os.str()); + } + + width = surface->w; + height = surface->h; + + glGenTextures(1, &texture); + glBindTexture(GL_TEXTURE_2D, texture); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + // Load the surface's data into the texture + glTexImage2D(GL_TEXTURE_2D, 0, ncols, surface->w, surface->h, 0, + texture_format, GL_UNSIGNED_BYTE, surface->pixels); + + SDL_FreeSurface(surface); +} + +Image::~Image() +{ + glDeleteTextures(1, &texture); +} + +void Image::Draw(int x, int y) const +{ + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glBindTexture(GL_TEXTURE_2D, texture); + glLoadIdentity(); + glTranslated((double)(x + width/2), (double)(y + height/2), 0.0); + glBegin(GL_QUADS); + glTexCoord2f(0.0f, 0.0f); glVertex2i(-(width/2), -(height/2)); + glTexCoord2f(0.0f, 1.0f); glVertex2i(-(width/2), height/2); + glTexCoord2f(1.0f, 1.0f); glVertex2i(width/2, height/2); + glTexCoord2f(1.0f, 0.0f); glVertex2i(width/2, -(height/2)); + glEnd(); +} diff --git a/trunk/src/Image.hpp b/trunk/src/Image.hpp new file mode 100644 index 0000000..5bc5a86 --- /dev/null +++ b/trunk/src/Image.hpp @@ -0,0 +1,38 @@ +/* Image.hpp -- Wrapper for loading and displaying images + * Copyright (C) 2008 Nick Gasson + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef INC_IMAGE_HPP +#define INC_IMAGE_HPP + +#include "Platform.hpp" + +class Image { +public: + Image(const char *file); + ~Image(); + + void Draw(int x, int y) const; + + int GetWidth() const { return width; } + int GetHeight() const { return height; } + +private: + GLuint texture; + int width, height; +}; + +#endif diff --git a/trunk/src/Main.cpp b/trunk/src/Main.cpp index 3c7c82d..a6808f3 100644 --- a/trunk/src/Main.cpp +++ b/trunk/src/Main.cpp @@ -106,3 +106,17 @@ int main(int argc, char **argv) return 0; } + +/* + * Find a filename in the installation tree. + */ +const char *LocateResource(const char *file) +{ +#ifdef DATADIR + static char path[PATH_MAX]; + snprintf(path, PATH_MAX, "%s/%s", DATADIR, file); + return path; +#endif + + return file; +} diff --git a/trunk/src/Makefile.am b/trunk/src/Makefile.am index 3b0cd88..e009667 100644 --- a/trunk/src/Makefile.am +++ b/trunk/src/Makefile.am @@ -1,7 +1,6 @@ bin_PROGRAMS = lander -AM_CXXFLAGS=$(LANDER_CFLAGS) $(SDL_CFLAGS) -DLINUX -DUNIX -DSHOW_FPS \ - -DDATADIR=\"$(pkgdatadir)\" +AM_CXXFLAGS=$(LANDER_CFLAGS) $(SDL_CFLAGS) AM_LDFLAGS=$(LANDER_LIBS) $(SDL_LIBS) -lGLU $(LTLIBINTL) lander_SOURCES = Main.cpp Lander.hpp Game.cpp \ Bitmap.cpp Bitmap.hpp FreeType.cpp FreeType.hpp \ @@ -13,9 +12,13 @@ lander_SOURCES = Main.cpp Lander.hpp Game.cpp \ Ship.hpp Ship.cpp Viewport.hpp Viewport.cpp LandingPad.hpp \ LandingPad.cpp Surface.hpp Surface.cpp Mine.hpp Mine.cpp \ ElectricGate.hpp ElectricGate.cpp Key.hpp Key.cpp \ - Mechanics.hpp Mechanics.cpp Geometry.hpp + Mechanics.hpp Mechanics.cpp Geometry.hpp Image.hpp \ + Image.cpp dist_pkgdata_DATA = ../lander.dat ../Default_Font.ttf ../Hollow_Font.ttf localedir = $(datadir)/locale -DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@ \ No newline at end of file + +# Add -DSHOW_FPS here to show FPS in title bar +DEFS = -DLOCALEDIR=\"$(localedir)\" -DLINUX -DUNIX \ + -DDATADIR=\"$(pkgdatadir)\" @DEFS@ \ No newline at end of file diff --git a/trunk/src/Menu.cpp b/trunk/src/Menu.cpp index 023dc5e..da6a459 100644 --- a/trunk/src/Menu.cpp +++ b/trunk/src/Menu.cpp @@ -27,7 +27,6 @@ const int MenuStar::TEXTURE_SIZE(20); extern DataFile *g_pData; -/* Loads menu data */ void MainMenu::Load() { OpenGL &opengl = OpenGL::GetInstance(); diff --git a/trunk/src/Menu.hpp b/trunk/src/Menu.hpp index 5529abf..9351393 100644 --- a/trunk/src/Menu.hpp +++ b/trunk/src/Menu.hpp @@ -22,6 +22,7 @@ #include "ScreenManager.hpp" #include "Mechanics.hpp" +#include "Image.hpp" #define MENU_FADE_SPEED 0.1f #define HINT_DISPLAY_TIME 140 diff --git a/trunk/src/Platform.hpp b/trunk/src/Platform.hpp index 435e2d2..ec234cc 100644 --- a/trunk/src/Platform.hpp +++ b/trunk/src/Platform.hpp @@ -150,4 +150,6 @@ using namespace std; #endif /* #ifdef LANDER_BIG_ENDIAN */ +const char *LocateResource(const char *file); + #endif /* #ifdef INC_PLATFORM_HPP */ -- 2.39.2