dangen-0.5/0000777000175000017500000000000011625724131013424 5ustar00ooharaoohara00000000000000dangen-0.5/README0000644000175000017500000001565011276334227014314 0ustar00ooharaoohara00000000000000dangen --- shoot 'em up game where accurate shooting matters by Oohara Yuuma published by Project Geeste $Id: README,v 1.42 2009/11/10 19:01:43 oohara Exp $ * what is dangen dangen is a shoot 'em up game that attach importance to accuracy of shooting. With the combination of the cursor key and the shot button, you can shoot at your side or even at your back. Get the bonus point by hitting the enemy without a miss. You can choose stages of different difficulty. * how to install dangen See the file INSTALL for information about how to install dangen. In short, install libc, libSDL and libSDL_image, then type 1) ./configure 2) make 3) make install * command line options Your play record is not saved if you use cheat option(s). --free-select Allow you to select any stage. You can select the same stage multiple times if you use this option. This is a cheat option. --full-screen Run the game in the full screen mode. --help Print a help message and exit. --slow Enable the slow mode. If you use this option, you can run the game at the half speed by pressing the s key. Press the s key again to play at the normal speed. This is a cheat option. --version Print version information, license information and the disclaimer, then exit. * key control cursor keys move space shoot (see below) ESC quit p pause/continue A joystick is also available for move and shoot. Note that you must plug the joystick before you invoke dangen. The game is paused if the mouse cursor leaves the window. This prevents you from being killed while you does not have the focus on the window. * how to shoot Just pressing the space key is _NOT_ enough to fire a shot. There are 2 ways to shoot: + By pressing one of the cursor keys while pressing the space key, you can fire a shot in the direction that cursor key indicates. You have 4 alternatives of directions: up, down, left and right. Any input of a diagonal direction is ignored. + If you press the space key and then release it before pressing any cursor key, a shot is fired to the top of the window when the space key is _released_. Your ship can't move while you press the space key. This applies whether a shot has already been fired or not. When your ship fires a shot, it takes a short time to prepare the next shot. It can't shoot while it is purple or while it is rolling. Each time you press the space key, one and only one shot is fired. Once you press the space key, you can't stop shooting. * tap-tap move When your ship begins to move, it takes a very short but non-zero time to reach the top speed. Therefore, you can adjust the position of your ship by hitting the cursor key quickly and repeatedly. * your ship If your ship gets hit by an enemy shot, an enemy ship or any other obstacle, your ship is destroyed. If you have no more ship, you lose the game. The circle at the center is the only weak point of your ship. The rest is safe. You get an additional ship for each 200,000 points. If you clear all of the 5 (not 4) stages, each remaining (unused) ship is worth 30,000 points. * the shot of your ship The shot of your ship consists of two parts: the head and the tail. Only the head of your shot deals damage to enemies. Its tail is just a decoration for your convenience; the tail of your shot turns black if it misses. The shot of your ship deals damage in 2 ways: + If its head hits an enemy directly, it deals 20 damage to that enemy. + If it hits something, it explodes. The explosion deals to each enemy it touches 1 damage per frame. The explosion remains for 30 frames. Therefore, an enemy gets at most 50 damage per shot (20 damage for a direct hit, 30 damage for explosion). The number displayed near an enemy is the hit point of that enemy. * the color of a enemy There are 3 colors of enemies: brown, green and red. Most of the enemies are brown and sometimes change their colors to green. You can get an additional score by destroying enemies when they are green (see below). You can't destroy red enemies. * the boss enemy A boss enemy appears at the end of each stage. If you destroy it, you can go to the next stage. Note that some boss enemies have 2 or more forms and some stages have 2 or more boss enemies. However, you don't have to destroy the boss enemy by yourself to go to the next stage. The boss enemy self-destructs if you survive for a few minutes (don't ask why), and you clear the stage. The window flashes when the boss enemy is dead. A white flash means you killed it. A blue flash means it commited suicide. * the chain bonus You can get an additional score if you destroy green enemies without a miss. This is called the chain bonus. number of chains bonus point 1 1 2 2 3 4 4 8 5 16 6 32 7 64 8 128 9 256 10 512 11+ 1024 The number of chains increases if one of the following happens: + your shot destroys a green enemy + your shot hits a green enemy directly If the direct hit of your shot destroys a green enemy, only 1 is added to the chain count. The number of chains is reset to 0 if one of the following happens: + your shot misses + your ship is destroyed + a boss enemy self-destructs + you clear a stage Note that you don't have to shoot only green enemies to keep the number of chains. If your shot hits something (even if it is a brown enemy or an obstacle), it's enough. * secret stages Usually, you select 4 stages of difficulty [hard] or lower. The game has extra stages for experts: + If you clear a stage with difficulty [normal] or greater, you can select [very hard] stages. + If you clear 4 stages and if at least one of the cleared stages has difficulty [hard] or greater, you can play the [hardest] stage as stage 5. Note that you can't select other stages as stage 5. These restrictions apply to each play. * license See the file LICENSE for information about the license. In short, the license is GPL exactly version 2 or the Artistic License Version 2.0beta5, whichever you like. * contact information Please send bug reports or comments to Oohara Yuuma . Also check the dangen webpage: http://www.interq.or.jp/libra/oohara/dangen/index.html * history The initial version of dangen was released on Thu, 14 Jul 2005. "dangen" is a Japanese word which has two meanings; one is "the source of bullets", the place enemy shots come from; and the other is "assertion", to say plainly and strongly, which is considered rude in Japan. The stage data, "spqr", was dedicated to shinichiro.h , who is famous for his Parliamentary Bullet Dodging System. This was why the stage data was named after the ancient Roman idiom. dangen-0.5/configure.ac0000644000175000017500000000312311624751755015720 0ustar00ooharaoohara00000000000000dnl configure.ac for dangen dnl Process this file with autoconf to produce a configure script. dnl autoconf 2.68 or later is required # $Id: configure.ac,v 1.69 2011/08/23 16:23:09 oohara Exp $ AC_INIT([dangen], [0.5], [oohara@libra.interq.or.jp]) AC_PREREQ([2.68]) AC_REVISION([$Revision: 1.69 $]) AM_INIT_AUTOMAKE([foreign tar-ustar]) AC_CONFIG_SRCDIR([main.c]) dnl don't quote config.h with [] AC_CONFIG_HEADERS(config.h) # Checks for programs. # Makefile.in will use awk AC_PROG_AWK AC_PROG_CC # cpp is required by AC_CHECK_HEADERS AC_PROG_CPP AC_PROG_LN_S AC_PROG_MAKE_SET AC_PROG_RANLIB AM_PROG_LEX AC_PROG_YACC # Checks for libraries. AC_CHECK_LIB([m], [sin]) AC_ARG_WITH([posix], AC_HELP_STRING([--without-posix], [don't use (most of) POSIX features (DANGEROUS)]), , [with_posix=yes]) if test "x$with_posix" = "xno" then AC_DEFINE([NOT_HAVE_POSIX], , [Define if your system does not have POSIX features.]) fi # Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS([stdlib.h]) AC_CHECK_HEADERS([string.h]) AC_CHECK_HEADERS([unistd.h]) AC_CHECK_HEADERS([stddef.h]) AC_CHECK_HEADERS([limits.h]) # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_UID_T AC_STRUCT_TM AC_TYPE_SIZE_T # Checks for library functions. AC_FUNC_MALLOC AC_FUNC_REALLOC AC_CHECK_FUNCS([atexit]) AC_CHECK_FUNCS([sqrt]) AC_CHECK_FUNCS([strdup]) AC_CHECK_FUNCS([memset]) AC_CHECK_FUNCS([strtol]) AC_SUBST([LIBS], ["-lSDL_image `sdl-config --libs` $LIBS"]) AC_CONFIG_FILES([Makefile libtenm/Makefile record/Makefile spqr/Makefile spqr/image/Makefile]) AC_OUTPUT dangen-0.5/aclocal.m40000644000175000017500000010603211624751770015272 0ustar00ooharaoohara00000000000000# generated automatically by aclocal 1.11 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. # 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],, [m4_warning([this file was generated for autoconf 2.68. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # # 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. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.11], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.11])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # 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. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to # `$srcdir', `$srcdir/..', or `$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is `.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 # Free Software Foundation, Inc. # # 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. # serial 9 # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ(2.52)dnl ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 # Free Software Foundation, Inc. # # 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. # serial 10 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "GCJ", or "OBJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl ifelse([$1], CC, [depcc="$CC" am_compiler_list=], [$1], CXX, [depcc="$CXX" am_compiler_list=], [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], UPC, [depcc="$UPC" am_compiler_list=], [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE(dependency-tracking, [ --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # 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. #serial 5 # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each `.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2008, 2009 Free Software Foundation, Inc. # # 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. # serial 16 # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.62])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) AM_MISSING_PROG(AUTOCONF, autoconf) AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) AM_MISSING_PROG(AUTOHEADER, autoheader) AM_MISSING_PROG(MAKEINFO, makeinfo) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AM_PROG_MKDIR_P])dnl # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES(CC)], [define([AC_PROG_CC], defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES(CXX)], [define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES(OBJC)], [define([AC_PROG_OBJC], defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) _AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl dnl The `parallel-tests' driver may need to know about EXEEXT, so add the dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl ]) dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc. # # 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. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST(install_sh)]) # Copyright (C) 2003, 2005 Free Software Foundation, Inc. # # 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. # serial 2 # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005 # Free Software Foundation, Inc. # # 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. # serial 5 # AM_PROG_LEX # ----------- # Autoconf leaves LEX=: if lex or flex can't be found. Change that to a # "missing" invocation, for better error output. AC_DEFUN([AM_PROG_LEX], [AC_PREREQ(2.50)dnl AC_REQUIRE([AM_MISSING_HAS_RUN])dnl AC_REQUIRE([AC_PROG_LEX])dnl if test "$LEX" = :; then LEX=${am_missing_run}flex fi]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. # # 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. # serial 4 # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # 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. # serial 6 # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it supports --run. # If it does, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= AC_MSG_WARN([`missing' script is too old or missing]) fi ]) # Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # # 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. # AM_PROG_MKDIR_P # --------------- # Check for `mkdir -p'. AC_DEFUN([AM_PROG_MKDIR_P], [AC_PREREQ([2.60])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, dnl while keeping a definition of mkdir_p for backward compatibility. dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of dnl Makefile.ins that do not define MKDIR_P, so we do our own dnl adjustment using top_builddir (which is defined more often than dnl MKDIR_P). AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl case $mkdir_p in [[\\/$]]* | ?:[[\\/]]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc. # # 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. # serial 4 # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # ------------------------------ # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), 1)]) # _AM_SET_OPTIONS(OPTIONS) # ---------------------------------- # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # 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. # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 # Free Software Foundation, Inc. # # 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. # serial 5 # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT(yes)]) # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # 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. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor `install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in `make install-strip', and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be `maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006, 2008 Free Software Foundation, Inc. # # 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. # serial 2 # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004, 2005 Free Software Foundation, Inc. # # 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. # serial 2 # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of `v7', `ustar', or `pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. AM_MISSING_PROG([AMTAR], [tar]) m4_if([$1], [v7], [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], [m4_case([$1], [ustar],, [pax],, [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' _am_tools=${am_cv_prog_tar_$1-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and # Solaris sh will not grok spaces in the rhs of `-'. for _am_tool in $_am_tools do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR dangen-0.5/Makefile.am0000644000175000017500000000324311625723573015467 0ustar00ooharaoohara00000000000000## Makefile.am for dangen ## process this file with automake --foreign to generate Makefile.in ## automake version 1.11 is required # $Id: Makefile.am,v 1.97 2011/08/26 14:02:35 oohara Exp $ SUBDIRS = libtenm record spqr bin_PROGRAMS = dangen dangen_SOURCES = background.c \ background.h \ chain.c \ chain.h \ const.h \ esc-ok.c \ esc-ok.h \ info.c \ info.h \ loop.c \ loop.h \ main.c \ option.c \ option.h \ pause.c \ pause.h \ score.c \ score.h \ ship.c \ ship.h \ slow.c \ slow.h \ stage.c \ stage.h \ util.c \ util.h #CC_WARNINGS = -Wall # the overkill warnings # I don't use -Wtraditional because I use string concatenation # use -Wno-long-long because -pedantic implies -Wlong-long CC_WARNINGS = -Wall -Wshadow -Wpointer-arith -Wcast-qual \ -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \ -Wmissing-declarations -Wnested-externs -Winline -pedantic -Wno-long-long # let's hardcode SDL flags here SDL_CFLAGS=`sdl-config --cflags` # sdl-config --libs is added to LIBS in configure # -g -O2 are in CFLAGS by default, don't use @CFLAGS@ here AM_CFLAGS = $(SDL_CFLAGS) $(CC_WARNINGS) AM_CPPFLAGS = -DDATADIR=\"$(datadir)\" \ -DLOCALSTATEDIR=\"$(localstatedir)\" \ -I$(top_srcdir)/libtenm \ -I$(top_srcdir)/record \ -I$(top_srcdir)/spqr # there is no AM_LDADD # don't use $(top_srcdir) here dangen_LDADD = libtenm/libtenm.a \ record/librecord.a \ spqr/libspqr.a man_MANS = dangen.6 EXTRA_DIST = Artistic-2 \ GPL-2 \ LICENSE \ README-ja-utf8 \ README-ja-sjis \ dangen.6 BUILT_SOURCES = README-ja-sjis README-ja-sjis: README-ja-utf8 sed "s/\n/\r\n/g" $< | \ iconv -f UTF-8 -t SJIS -o $@ dangen-0.5/Makefile.in0000644000175000017500000007512611625723743015510 0ustar00ooharaoohara00000000000000# Makefile.in generated by automake 1.11 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # $Id: Makefile.am,v 1.97 2011/08/26 14:02:35 oohara Exp $ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : bin_PROGRAMS = dangen$(EXEEXT) subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(top_srcdir)/configure ChangeLog INSTALL compile depcomp \ install-sh missing mkinstalldirs ylwrap ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man6dir)" PROGRAMS = $(bin_PROGRAMS) am_dangen_OBJECTS = background.$(OBJEXT) chain.$(OBJEXT) \ esc-ok.$(OBJEXT) info.$(OBJEXT) loop.$(OBJEXT) main.$(OBJEXT) \ option.$(OBJEXT) pause.$(OBJEXT) score.$(OBJEXT) \ ship.$(OBJEXT) slow.$(OBJEXT) stage.$(OBJEXT) util.$(OBJEXT) dangen_OBJECTS = $(am_dangen_OBJECTS) dangen_DEPENDENCIES = libtenm/libtenm.a record/librecord.a \ spqr/libspqr.a DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(dangen_SOURCES) DIST_SOURCES = $(dangen_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' man6dir = $(mandir)/man6 NROFF = nroff MANS = $(man_MANS) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir dist dist-all distcheck ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ { test ! -d "$(distdir)" \ || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -fr "$(distdir)"; }; } am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best distuninstallcheck_listfiles = find . -type f -print distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build_alias = @build_alias@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = libtenm record spqr dangen_SOURCES = background.c \ background.h \ chain.c \ chain.h \ const.h \ esc-ok.c \ esc-ok.h \ info.c \ info.h \ loop.c \ loop.h \ main.c \ option.c \ option.h \ pause.c \ pause.h \ score.c \ score.h \ ship.c \ ship.h \ slow.c \ slow.h \ stage.c \ stage.h \ util.c \ util.h #CC_WARNINGS = -Wall # the overkill warnings # I don't use -Wtraditional because I use string concatenation # use -Wno-long-long because -pedantic implies -Wlong-long CC_WARNINGS = -Wall -Wshadow -Wpointer-arith -Wcast-qual \ -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \ -Wmissing-declarations -Wnested-externs -Winline -pedantic -Wno-long-long # let's hardcode SDL flags here SDL_CFLAGS = `sdl-config --cflags` # sdl-config --libs is added to LIBS in configure # -g -O2 are in CFLAGS by default, don't use @CFLAGS@ here AM_CFLAGS = $(SDL_CFLAGS) $(CC_WARNINGS) AM_CPPFLAGS = -DDATADIR=\"$(datadir)\" \ -DLOCALSTATEDIR=\"$(localstatedir)\" \ -I$(top_srcdir)/libtenm \ -I$(top_srcdir)/record \ -I$(top_srcdir)/spqr # there is no AM_LDADD # don't use $(top_srcdir) here dangen_LDADD = libtenm/libtenm.a \ record/librecord.a \ spqr/libspqr.a man_MANS = dangen.6 EXTRA_DIST = Artistic-2 \ GPL-2 \ LICENSE \ README-ja-utf8 \ README-ja-sjis \ dangen.6 BUILT_SOURCES = README-ja-sjis all: $(BUILT_SOURCES) config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: .SUFFIXES: .c .o .obj am--refresh: @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): config.h: stamp-h1 @if test ! -f $@; then \ rm -f stamp-h1; \ $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ else :; fi stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h $(srcdir)/config.h.in: $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p; \ then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) dangen$(EXEEXT): $(dangen_OBJECTS) $(dangen_DEPENDENCIES) @rm -f dangen$(EXEEXT) $(LINK) $(dangen_OBJECTS) $(dangen_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/background.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chain.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/esc-ok.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/info.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loop.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/option.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pause.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/score.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ship.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slow.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stage.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` install-man6: $(man_MANS) @$(NORMAL_INSTALL) test -z "$(man6dir)" || $(MKDIR_P) "$(DESTDIR)$(man6dir)" @list=''; test -n "$(man6dir)" || exit 0; \ { for i in $$list; do echo "$$i"; done; \ l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.6[a-z]*$$/p'; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^6][0-9a-z]*$$,6,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man6dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man6dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man6dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man6dir)" || exit $$?; }; \ done; } uninstall-man6: @$(NORMAL_UNINSTALL) @list=''; test -n "$(man6dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.6[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^6][0-9a-z]*$$,6,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ test -z "$$files" || { \ echo " ( cd '$(DESTDIR)$(man6dir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(man6dir)" && rm -f $$files; } # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @list='$(MANS)'; if test -n "$$list"; then \ list=`for p in $$list; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \ if test -n "$$list" && \ grep 'ab help2man is required to generate this page' $$list >/dev/null; then \ echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \ grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \ echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \ echo " typically \`make maintainer-clean' will remove them" >&2; \ exit 1; \ else :; fi; \ else :; fi $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 $(am__remove_distdir) dist-lzma: distdir tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma $(am__remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz $(am__remove_distdir) dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__remove_distdir) dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__remove_distdir) dist dist-all: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lzma*) \ unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir); chmod a+w $(distdir) mkdir $(distdir)/_build mkdir $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @$(am__cd) '$(distuninstallcheck_dir)' \ && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-recursive all-am: Makefile $(PROGRAMS) $(MANS) config.h installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man6dir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) clean: clean-recursive clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-man install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-binPROGRAMS install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-man6 install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-man uninstall-man: uninstall-man6 .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all check \ ctags-recursive install install-am install-strip \ tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am am--refresh check check-am clean clean-binPROGRAMS \ clean-generic ctags ctags-recursive dist dist-all dist-bzip2 \ dist-gzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \ distcheck distclean distclean-compile distclean-generic \ distclean-hdr distclean-tags distcleancheck distdir \ distuninstallcheck dvi dvi-am html html-am info info-am \ install install-am install-binPROGRAMS install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-man6 install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs installdirs-am \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags tags-recursive uninstall uninstall-am \ uninstall-binPROGRAMS uninstall-man uninstall-man6 README-ja-sjis: README-ja-utf8 sed "s/\n/\r\n/g" $< | \ iconv -f UTF-8 -t SJIS -o $@ # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: dangen-0.5/config.h.in0000644000175000017500000000571211624752005015450 0ustar00ooharaoohara00000000000000/* config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you have the `atexit' function. */ #undef HAVE_ATEXIT /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `m' library (-lm). */ #undef HAVE_LIBM /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H /* Define to 1 if your system has a GNU libc compatible `malloc' function, and to 0 otherwise. */ #undef HAVE_MALLOC /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET /* Define to 1 if your system has a GNU libc compatible `realloc' function, and to 0 otherwise. */ #undef HAVE_REALLOC /* Define to 1 if you have the `sqrt' function. */ #undef HAVE_SQRT /* Define to 1 if you have the header file. */ #undef HAVE_STDDEF_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strtol' function. */ #undef HAVE_STRTOL /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define if your system does not have POSIX features. */ #undef NOT_HAVE_POSIX /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if your declares `struct tm'. */ #undef TM_IN_SYS_TIME /* Version number of package */ #undef VERSION /* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a `char[]'. */ #undef YYTEXT_POINTER /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define to `int' if doesn't define. */ #undef gid_t /* Define to rpl_malloc if the replacement function should be used. */ #undef malloc /* Define to rpl_realloc if the replacement function should be used. */ #undef realloc /* Define to `unsigned int' if does not define. */ #undef size_t /* Define to `int' if doesn't define. */ #undef uid_t dangen-0.5/configure0000755000175000017500000055573411624751771015363 0ustar00ooharaoohara00000000000000#! /bin/sh # From configure.ac Revision: 1.69 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.68 for dangen 0.5. # # Report bugs to . # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software # Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: oohara@libra.interq.or.jp about your system, including $0: any error possibly output before this message. Then $0: install a modern shell, or manually run the script $0: under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='dangen' PACKAGE_TARNAME='dangen' PACKAGE_VERSION='0.5' PACKAGE_STRING='dangen 0.5' PACKAGE_BUGREPORT='oohara@libra.interq.or.jp' PACKAGE_URL='' ac_unique_file="main.c" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS EGREP GREP YFLAGS YACC LEXLIB LEX_OUTPUT_ROOT LEX RANLIB LN_S CPP am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_dependency_tracking with_posix ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP YACC YFLAGS' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures dangen 0.5 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/dangen] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of dangen 0.5:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --without-posix don't use (most of) POSIX features (DANGEROUS) Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor YACC The `Yet Another Compiler Compiler' implementation to use. Defaults to the first program found out of: `bison -y', `byacc', `yacc'. YFLAGS The list of arguments that will be passed by default to $YACC. This script will default YFLAGS to the empty string to avoid a default value of `-d' given by some make applications. Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF dangen configure 0.5 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## ---------------------------------------- ## ## Report this to oohara@libra.interq.or.jp ## ## ---------------------------------------- ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by dangen $as_me 0.5, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu am__api_version='1.11' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } mkdir_p="$MKDIR_P" case $mkdir_p in [\\/$]* | ?:[\\/]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='dangen' VERSION='0.5' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. AMTAR=${AMTAR-"${am_missing_run}tar"} { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to create a ustar tar archive" >&5 $as_echo_n "checking how to create a ustar tar archive... " >&6; } # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar plaintar pax cpio none' _am_tools=${am_cv_prog_tar_ustar-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and # Solaris sh will not grok spaces in the rhs of `-'. for _am_tool in $_am_tools do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do { echo "$as_me:$LINENO: $_am_tar --version" >&5 ($_am_tar --version) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && break done am__tar="$_am_tar --format=ustar -chf - "'"$$tardir"' am__tar_="$_am_tar --format=ustar -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x ustar -w "$$tardir"' am__tar_='pax -L -x ustar -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H ustar -L' am__tar_='find "$tardir" -print | cpio -o -H ustar -L' am__untar='cpio -i -H ustar -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_ustar}" && break # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file { echo "$as_me:$LINENO: tardir=conftest.dir && eval $am__tar_ >conftest.tar" >&5 (tardir=conftest.dir && eval $am__tar_ >conftest.tar) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } rm -rf conftest.dir if test -s conftest.tar; then { echo "$as_me:$LINENO: $am__untar &5 ($am__untar &5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } grep GrepMe conftest.dir/file >/dev/null 2>&1 && break fi done rm -rf conftest.dir if ${am_cv_prog_tar_ustar+:} false; then : $as_echo_n "(cached) " >&6 else am_cv_prog_tar_ustar=$_am_tool fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_tar_ustar" >&5 $as_echo "$am_cv_prog_tar_ustar" >&6; } ac_config_headers="$ac_config_headers config.h" # Checks for programs. # Makefile.in will use awk for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi # cpp is required by AC_CHECK_HEADERS ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi for ac_prog in flex lex do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_LEX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LEX"; then ac_cv_prog_LEX="$LEX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_LEX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LEX=$ac_cv_prog_LEX if test -n "$LEX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LEX" >&5 $as_echo "$LEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$LEX" && break done test -n "$LEX" || LEX=":" if test "x$LEX" != "x:"; then cat >conftest.l <<_ACEOF %% a { ECHO; } b { REJECT; } c { yymore (); } d { yyless (1); } e { yyless (input () != 0); } f { unput (yytext[0]); } . { BEGIN INITIAL; } %% #ifdef YYTEXT_POINTER extern char *yytext; #endif int main (void) { return ! yylex () + ! yywrap (); } _ACEOF { { ac_try="$LEX conftest.l" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$LEX conftest.l") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking lex output file root" >&5 $as_echo_n "checking lex output file root... " >&6; } if ${ac_cv_prog_lex_root+:} false; then : $as_echo_n "(cached) " >&6 else if test -f lex.yy.c; then ac_cv_prog_lex_root=lex.yy elif test -f lexyy.c; then ac_cv_prog_lex_root=lexyy else as_fn_error $? "cannot find output from $LEX; giving up" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_lex_root" >&5 $as_echo "$ac_cv_prog_lex_root" >&6; } LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root if test -z "${LEXLIB+set}"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking lex library" >&5 $as_echo_n "checking lex library... " >&6; } if ${ac_cv_lib_lex+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_LIBS=$LIBS ac_cv_lib_lex='none needed' for ac_lib in '' -lfl -ll; do LIBS="$ac_lib $ac_save_LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ `cat $LEX_OUTPUT_ROOT.c` _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_lex=$ac_lib fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext test "$ac_cv_lib_lex" != 'none needed' && break done LIBS=$ac_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lex" >&5 $as_echo "$ac_cv_lib_lex" >&6; } test "$ac_cv_lib_lex" != 'none needed' && LEXLIB=$ac_cv_lib_lex fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether yytext is a pointer" >&5 $as_echo_n "checking whether yytext is a pointer... " >&6; } if ${ac_cv_prog_lex_yytext_pointer+:} false; then : $as_echo_n "(cached) " >&6 else # POSIX says lex can declare yytext either as a pointer or an array; the # default is implementation-dependent. Figure out which it is, since # not all implementations provide the %pointer and %array declarations. ac_cv_prog_lex_yytext_pointer=no ac_save_LIBS=$LIBS LIBS="$LEXLIB $ac_save_LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define YYTEXT_POINTER 1 `cat $LEX_OUTPUT_ROOT.c` _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_prog_lex_yytext_pointer=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_lex_yytext_pointer" >&5 $as_echo "$ac_cv_prog_lex_yytext_pointer" >&6; } if test $ac_cv_prog_lex_yytext_pointer = yes; then $as_echo "#define YYTEXT_POINTER 1" >>confdefs.h fi rm -f conftest.l $LEX_OUTPUT_ROOT.c fi if test "$LEX" = :; then LEX=${am_missing_run}flex fi for ac_prog in 'bison -y' byacc do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_YACC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$YACC"; then ac_cv_prog_YACC="$YACC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_YACC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi YACC=$ac_cv_prog_YACC if test -n "$YACC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $YACC" >&5 $as_echo "$YACC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$YACC" && break done test -n "$YACC" || YACC="yacc" # Checks for libraries. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sin in -lm" >&5 $as_echo_n "checking for sin in -lm... " >&6; } if ${ac_cv_lib_m_sin+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lm $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char sin (); int main () { return sin (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_m_sin=yes else ac_cv_lib_m_sin=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_sin" >&5 $as_echo "$ac_cv_lib_m_sin" >&6; } if test "x$ac_cv_lib_m_sin" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBM 1 _ACEOF LIBS="-lm $LIBS" fi # Check whether --with-posix was given. if test "${with_posix+set}" = set; then : withval=$with_posix; else with_posix=yes fi if test "x$with_posix" = "xno" then $as_echo "#define NOT_HAVE_POSIX /**/" >>confdefs.h fi # Checks for header files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in stdlib.h do : ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" if test "x$ac_cv_header_stdlib_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDLIB_H 1 _ACEOF fi done for ac_header in string.h do : ac_fn_c_check_header_mongrel "$LINENO" "string.h" "ac_cv_header_string_h" "$ac_includes_default" if test "x$ac_cv_header_string_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRING_H 1 _ACEOF fi done for ac_header in unistd.h do : ac_fn_c_check_header_mongrel "$LINENO" "unistd.h" "ac_cv_header_unistd_h" "$ac_includes_default" if test "x$ac_cv_header_unistd_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_UNISTD_H 1 _ACEOF fi done for ac_header in stddef.h do : ac_fn_c_check_header_mongrel "$LINENO" "stddef.h" "ac_cv_header_stddef_h" "$ac_includes_default" if test "x$ac_cv_header_stddef_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDDEF_H 1 _ACEOF fi done for ac_header in limits.h do : ac_fn_c_check_header_mongrel "$LINENO" "limits.h" "ac_cv_header_limits_h" "$ac_includes_default" if test "x$ac_cv_header_limits_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIMITS_H 1 _ACEOF fi done # Checks for typedefs, structures, and compiler characteristics. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } if ${ac_cv_c_const+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { /* FIXME: Include the comments suggested by Paul. */ #ifndef __cplusplus /* Ultrix mips cc rejects this. */ typedef int charset[2]; const charset cs; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this. */ char *t; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; }; struct s *b; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_const=yes else ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 $as_echo "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then $as_echo "#define const /**/" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uid_t in sys/types.h" >&5 $as_echo_n "checking for uid_t in sys/types.h... " >&6; } if ${ac_cv_type_uid_t+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "uid_t" >/dev/null 2>&1; then : ac_cv_type_uid_t=yes else ac_cv_type_uid_t=no fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_uid_t" >&5 $as_echo "$ac_cv_type_uid_t" >&6; } if test $ac_cv_type_uid_t = no; then $as_echo "#define uid_t int" >>confdefs.h $as_echo "#define gid_t int" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5 $as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; } if ${ac_cv_struct_tm+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { struct tm tm; int *p = &tm.tm_sec; return !p; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_struct_tm=time.h else ac_cv_struct_tm=sys/time.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm" >&5 $as_echo "$ac_cv_struct_tm" >&6; } if test $ac_cv_struct_tm = sys/time.h; then $as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" if test "x$ac_cv_type_size_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi # Checks for library functions. for ac_header in stdlib.h do : ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" if test "x$ac_cv_header_stdlib_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDLIB_H 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5 $as_echo_n "checking for GNU libc compatible malloc... " >&6; } if ${ac_cv_func_malloc_0_nonnull+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_malloc_0_nonnull=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined STDC_HEADERS || defined HAVE_STDLIB_H # include #else char *malloc (); #endif int main () { return ! malloc (0); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_malloc_0_nonnull=yes else ac_cv_func_malloc_0_nonnull=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_malloc_0_nonnull" >&5 $as_echo "$ac_cv_func_malloc_0_nonnull" >&6; } if test $ac_cv_func_malloc_0_nonnull = yes; then : $as_echo "#define HAVE_MALLOC 1" >>confdefs.h else $as_echo "#define HAVE_MALLOC 0" >>confdefs.h case " $LIBOBJS " in *" malloc.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS malloc.$ac_objext" ;; esac $as_echo "#define malloc rpl_malloc" >>confdefs.h fi for ac_header in stdlib.h do : ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" if test "x$ac_cv_header_stdlib_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDLIB_H 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible realloc" >&5 $as_echo_n "checking for GNU libc compatible realloc... " >&6; } if ${ac_cv_func_realloc_0_nonnull+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_realloc_0_nonnull=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined STDC_HEADERS || defined HAVE_STDLIB_H # include #else char *realloc (); #endif int main () { return ! realloc (0, 0); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_realloc_0_nonnull=yes else ac_cv_func_realloc_0_nonnull=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_realloc_0_nonnull" >&5 $as_echo "$ac_cv_func_realloc_0_nonnull" >&6; } if test $ac_cv_func_realloc_0_nonnull = yes; then : $as_echo "#define HAVE_REALLOC 1" >>confdefs.h else $as_echo "#define HAVE_REALLOC 0" >>confdefs.h case " $LIBOBJS " in *" realloc.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS realloc.$ac_objext" ;; esac $as_echo "#define realloc rpl_realloc" >>confdefs.h fi for ac_func in atexit do : ac_fn_c_check_func "$LINENO" "atexit" "ac_cv_func_atexit" if test "x$ac_cv_func_atexit" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ATEXIT 1 _ACEOF fi done for ac_func in sqrt do : ac_fn_c_check_func "$LINENO" "sqrt" "ac_cv_func_sqrt" if test "x$ac_cv_func_sqrt" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SQRT 1 _ACEOF fi done for ac_func in strdup do : ac_fn_c_check_func "$LINENO" "strdup" "ac_cv_func_strdup" if test "x$ac_cv_func_strdup" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRDUP 1 _ACEOF fi done for ac_func in memset do : ac_fn_c_check_func "$LINENO" "memset" "ac_cv_func_memset" if test "x$ac_cv_func_memset" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_MEMSET 1 _ACEOF fi done for ac_func in strtol do : ac_fn_c_check_func "$LINENO" "strtol" "ac_cv_func_strtol" if test "x$ac_cv_func_strtol" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRTOL 1 _ACEOF fi done LIBS="-lSDL_image `sdl-config --libs` $LIBS" ac_config_files="$ac_config_files Makefile libtenm/Makefile record/Makefile spqr/Makefile spqr/image/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by dangen $as_me 0.5, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ dangen config.status 0.5 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "libtenm/Makefile") CONFIG_FILES="$CONFIG_FILES libtenm/Makefile" ;; "record/Makefile") CONFIG_FILES="$CONFIG_FILES record/Makefile" ;; "spqr/Makefile") CONFIG_FILES="$CONFIG_FILES spqr/Makefile" ;; "spqr/image/Makefile") CONFIG_FILES="$CONFIG_FILES spqr/image/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi dangen-0.5/ChangeLog0000644000175000017500000000450411625723726015206 0ustar00ooharaoohara000000000000002011-08-26 Oohara Yuuma * version 0.5 * configure.ac: use AC_DEFINE after AC_ARG_WITH, not in it * configure.ac, Makefile.am, libtenm/Makefile.am, spqr/Makefile.am: add the return value of sdl-config --libs (which usually contains a -l flag) to LIBS, not AM_LDFLAGS * record/Makefile.am, spqr/image/Makefile.am: fixed comment so that Makefile doesn't say "process this file with automake" * record/record_lexical.h, record/record_lexical.l, record/record_parser.y, record/record_io.c: use %option yylineno instead of counting the line number manually * record/record_lexical.h: added yylex_destroy declaration * record/record_lexical.l: added %option no* to fix the -Wunused-function warning * spqr/fragment.c: removed size_fragment from count[] * spqr/net-can-howl.c: a_x, a_y, b_x, b_y in net_can_howl_core_draw() are double, not int * spqr/afterdeath.c, spqr/cat-tail-grep.c, spqr/cat-tail.c, spqr/empty-wind.c, spqr/gosanpachi.c, spqr/hugin.c, spqr/insane-hand.c, spqr/p-can.c, spqr/plan-19.c, spqr/seiron-fake.c, spqr/seiron.c, spqr/stage-title.c, spqr/tenmado.c, spqr/theorem-weapon.c, spqr/w-ko.c, spqr/wall-0.c, spqr/wall-4.c, spqr/wall-13.c: fixed -Wunused-but-set-variable warnings * Makefile.am, libtenm/Makefile.am, record/Makefile.am, spqr/Makefile.am: removed -Wconversion because it is too noisy * Makefile.am, configure.ac: use the tar-ustar option of automake instead of setting AMTAR 2009-11-11 Oohara Yuuma * version 0.4 * libtenm/tenm_timer.c: uses an empty loop for maximum accuracy * README, README-ja-utf8, dangen.6, loop.c, main.c: the "slow" cheating key is changed from CAPS to s (CAPS doesn't work well with my new keyboard) * slow.c, slow.h: new files, supports the new slow key (the s key) 2005-08-14 Oohara Yuuma * version 0.3 * spqr/image/font-mikachan.png: removed because it is derived from the mikachan font, which is not free * Makefile.am: added a note about the version of automake 2005-07-22 Oohara Yuuma * version 0.2 * record/record_data.c: when you beat the high total score, clears old stage score data before updating the play record 2005-07-14 Oohara Yuuma * version 0.1 * initial release dangen-0.5/INSTALL0000644000175000017500000000361110276702736014462 0ustar00ooharaoohara00000000000000how to install dangen $Id: INSTALL,v 1.21 2005/07/11 21:18:58 oohara Exp $ * requirement To compile dangen, you need: 1) a C library (libc) (GNU C Library is known to work) 2) the Simple DirectMedia Layer library (libSDL) 3) SDL_image (libSDL_image) To hack dangen, you also need: 1) autoconf 2) automake 3) flex 4) bison * installation commands dangen follows the standard 3-step installation process, that is: 1) ./configure 2) make 3) make install * ./configure options ** --with --without-posix Don't use _most_ (not all) of the POSIX features, that is: - You must NOT run "make install" --- I don't know where I put necessary files on a non-POSIX system. - Image data are loaded from the directory spqr/image/ in the current directory. - High score data are saved in the directory save/ in the current directory. - The directory where high score data are saved (that is, "save/") is not created by dangen. You must create it manually before invoking dangen. - All install directory options (see below) are ignored. In short, you should invoke dangen as "./dangen" from the top directory of the source tree. DON'T USE THIS OPTION UNLESS YOU KNOW WHAT YOU ARE DOING. dangen is designed for a POSIX system. ** install directories --prefix Everything will be installed here by default. --bindir The executable will be installed in this directory. --datadir The image files (spqr/image/*.png) will be installed in its subdirectory games/dangen/ . --mandir The manpage will be installed in its subdirectory man6/ . The FHS way will be something like: ./configure --prefix=/usr --bindir=/usr/games \ --mandir=/usr/share/man If you have no root privilege and want to install dangen under your home directory, try: ./configure --prefix=/home/oohara/temp/dangen Replace /home/oohara/temp/dangen as appropriate. Note that these directories must be specified in their absolute path. dangen-0.5/compile0000755000175000017500000000576110447342004015003 0ustar00ooharaoohara00000000000000#! /bin/sh # Wrapper for compilers which do not understand `-c -o'. # Copyright 1999, 2000 Free Software Foundation, Inc. # Written by Tom Tromey . # # 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 2, 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, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Usage: # compile PROGRAM [ARGS]... # `-o FOO.o' is removed from the args passed to the actual compile. # Usage statement added by Billy Biggs . if [ -z $1 ]; then echo "Wrapper for compilers which do not understand '-c -o'." echo "usage: compile PROGRAM [ARGS]..." echo "'-o FOO.o' is removed from the args passed to the actual compile." exit 1 fi prog=$1 shift ofile= cfile= args= while test $# -gt 0; do case "$1" in -o) # configure might choose to run compile as `compile cc -o foo foo.c'. # So we do something ugly here. ofile=$2 shift case "$ofile" in *.o | *.obj) ;; *) args="$args -o $ofile" ofile= ;; esac ;; *.c) cfile=$1 args="$args $1" ;; *) args="$args $1" ;; esac shift done if test -z "$ofile" || test -z "$cfile"; then # If no `-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # `.c' file was seen then we are probably linking. That is also # ok. exec "$prog" $args fi # Name of file we expect compiler to create. cofile=`echo $cfile | sed -e 's|^.*/||' -e 's/\.c$/.o/'` # Create the lock directory. # Note: use `[/.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo $cofile | sed -e 's|[/.-]|_|g'`.d while true; do if mkdir $lockdir > /dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir $lockdir; exit 1" 1 2 15 # Run the compile. "$prog" $args status=$? if test -f "$cofile"; then mv "$cofile" "$ofile" fi rmdir $lockdir exit $status dangen-0.5/depcomp0000755000175000017500000003305210447342004014774 0ustar00ooharaoohara00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects # Copyright 1999, 2000, 2003 Free Software Foundation, Inc. # 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 2, 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, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # `libtool' can also be set to `yes' or `no'. if test -z "$depfile"; then base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'` dir=`echo "$object" | sed 's,/.*$,/,'` if test "$dir" = "$object"; then dir= fi # FIXME: should be _deps on DOS. depfile="$dir.deps/$base" fi tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. tr ' ' ' ' < "$tmpdepfile" | ## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as ## well. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like `#:fec' to the end of the # dependency line. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr ' ' ' ' >> $depfile echo >> $depfile # The second pass generates a dummy entry for each header file. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> $depfile else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts `$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` tmpdepfile="$stripped.u" if test "$libtool" = yes; then "$@" -Wc,-M else "$@" -M fi stat=$? if test -f "$tmpdepfile"; then : else stripped=`echo "$stripped" | sed 's,^.*/,,'` tmpdepfile="$stripped.u" fi if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi if test -f "$tmpdepfile"; then outname="$stripped.o" # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; icc) # Intel's C compiler understands `-MD -MF file'. However on # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c # ICC 7.0 will fill foo.d with something like # foo.o: sub/foo.c # foo.o: sub/foo.h # which is wrong. We want: # sub/foo.o: sub/foo.c # sub/foo.o: sub/foo.h # sub/foo.c: # sub/foo.h: # ICC 7.1 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using \ : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in `foo.d' instead, so we check for that too. # Subdirectories are respected. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1="$dir.libs/$base.lo.d" tmpdepfile2="$dir.libs/$base.d" "$@" -Wc,-MD else tmpdepfile1="$dir$base.o.d" tmpdepfile2="$dir$base.d" "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi if test -f "$tmpdepfile1"; then tmpdepfile="$tmpdepfile1" else tmpdepfile="$tmpdepfile2" fi if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test $1 != '--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for `:' # in the target name. This is to cope with DOS-style filenames: # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. "$@" $dashmflag | sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' ' ' < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test $1 != '--mode=compile'; do shift done shift fi # X makedepend shift cleared=no for arg in "$@"; do case $cleared in no) set ""; shift cleared=yes ;; esac case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix="`echo $object | sed 's/^.*\././'`" touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" sed '1,2d' "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test $1 != '--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E | sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o, # because we must use -o when running libtool. "$@" || exit $? IFS=" " for arg do case "$arg" in "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" echo " " >> "$depfile" . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 dangen-0.5/install-sh0000755000175000017500000001572210447342004015427 0ustar00ooharaoohara00000000000000#!/bin/sh # # install - install a program, script, or datafile # # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # 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 # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd=$cpprog shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd=$stripprog shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "$0: no input file specified" >&2 exit 1 else : fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d "$dst" ]; then instcmd=: chmodcmd="" else instcmd=$mkdirprog fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f "$src" ] || [ -d "$src" ] then : else echo "$0: $src does not exist" >&2 exit 1 fi if [ x"$dst" = x ] then echo "$0: no destination specified" >&2 exit 1 else : fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d "$dst" ] then dst=$dst/`basename "$src"` else : fi fi ## this sed command emulates the dirname command dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-$defaultIFS}" oIFS=$IFS # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` IFS=$oIFS pathcomp='' while [ $# -ne 0 ] ; do pathcomp=$pathcomp$1 shift if [ ! -d "$pathcomp" ] ; then $mkdirprog "$pathcomp" else : fi pathcomp=$pathcomp/ done fi if [ x"$dir_arg" != x ] then $doit $instcmd "$dst" && if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename "$dst"` else dstfile=`basename "$dst" $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename "$dst"` else : fi # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up temp files at exit. trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0 trap '(exit $?); exit' 1 2 13 15 # Move or copy the file name to the temp name $doit $instcmd "$src" "$dsttmp" && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi && # Now remove or move aside any old file at destination location. We try this # two ways since rm can't unlink itself on some systems and the destination # file might be busy for other reasons. In this case, the final cleanup # might fail but the new file should still install successfully. { if [ -f "$dstdir/$dstfile" ] then $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null || { echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 (exit 1); exit } else : fi } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" fi && # The final little trick to "correctly" pass the exit status to the exit trap. { (exit 0); exit } dangen-0.5/missing0000755000175000017500000002403210447342004015014 0ustar00ooharaoohara00000000000000#! /bin/sh # Common stub for a few missing GNU programs while installing. # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # 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 2, 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, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi case "$1" in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case "$1" in -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file tar try tar, gnutar, gtar, then tar without non-portable flags yacc create \`y.tab.[ch]', if possible, from existing .[ch]" ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing 0.4 - GNU automake" ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; aclocal*) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case "$f" in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is needed, and you do not seem to have it handy on your system. You might have modified some files without having the proper tools for further handling them. You can get \`$1' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison|yacc) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.h fi ;; esac fi if [ ! -f y.tab.h ]; then echo >y.tab.h fi if [ ! -f y.tab.c ]; then echo 'main() { return 0; }' >y.tab.c fi ;; lex|flex) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if [ ! -f lex.yy.c ]; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` fi if [ -f "$file" ]; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit 1 fi ;; makeinfo) if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then # We have makeinfo, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` fi touch $file ;; tar) shift if test -n "$run"; then echo 1>&2 "ERROR: \`tar' requires --run" exit 1 fi # We have already tried tar in the generic part. # Look for gnutar/gtar before invocation to avoid ugly error # messages. if (gnutar --version > /dev/null 2>&1); then gnutar "$@" && exit 0 fi if (gtar --version > /dev/null 2>&1); then gtar "$@" && exit 0 fi firstarg="$1" if shift; then case "$firstarg" in *o*) firstarg=`echo "$firstarg" | sed s/o//` tar "$firstarg" "$@" && exit 0 ;; esac case "$firstarg" in *h*) firstarg=`echo "$firstarg" | sed s/h//` tar "$firstarg" "$@" && exit 0 ;; esac fi echo 1>&2 "\ WARNING: I can't seem to be able to run \`tar' with the given arguments. You may want to install GNU tar or Free paxutils, or check the command line arguments." exit 1 ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and you do not seem to have it handy on your system. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequisites for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 dangen-0.5/mkinstalldirs0000755000175000017500000000370410447342004016226 0ustar00ooharaoohara00000000000000#! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman # Created: 1993-05-16 # Public domain errstatus=0 dirmode="" usage="\ Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." # process command line arguments while test $# -gt 0 ; do case $1 in -h | --help | --h*) # -h for help echo "$usage" 1>&2 exit 0 ;; -m) # -m PERM arg shift test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } dirmode=$1 shift ;; --) # stop option processing shift break ;; -*) # unknown option echo "$usage" 1>&2 exit 1 ;; *) # first non-opt arg break ;; esac done for file do if test -d "$file"; then shift else break fi done case $# in 0) exit 0 ;; esac case $dirmode in '') if mkdir -p -- . 2>/dev/null; then echo "mkdir -p -- $*" exec mkdir -p -- "$@" fi ;; *) if mkdir -m "$dirmode" -p -- . 2>/dev/null; then echo "mkdir -m $dirmode -p -- $*" exec mkdir -m "$dirmode" -p -- "$@" fi ;; esac for file do set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` shift pathcomp= for d do pathcomp="$pathcomp$d" case $pathcomp in -*) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr else if test ! -z "$dirmode"; then echo "chmod $dirmode $pathcomp" lasterr="" chmod "$dirmode" "$pathcomp" || lasterr=$? if test ! -z "$lasterr"; then errstatus=$lasterr fi fi fi fi pathcomp="$pathcomp/" done done exit $errstatus # Local Variables: # mode: shell-script # sh-indentation: 2 # End: # mkinstalldirs ends here dangen-0.5/ylwrap0000755000175000017500000001404311240463124014661 0ustar00ooharaoohara00000000000000#! /bin/sh # ylwrap - wrapper for lex/yacc invocations. scriptversion=2009-04-28.21; # UTC # Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005, # 2007, 2009 Free Software Foundation, Inc. # # Written by Tom Tromey . # # 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 2, 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 . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . case "$1" in '') echo "$0: No files given. Try \`$0 --help' for more information." 1>&2 exit 1 ;; --basedir) basedir=$2 shift 2 ;; -h|--h*) cat <<\EOF Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]... Wrapper for lex/yacc invocations, renaming files as desired. INPUT is the input file OUTPUT is one file PROG generates DESIRED is the file we actually want instead of OUTPUT PROGRAM is program to run ARGS are passed to PROG Any number of OUTPUT,DESIRED pairs may be used. Report bugs to . EOF exit $? ;; -v|--v*) echo "ylwrap $scriptversion" exit $? ;; esac # The input. input="$1" shift case "$input" in [\\/]* | ?:[\\/]*) # Absolute path; do nothing. ;; *) # Relative path. Make it absolute. input="`pwd`/$input" ;; esac pairlist= while test "$#" -ne 0; do if test "$1" = "--"; then shift break fi pairlist="$pairlist $1" shift done # The program to run. prog="$1" shift # Make any relative path in $prog absolute. case "$prog" in [\\/]* | ?:[\\/]*) ;; *[\\/]*) prog="`pwd`/$prog" ;; esac # FIXME: add hostname here for parallel makes that run commands on # other machines. But that might take us over the 14-char limit. dirname=ylwrap$$ trap "cd '`pwd`'; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15 mkdir $dirname || exit 1 cd $dirname case $# in 0) "$prog" "$input" ;; *) "$prog" "$@" "$input" ;; esac ret=$? if test $ret -eq 0; then set X $pairlist shift first=yes # Since DOS filename conventions don't allow two dots, # the DOS version of Bison writes out y_tab.c instead of y.tab.c # and y_tab.h instead of y.tab.h. Test to see if this is the case. y_tab_nodot="no" if test -f y_tab.c || test -f y_tab.h; then y_tab_nodot="yes" fi # The directory holding the input. input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'` # Quote $INPUT_DIR so we can use it in a regexp. # FIXME: really we should care about more than `.' and `\'. input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'` while test "$#" -ne 0; do from="$1" # Handle y_tab.c and y_tab.h output by DOS if test $y_tab_nodot = "yes"; then if test $from = "y.tab.c"; then from="y_tab.c" else if test $from = "y.tab.h"; then from="y_tab.h" fi fi fi if test -f "$from"; then # If $2 is an absolute path name, then just use that, # otherwise prepend `../'. case "$2" in [\\/]* | ?:[\\/]*) target="$2";; *) target="../$2";; esac # We do not want to overwrite a header file if it hasn't # changed. This avoid useless recompilations. However the # parser itself (the first file) should always be updated, # because it is the destination of the .y.c rule in the # Makefile. Divert the output of all other files to a temporary # file so we can compare them to existing versions. if test $first = no; then realtarget="$target" target="tmp-`echo $target | sed s/.*[\\/]//g`" fi # Edit out `#line' or `#' directives. # # We don't want the resulting debug information to point at # an absolute srcdir; it is better for it to just mention the # .y file with no path. # # We want to use the real output file name, not yy.lex.c for # instance. # # We want the include guards to be adjusted too. FROM=`echo "$from" | sed \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` TARGET=`echo "$2" | sed \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \ -e "s,$FROM,$TARGET," "$from" >"$target" || ret=$? # Check whether header files must be updated. if test $first = no; then if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then echo "$2" is unchanged rm -f "$target" else echo updating "$2" mv -f "$target" "$realtarget" fi fi else # A missing file is only an error for the first file. This # is a blatant hack to let us support using "yacc -d". If -d # is not specified, we don't want an error when the header # file is "missing". if test $first = yes; then ret=1 fi fi shift shift first=no done else ret=$? fi # Remove the directory. cd .. rm -rf $dirname exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: dangen-0.5/background.c0000644000175000017500000000442210276702735015714 0ustar00ooharaoohara00000000000000/* $Id: background.c,v 1.9 2004/08/10 10:43:41 oohara Exp $ */ #include #include "tenm_graphic.h" #include "const.h" #include "background.h" static int background_n = 0; static int background_timer = 0; void set_background(int n) { background_n = n; if (n == 0) background_timer = 0; else background_timer = -20; } int clear_window_with_background(void) { int red; int green; int blue; int red_base; int green_base; int blue_base; if ((background_n == 0) || (background_timer < -20) || (background_timer >= 32)) { background_timer = 0; if (tenm_clear_window(tenm_map_color(DEFAULT_BACKGROUND_RED, DEFAULT_BACKGROUND_GREEN, DEFAULT_BACKGROUND_BLUE))) { fprintf(stderr, "clear_window_with_background: " "tenm_clear_window failed\n"); return 1; } return 0; } switch (background_n) { /* boss destroyed */ case 1: red_base = 255; green_base = 255; blue_base = 255; break; /* boss self-destruction */ case 2: red_base = 160; green_base = 160; blue_base = 255; break; /* boss approaching */ case 3: red_base = 255; green_base = 160; blue_base = 160; break; default: fprintf(stderr, "clear_window_with_background: undefined background_n " "(%d)\n", background_n); red_base = DEFAULT_BACKGROUND_RED; green_base = DEFAULT_BACKGROUND_GREEN; blue_base = DEFAULT_BACKGROUND_BLUE; break; } if (background_timer < 0) { red = red_base; green = green_base; blue = blue_base; } else { red = (DEFAULT_BACKGROUND_RED * background_timer + red_base * (32 - background_timer)) / 32; green = (DEFAULT_BACKGROUND_GREEN * background_timer + green_base * (32 - background_timer)) / 32; blue = (DEFAULT_BACKGROUND_BLUE * background_timer + blue_base * (32 - background_timer)) / 32; } background_timer++; if (background_timer >= 32) { background_n = 0; background_timer = 0; } if (tenm_clear_window(tenm_map_color(red, green, blue))) { fprintf(stderr, "clear_window_with_background: " "tenm_clear_window failed\n"); return 1; } return 0; } dangen-0.5/background.h0000644000175000017500000000035710276702735015724 0ustar00ooharaoohara00000000000000/* $Id: background.h,v 1.1 2003/08/10 15:57:01 oohara Exp $ */ #ifndef __DANGEN_BACKGROUND_H__ #define __DANGEN_BACKGROUND_H__ void set_background(int n); int clear_window_with_background(void); #endif /* not __DANGEN_BACKGROUND_H__ */ dangen-0.5/chain.c0000644000175000017500000000214610276702736014661 0ustar00ooharaoohara00000000000000/* $Id: chain.c,v 1.37 2005/06/30 15:07:06 oohara Exp $ */ #include /* strlen */ #include #include "const.h" #include "util.h" #include "score.h" #include "tenm_math.h" #include "ship.h" #include "chain.h" static int chain = 0; static int add_chain2(int delta); void clear_chain(void) { chain = 0; } int get_chain(void) { return chain; } /* chain handling function for hit() of an enemy * my is the enemy, your is the player shot * this must be called _after_ damage is dealt */ int add_chain(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) return 0; if (your == NULL) return 0; if ((my->hit_point <= 0) || (your->count[0] == 1)) return add_chain2(1); return 0; } /* return the actual chain added to the total */ static int add_chain2(int delta) { int i; /* sanity check */ /* decrease is not allowed --- simply clear it instead */ if (delta <= 0) return 0; for (i = 0; i < delta; i++) { if (chain >= 10) add_score(tenm_pow2(10)); else add_score(tenm_pow2(chain)); chain++; } return delta; } dangen-0.5/chain.h0000644000175000017500000000042210276702736014661 0ustar00ooharaoohara00000000000000/* $Id: chain.h,v 1.14 2005/06/30 15:05:14 oohara Exp $ */ #ifndef __DANGEN_CHAIN_H__ #define __DANGEN_CHAIN_H__ #include "tenm_object.h" void clear_chain(void); int get_chain(void); int add_chain(tenm_object *my, tenm_object *your); #endif /* not __DANGEN_CHAIN_H__ */ dangen-0.5/const.h0000644000175000017500000000145011624673332014724 0ustar00ooharaoohara00000000000000/* $Id: const.h,v 1.33 2011/08/23 09:46:02 oohara Exp $ */ #ifndef __DANGEN_CONST_H__ #define __DANGEN_CONST_H__ #define COPYRIGHT_STRING "Copyright (C) 2005, 2011 Oohara Yuuma" #define WINDOW_WIDTH 640 #define WINDOW_HEIGHT 480 /* attribute * these values must be one of 2^n */ #define ATTR_PLAYER 1 #define ATTR_PLAYER_SHOT 2 /* this object is not killed automatically when the stage target is dead */ #define ATTR_BOSS 4 #define ATTR_ENEMY 8 #define ATTR_ENEMY_SHOT 16 /* "weak" enemy gets hit by it */ #define ATTR_OBSTACLE 32 /* normal enemy shot cannot go through it */ #define ATTR_OPAQUE 64 /* background color */ /* pure white is bad for your eyes */ #define DEFAULT_BACKGROUND_RED 255 #define DEFAULT_BACKGROUND_GREEN 245 #define DEFAULT_BACKGROUND_BLUE 192 #endif /* __DANGEN_CONST_H__ */ dangen-0.5/esc-ok.c0000644000175000017500000000032110276702736014751 0ustar00ooharaoohara00000000000000/* $Id: esc-ok.c,v 1.4 2002/07/13 05:02:11 oohara Exp $ */ #include #include "esc-ok.h" static int esc_ok = 1; void set_esc_ok(int n) { esc_ok = n; } int get_esc_ok(void) { return esc_ok; } dangen-0.5/esc-ok.h0000644000175000017500000000031110276702736014755 0ustar00ooharaoohara00000000000000/* $Id: esc-ok.h,v 1.3 2004/08/16 15:37:32 oohara Exp $ */ #ifndef __DANGEN_ESC_OK_H__ #define __DANGEN_ESC_OK_H__ void set_esc_ok(int n); int get_esc_ok(void); #endif /* not __DANGEN_ESC_OK_H__ */ dangen-0.5/info.c0000644000175000017500000000534610276702736014537 0ustar00ooharaoohara00000000000000/* $Id: info.c,v 1.8 2005/07/02 05:32:28 oohara Exp $ */ #include /* strlen */ #include #include "tenm_object.h" #include "const.h" #include "util.h" #include "score.h" #include "ship.h" #include "chain.h" #include "info.h" static int chain_scroll = 0; static int ship_scroll = 0; static int score_scroll = 0; void clear_chain_scroll(void) { chain_scroll = 0; } /* return 0 on success, 1 on error */ int show_chain(const tenm_object *player) { char temp[16]; int chain; /* sanity check */ chain = get_chain(); if (chain < 0) return 0; /* hide the stat if the game is still on and * if the player is near it */ if ((player != NULL) && (get_ship() >= 0) && (player->x > (double) (WINDOW_WIDTH * 2 / 3)) && (player->y < 60.0)) { if (chain_scroll < 20) chain_scroll += 2; } else { if (chain_scroll > 0) chain_scroll -= 2; } sprintf(temp, "chain %4d", chain); if (draw_string(WINDOW_WIDTH - 100, 10 - chain_scroll, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "show_chain: draw_string failed\n"); return 1; } return 0; } void clear_ship_scroll(void) { ship_scroll = 0; } /* return 0 on success, 1 on error */ int show_ship(const tenm_object *player) { int ship; char temp[16]; /* sanity check */ ship = get_ship(); if (ship < 0) return 0; /* hide the stat if the game is still on and * if the player is near it */ if ((player != NULL) && (get_ship() >= 0) && (player->x > (double) (WINDOW_WIDTH * 2 / 3)) && (player->y > (double) (WINDOW_HEIGHT - 60))) { if (ship_scroll < 20) ship_scroll += 2; } else { if (ship_scroll > 0) ship_scroll -= 2; } sprintf(temp, "ship %3d", ship); if (draw_string(WINDOW_WIDTH - 80, WINDOW_HEIGHT - 10 + ship_scroll, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "show_ship: draw_string failed\n"); return 1; } return 0; } void clear_score_scroll(void) { score_scroll = 0; } /* return 0 on success, 1 on error */ int show_score(const tenm_object *player) { int score; char temp[32]; score = get_score(); /* hide the stat if the game is still on and * if the player is near it */ if ((player != NULL) && (get_ship() >= 0) && (player->x < (double) (WINDOW_WIDTH / 3)) && (player->y > (double) (WINDOW_HEIGHT - 60))) { if (score_scroll < 20) score_scroll += 2; } else { if (score_scroll > 0) score_scroll -= 2; } sprintf(temp, "score %8d", score); if (draw_string(10, WINDOW_HEIGHT - 10 + score_scroll, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "show_score: draw_string failed\n"); return 1; } return 0; } dangen-0.5/info.h0000644000175000017500000000061110276702736014532 0ustar00ooharaoohara00000000000000/* $Id: info.h,v 1.4 2005/06/30 15:10:38 oohara Exp $ */ #ifndef __DANGEN_INFO_H__ #define __DANGEN_INFO_H__ #include "tenm_object.h" void clear_chain_scroll(void); int show_chain(const tenm_object *player); void clear_ship_scroll(void); int show_ship(const tenm_object *player); void clear_score_scroll(void); int show_score(const tenm_object *player); #endif /* not __DANGEN_INFO_H__ */ dangen-0.5/loop.c0000644000175000017500000001356311276333450014547 0ustar00ooharaoohara00000000000000/* $Id: loop.c,v 1.146 2009/11/10 18:55:36 oohara Exp $ */ #include #include "tenm_object.h" #include "tenm_table.h" #include "player.h" #include "tenm_timer.h" #include "tenm_input.h" #include "const.h" #include "tenm_graphic.h" #include "background.h" #include "scheduler.h" #include "score.h" #include "chain.h" #include "stage.h" #include "ship.h" #include "stage-select.h" #include "pause.h" #include "result.h" #include "esc-ok.h" #include "option.h" #include "info.h" #include "record_data.h" #include "record_io.h" #include "slow.h" #include "loop.h" static int main_loop(int tutorial); static void ship_bonus(void); /* static int draw_all_mass(tenm_object *my, int n); */ /* returns 1 if the program should quit, 0 if not */ int game_loop(int tutorial) { int i; int status = 0; game_record *record = NULL; clear_chain(); clear_chain_scroll(); clear_score(); clear_score_scroll(); clear_ship(); clear_ship_scroll(); set_stage_number(1); for (i = 1; i <= 6; i++) { set_stage_id(i, -1); set_stage_name(i, NULL); set_stage_difficulty(i, -1); } record = game_record_load(); if (record == NULL) { fprintf(stderr, "game_loop: game_record_load failed\n"); return 1; } if ((!tutorial) && (!cheating())) increment_play_total(record); while (1 == 1) { if (tutorial) { set_stage_id(get_stage_number(), -1); } else { clear_chain_scroll(); clear_score_scroll(); clear_ship_scroll(); status = stage_select(record); if (status != 0) break; } status = main_loop(tutorial); if ((!cheating()) && (get_stage_id(get_stage_number()) >= 0)) { /* the order does matter here (when you clear this plan first time) */ increment_play_plan(record, get_stage_id(get_stage_number())); game_record_update(record); if (status == 0) increment_clear_plan(record, get_stage_id(get_stage_number())); } if (tutorial) break; if (status != 0) break; add_stage_number(1); if (get_stage_number() >= 6) { ship_bonus(); game_record_update(record); break; } } if (!cheating()) { if (game_record_save(record) != 0) fprintf(stderr, "game_loop: game_record_save failed\n"); } if (record != NULL) game_record_delete(record); record = NULL; if ((!tutorial) && (status != 2)) { if (show_result() != 0) return 1; } if (status == 2) return 1; return 0; } /* return * 0 if the player cleared the stage * 1 if the game or the tutorial is over * 2 if the program should quit * player (arg 1) is freed if and only if the return value is non-zero */ static int main_loop(int tutorial) { int i; int t = 0; int frame_passed = 0; int status = 0; int temp; tenm_object *player = NULL; const option *op = NULL; op = get_option(); if (op == NULL) { fprintf(stderr, "game_loop: get_option failed\n"); return 2; } set_background(0); tenm_table_clear_all(); clear_chain(); player = player_new(tutorial); if (player == NULL) { fprintf(stderr, "game_loop: player_new failed\n"); return 2; } tenm_set_focus_handler((void (*)(int)) pause_by_mouse); clear_pause(); clear_slow(); tenm_timer_reset(); while (1 == 1) { /* quit the program if a SDL_QUIT event happened * (for example, if a SIGINT signal (sent by Ctrl+c) is received) */ if (tenm_event_handle() != 0) { status = 2; break; } /* back to the title if ESC is pressed */ if (tenm_get_key_status() & 32) { if (get_esc_ok()) { set_esc_ok(0); status = 1; break; } } else { set_esc_ok(1); } /* pause */ if (do_pause(tenm_get_key_status() & 64)) { frame_passed++; /* update the "paused" message */ tenm_redraw_window(); /* do_pause() needs this wait */ tenm_wait_next_frame(); continue; } for (i = 1; i <= 30; i++) { if (tenm_table_detect_collision(player) != 0) player = NULL; if (tenm_table_move(player, 30) != 0) player = NULL; } /* scheduler() must be called before tenm_table_do_action() * to clear action_needed flag correctly */ temp = scheduler(tutorial, t); if (tenm_table_do_action(player) != 0) player = NULL; clear_window_with_background(); tenm_table_draw(player); show_score(player); show_ship(player); show_chain(player); /* for those who want to see the world as it is */ /* note that * (1) the player is not in the table * (2) this is slow */ /* tenm_table_apply_all((int (*)(tenm_object *, int)) draw_all_mass, 0); */ tenm_redraw_window(); tenm_wait_next_frame(); /* slow down if CAPS lock is set */ if ((op->slow != 0) && (do_slow(tenm_get_key_status() & 128))) tenm_wait_next_frame(); if (player == NULL) { /* no more life, game over */ status = 1; break; } t++; frame_passed++; if (temp == SCHEDULER_NEXT_STAGE) break; } if (frame_passed > 0) { printf("average fps: %f\n", tenm_calculate_fps(frame_passed)); fflush(stdout); } tenm_table_clear_all(); if (player != NULL) tenm_object_delete(player); return status; } static void ship_bonus(void) { if (get_stage_number() != 6) return; if (get_stage_cleared(6) != 0) return; set_stage_id(6, 0); add_score(get_ship() * 30000); set_stage_cleared(6, 1); } #if 0 static int draw_all_mass(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if (my->mass == NULL) return 0; if (my->attr == 0) return 0; if (tenm_draw_mass(my->mass, tenm_map_color(0, 0, 0)) != 0) { fprintf(stderr, "draw_all_mass: tenm_draw_mass failed (%d)\n", my->table_index); } return 0; } #endif /* 0 */ dangen-0.5/loop.h0000644000175000017500000000026010276702736014550 0ustar00ooharaoohara00000000000000/* $Id: loop.h,v 1.5 2004/07/05 23:43:54 oohara Exp $ */ #ifndef __DANGEN_LOOP_H__ #define __DANGEN_LOOP_H__ int game_loop(int tutorial); #endif /* not __DANGEN_LOOP_H__ */ dangen-0.5/main.c0000644000175000017500000000452211276333017014514 0ustar00ooharaoohara00000000000000/* $Id: main.c,v 1.271 2009/11/10 18:50:55 oohara Exp $ */ #include /* rand, exit */ #include /* time */ #include #include "const.h" #include "tenm_graphic.h" #include "tenm_input.h" #include "tenm_math.h" #include "tenm_table.h" #include "tenm_timer.h" #include "util.h" #include "loop.h" #include "title.h" #include "option.h" #include "background.h" #include "show-record.h" /* note that delay granularity is 10 ms */ #define NUM_WAIT 3 int main(int argc, char *argv[]) { int temp; int choice; const option *op = NULL; int graphic_flag; if (set_option(argc, argv) != 0) { fprintf(stderr, "main: set_option failed\n"); return 1; } op = get_option(); if (op == NULL) { fprintf(stderr, "main: get_option failed\n"); return 1; } if (op->help != 0) { do_help(); return 0; } if (op->version != 0) { do_version(); return 0; } srand((unsigned int) time(NULL)); if (op->full_screen != 0) graphic_flag = TENM_FULLSCREEN; else graphic_flag = 0; tenm_graphic_init(WINDOW_WIDTH, WINDOW_HEIGHT, graphic_flag, "dangen"); set_background(0); clear_window_with_background(); tenm_timer_init(NUM_WAIT); if (tenm_math_init(810, 11) != 0) fprintf(stderr, "main: tenm_math_init failed, continuing (can be slow)\n"); tenm_table_init(256, -1, 1); tenm_set_key(8, TENM_KEY_UP, TENM_KEY_DOWN, TENM_KEY_RIGHT, TENM_KEY_LEFT, TENM_KEY_SPACE, TENM_KEY_ESCAPE, TENM_KEY_p, TENM_KEY_s); temp = tenm_joystick_init(8192); if (temp == TENM_JOYSTICK_INIT_ERROR) { fprintf(stderr, "main: tenm_joystick_init failed\n"); return 1; } else if (temp == TENM_JOYSTICK_INIT_NO_JOYSTICK) { fprintf(stderr, "main: don't worry, just use the keyboard\n"); } else { tenm_joystick_map_axis(TENM_JOYSTICK_UP, TENM_KEY_UP); tenm_joystick_map_axis(TENM_JOYSTICK_DOWN, TENM_KEY_DOWN); tenm_joystick_map_axis(TENM_JOYSTICK_LEFT, TENM_KEY_LEFT); tenm_joystick_map_axis(TENM_JOYSTICK_RIGHT, TENM_KEY_RIGHT); tenm_joystick_map_button(0, TENM_KEY_SPACE); } util_init(WINDOW_WIDTH, WINDOW_HEIGHT); while (1 == 1) { choice = title(); if (choice == 3) break; if (choice == 2) { if (show_record() != 0) break; continue; } if (game_loop(choice) != 0) break; } return 0; } dangen-0.5/option.c0000644000175000017500000000641310276702736015110 0ustar00ooharaoohara00000000000000/* $Id: option.c,v 1.60 2005/07/01 03:23:10 oohara Exp $ */ /* VERSION */ #include #include /* strcmp */ #include /* malloc, atexit */ #include /* COPYRIGHT_STRING */ #include "const.h" #include "option.h" static option *option_pointer = NULL; static void option_quit(void); /* return 0 on success, 1 on error */ int set_option(int argc, char *argv[]) { int i; /* sanity check */ if (argc <= 0) { fprintf(stderr, "set_option: argc is non-positive\n"); return 1; } if (argv == NULL) { fprintf(stderr, "set_option: argv is NULL\n"); return 1; } if (option_pointer != NULL) free(option_pointer); option_pointer = (option *) malloc(sizeof(option)); if (option_pointer == NULL) { fprintf(stderr, "set_option: malloc failed\n"); return 1; } if (atexit(option_quit) != 0) { fprintf(stderr, "set_option: cannot register option_quit to exit\n"); option_quit(); return 1; } option_pointer->free_select = 0; option_pointer->full_screen = 0; option_pointer->help = 0; option_pointer->slow = 0; option_pointer->version = 0; for (i = 1; i < argc; i++) { if (strcmp(argv[i], "--free-select") == 0) { option_pointer->free_select = 1; } else if (strcmp(argv[i], "--full-screen") == 0) { option_pointer->full_screen = 1; } else if (strcmp(argv[i], "--help") == 0) { option_pointer->help = 1; /* ignore the rest */ break; } else if (strcmp(argv[i], "--slow") == 0) { option_pointer->slow = 1; } else if (strcmp(argv[i], "--version") == 0) { option_pointer->version = 1; /* ignore the rest */ break; } else { fprintf(stderr, "set_option: unknown option (arg %d)\n", i); return 1; } } return 0; } /* return 1 (true) or 0 (false) */ int cheating(void) { /* sanity check */ if (option_pointer == NULL) { fprintf(stderr, "cheating: option_pointer is NULL\n"); return 0; } if (option_pointer->free_select != 0) return 1; if (option_pointer->slow != 0) return 1; return 0; } void do_help(void) { printf("Usage: dangen [options]\n" "shoot 'em up game where accurate shooting matters\n" "Options:\n" ); printf(" --free-select allow selecting any stage\n" " --full-screen run the game in the full screen mode\n" " --help print this message\n" ); printf(" --slow enable the slow mode (CAPS lock)\n" ); printf(" --version print version information\n" "\n" "Report bugs to .\n" ); } void do_version(void) { printf("dangen %s\n", VERSION); printf("%s\n", COPYRIGHT_STRING); printf("This program is free software; you can redistribute it and/or\n" "modify it under the terms of either the GNU General Public License\n" "version 2 or the Artistic License Version 2.0beta5.\n"); printf("dangen comes with NO WARRANTY, to the extent permitted by law.\n"); } const option * get_option(void) { return (const option *) option_pointer; } static void option_quit(void) { if (option_pointer != NULL) { free(option_pointer); option_pointer = NULL; } } dangen-0.5/option.h0000644000175000017500000000106510276702736015113 0ustar00ooharaoohara00000000000000/* $Id: option.h,v 1.20 2005/07/01 03:21:16 oohara Exp $ */ #ifndef __DANGEN_OPTION_H__ #define __DANGEN_OPTION_H__ struct _option { /* 1 if set, 0 if unset */ int free_select; /* 1 if set, 0 if unset */ int full_screen; /* 1 if set, 0 if unset */ int help; /* 1 if set, 0 is unset */ int slow; /* 1 if set, 0 if unset */ int version; }; typedef struct _option option; int set_option(int argc, char *argv[]); int cheating(void); void do_help(void); void do_version(void); const option *get_option(void); #endif /* not __DANGEN_OPTION_H__ */ dangen-0.5/pause.c0000644000175000017500000000540010276702736014710 0ustar00ooharaoohara00000000000000/* $Id: pause.c,v 1.22 2004/08/26 16:48:17 oohara Exp $ */ #include /* WINDOW_WIDTH */ #include "const.h" /* draw_string() */ #include "util.h" #include "pause.h" /* 0: the game is going * 1: the game is paused * 2: the game will continue soon */ static int paused = 0; static int paused_modify_ok = 1; static int paused_timer = 0; static int show_pause_message(void); void clear_pause(void) { paused = 0; paused_modify_ok = 1; paused_timer = 0; } /* return 1 if the game is paused, 0 if not */ int do_pause(int pause_key_pressed) { if (pause_key_pressed) { if (paused_modify_ok) { paused_modify_ok = 0; switch (paused) { case 0: paused = 1; paused_timer = 0; if (show_pause_message() != 0) fprintf(stderr, "do_pause: show_pause_message failed\n"); break; case 1: paused = 2; paused_timer = 0; break; case 2: break; default: if (show_pause_message() != 0) fprintf(stderr, "do_pause: undefined paused (%d)\n", paused); break; } } } else { paused_modify_ok = 1; } if (paused == 2) { paused_timer++; if (paused_timer > 30) { paused = 0; paused_timer = 0; } } if (show_pause_message() != 0) fprintf(stderr, "do_pause: show_pause_message failed\n"); if (paused) return 1; return 0; } /* pause the game if the mouse cursor is out of the window * note that moving the mouse cursor into the window does not * continue the game */ void pause_by_mouse(int gain) { if ((gain != 1) && (paused == 0)) { paused = 1; paused_timer = 0; /* don't call show_pause_message() here */ } } /* return 0 on success, 1 on error */ static int show_pause_message(void) { int status = 0; int i; switch (paused) { case 0: return 0; break; case 1: if (draw_string(WINDOW_WIDTH / 2 - 135, WINDOW_HEIGHT - 60, "paused --- press p to continue", 30) != 0) { fprintf(stderr, "show_pause_message: draw_string (case 1) failed\n"); status = 1; } break; case 2: if (draw_string(WINDOW_WIDTH / 2 - 157, WINDOW_HEIGHT - 40, "ready", 5) != 0) { fprintf(stderr, "show_pause_message: draw_string (case 2) failed\n"); status = 1; } for (i = 0; i < paused_timer; i++) if (draw_string(WINDOW_WIDTH / 2 - 112 + i * 9, WINDOW_HEIGHT - 40, ".", 1) != 0) { fprintf(stderr, "show_pause_message: draw_string (dot %d) failed\n", i); status = 1; } break; default: fprintf(stderr, "show_pause_message: undefined paused (%d)\n", paused); status = 1; break; } return status; } dangen-0.5/pause.h0000644000175000017500000000036310276702736014720 0ustar00ooharaoohara00000000000000/* $Id: pause.h,v 1.8 2004/08/16 14:13:48 oohara Exp $ */ #ifndef __DANGEN_PAUSE_H__ #define __DANGEN_PAUSE_H__ void clear_pause(void); int do_pause(int pause_key_pressed); void pause_by_mouse(int gain); #endif /* not __DANGEN_PAUSE_H__ */ dangen-0.5/score.c0000644000175000017500000000444410276702736014715 0ustar00ooharaoohara00000000000000/* $Id: score.c,v 1.35 2005/07/10 04:40:58 oohara Exp $ */ #include /* strlen */ #include #include "util.h" #include "tenm_object.h" #include "const.h" #include "stage.h" #include "ship.h" #include "score.h" #define EXTEND_FIRST 200000 #define EXTEND_LATER_EVERY 200000 static int score = 0; static int stage_score[6]; static int stage_cleared[6]; static int extend_next = EXTEND_FIRST; void clear_score(void) { int i; score = 0; for (i = 0; i < 6; i++) { stage_score[i] = 0; stage_cleared[i] = 0; } extend_next = EXTEND_FIRST; } int get_score(void) { return score; } int get_stage_score(int stage) { /* sanity check */ if ((stage <= 0) || (stage > 6)) { fprintf(stderr, "get_stage_score: strange stage (%d)\n", stage); return 0; } return stage_score[stage - 1]; } int get_stage_cleared(int stage) { /* sanity check */ if ((stage <= 0) || (stage > 6)) { fprintf(stderr, "get_stage_cleared: strange stage (%d)\n", stage); return 0; } return stage_cleared[stage - 1]; } void set_stage_cleared(int stage, int n) { /* sanity check */ if ((stage <= 0) || (stage > 6)) { fprintf(stderr, "set_stage_cleared: strange stage (%d)\n", stage); return; } stage_cleared[stage - 1] = n; } /* return the actual score added to the total */ int add_score(int delta) { if (score + delta < 0) delta = -score; score += delta; if ((get_stage_number() >= 1) && (get_stage_number() <= 6)) stage_score[get_stage_number() - 1] += delta; while (score >= extend_next) { extend_next += EXTEND_LATER_EVERY; /* you don't get an extra ship if you have already * lost the game, if you have cleared the game or * if you are watching the tutorial demo */ if ((get_ship() >= 0) && (get_stage_number() >= 1) && (get_stage_number() <= 5) && (get_stage_id(get_stage_number()) > 0)) add_ship(1); } return delta; } /* return the damege that should be subtracted from * the hit point of the enemy */ int add_damage_score(int hit_point, int damage) { /* sanity check */ if (hit_point <= 0) return 0; if (damage <= 0) return 0; if (hit_point > damage) { add_score(damage); } else { damage = hit_point; add_score(damage - 1); } return damage; } dangen-0.5/score.h0000644000175000017500000000057410276702736014722 0ustar00ooharaoohara00000000000000/* $Id: score.h,v 1.13 2005/06/30 15:11:02 oohara Exp $ */ #ifndef __DANGEN_SCORE_H__ #define __DANGEN_SCORE_H__ void clear_score(void); int get_score(void); int get_stage_score(int stage); int get_stage_cleared(int stage); void set_stage_cleared(int stage, int n); int add_score(int delta); int add_damage_score(int hit_point, int damage); #endif /* not __DANGEN_SCORE_H__ */ dangen-0.5/ship.c0000644000175000017500000000054710276702736014545 0ustar00ooharaoohara00000000000000/* $Id: ship.c,v 1.19 2005/06/30 15:09:26 oohara Exp $ */ #include /* strlen */ #include #include "ship.h" static int ship = 5; void clear_ship(void) { ship = 5; } /* return the new value of ships */ int add_ship(int delta) { ship += delta; if (ship < -1) ship = -1; return ship; } int get_ship(void) { return ship; } dangen-0.5/ship.h0000644000175000017500000000032710276702736014546 0ustar00ooharaoohara00000000000000/* $Id: ship.h,v 1.8 2005/06/30 15:07:50 oohara Exp $ */ #ifndef __DANGEN_SHIP_H__ #define __DANGEN_SHIP_H__ void clear_ship(void); int add_ship(int delta); int get_ship(void); #endif /* not __DANGEN_SHIP_H__ */ dangen-0.5/slow.c0000644000175000017500000000102311276333257014553 0ustar00ooharaoohara00000000000000/* $Id: slow.c,v 1.3 2009/11/10 18:53:35 oohara Exp $ */ #include #include "slow.h" static int slowed = 0; static int slowed_modify_ok = 0; void clear_slow(void) { slowed = 0; slowed_modify_ok = 0; } /* return 1 if the game is slowed, 0 if not */ int do_slow(int slow_key_pressed) { if (slow_key_pressed) { if (slowed_modify_ok) { slowed_modify_ok = 0; if (slowed) slowed = 0; else slowed = 1; } } else { slowed_modify_ok = 1; } return slowed; } dangen-0.5/slow.h0000644000175000017500000000031111276333210014544 0ustar00ooharaoohara00000000000000/* $Id: slow.h,v 1.3 2009/11/10 18:52:56 oohara Exp $ */ #ifndef __DANGEN_SLOW_H__ #define __DANGEN_SLOW_H__ void clear_slow(void); int do_slow(int slow_key_pressed); #endif /* __DANGEN_SLOW_H__ */ dangen-0.5/stage.c0000644000175000017500000000410310276702742014672 0ustar00ooharaoohara00000000000000/* $Id: stage.c,v 1.12 2004/08/16 15:48:09 oohara Exp $ */ #include #include "stage.h" static int current_stage_number = 1; static int current_stage_id[6]; static int current_stage_difficulty[6]; static const char *current_stage_name[6]; void set_stage_number(int n) { current_stage_number = n; } int get_stage_number(void) { return current_stage_number; } /* return the new value of stage_number */ int add_stage_number(int delta) { if (current_stage_number + delta <= 0) { fprintf(stderr, "add_stage_number: trying to let stage_number negative, " "assuming 1 instead\n"); current_stage_number = 1; } else { current_stage_number += delta; } return current_stage_number; } void set_stage_id(int stage, int n) { /* sanity check */ if ((stage < 1) || (stage > 6)) { fprintf(stderr, "set_stage_id: strange stage (%d)\n", stage); return; } current_stage_id[stage - 1] = n; } void set_stage_name(int stage, const char *p) { /* sanity check */ if ((stage < 1) || (stage > 6)) { fprintf(stderr, "set_stage_name: strange stage (%d)\n", stage); return; } current_stage_name[stage - 1] = p; } void set_stage_difficulty(int stage, int n) { /* sanity check */ if ((stage < 1) || (stage > 6)) { fprintf(stderr, "set_stage_difficulty: strange stage (%d)\n", stage); return; } current_stage_difficulty[stage - 1] = n; } int get_stage_id(int stage) { /* sanity check */ if ((stage < 1) || (stage > 6)) { fprintf(stderr, "get_stage_id: strange stage (%d)\n", stage); return -1; } return current_stage_id[stage - 1]; } const char * get_stage_name(int stage) { /* sanity check */ if ((stage < 1) || (stage > 6)) { fprintf(stderr, "get_stage_name: strange stage (%d)\n", stage); return NULL; } return current_stage_name[stage - 1]; } int get_stage_difficulty(int stage) { /* sanity check */ if ((stage < 1) || (stage > 6)) { fprintf(stderr, "get_stage_difficulty: strange stage (%d)\n", stage); return -1; } return current_stage_difficulty[stage - 1]; } dangen-0.5/stage.h0000644000175000017500000000073410276702742014705 0ustar00ooharaoohara00000000000000/* $Id: stage.h,v 1.8 2004/08/15 12:03:59 oohara Exp $ */ #ifndef __DANGEN_STAGE_H__ #define __DANGEN_STAGE_H__ void set_stage_number(int n); int get_stage_number(void); int add_stage_number(int delta); void set_stage_id(int stage, int n); void set_stage_name(int stage, const char *p); void set_stage_difficulty(int stage, int n); int get_stage_id(int stage); const char *get_stage_name(int stage); int get_stage_difficulty(int stage); #endif /* not __DANGEN_STAGE_H__ */ dangen-0.5/util.c0000644000175000017500000002201510276702742014546 0ustar00ooharaoohara00000000000000/* $Id: util.c,v 1.57 2005/07/11 21:23:12 oohara Exp $ */ /* NOT_HAVE_POSIX */ #include #include /* malloc, strtol */ #include /* errno */ #include /* INT_MIN, INT_MAX */ #include #include "tenm_graphic.h" #include "tenm_table.h" #include "tenm_primitive.h" #include "tenm_collision.h" #include "tenm_object.h" #include "tenm_math.h" #include "const.h" #include "explosion.h" #include "util.h" #define NEAR_ZERO 0.0001 #ifdef NOT_HAVE_POSIX #define FONTDIR "spqr/image/" #else /* not NOT_HAVE_POSIX */ #define FONTDIR DATADIR "/games/dangen/image/" #endif static tenm_image *font = NULL; static tenm_primitive *window = NULL; static double window_width = 0.0; static double window_height = 0.0; static char *buffer = NULL; static int buffer_size = 0; static int in_window_point(double x, double y); /* return 0 on success, 1 on error */ int util_init(int width, int height) { font = tenm_load_image(1, FONTDIR "/" "font.png", 1, 95, tenm_map_color(255, 255, 255)); window= (tenm_primitive *) tenm_polygon_new(4, 0.0, 0.0, 0.0, (double) height, (double) width, 0.0, (double) width, (double) height); if (window == NULL) { tenm_image_delete(font); fprintf(stderr, "util_init: tenm_polygon_new failed\n"); return 1; } window_width = width; window_height = height; return 0; } void util_quit(void) { if (font != NULL) { tenm_image_delete(font); font = NULL; } if (window != NULL) { (window->delete)(window); window = NULL; } window_width = 0.0; window_height = 0.0; if (buffer != NULL) { free(buffer); buffer = NULL; } buffer_size = 0; } int draw_string(int x, int y, const char *string, int length) { /* sanity check */ if (font == NULL) return 0; if (string == NULL) return 0; if (length <= 0) return 0; if (tenm_draw_string(x, y, font, string, length) != 0) { fprintf(stderr, "draw_string: tenm_draw_string failed\n"); return 1; } return 0; } int draw_string_int(int x, int y, const int *string, int length) { int i; char *buffer_temp; /* sanity check */ if (font == NULL) return 0; if (string == NULL) return 0; if (length <= 0) return 0; /* don't substitute buffer directly, or you will be in a trouble * if realloc fails (you don't need data in buffer, but you still * need to free buffer in any case) */ if ((buffer == NULL) || (length + 1 > buffer_size)) { if (buffer == NULL) buffer_temp = (char *) malloc(sizeof(char) * (length + 1)); else buffer_temp = (char *) realloc(buffer, sizeof(char) * (length + 1)); if (buffer_temp == NULL) { fprintf(stderr, "draw_string_int: memory allocation to buffer failed\n"); return 1; } buffer = buffer_temp; buffer_size = length + 1; } /* stupid way to get a pointer to char * (char * and int * are incompatible) */ for (i = 0; i < length; i++) buffer[i] = (char) string[i]; buffer[length] = '\0'; if (tenm_draw_string(x, y, font, buffer, length) != 0) { fprintf(stderr, "draw_string_int: tenm_draw_string failed\n"); return 1; } return 0; } /* return 1 (true) or 0 (false) */ int in_window_object(const tenm_object *p) { int i; if (window == NULL) { fprintf(stderr, "in_window_primitive: window is NULL\n"); return 0; } if (p == NULL) { fprintf(stderr, "in_window_primitive: p is NULL\n"); return 0; } if (p->mass == NULL) { fprintf(stderr, "in_window_primitive: p->mass is NULL\n"); return 0; } for (i = 0; i < p->mass->n; i++) if (in_window_primitive(p->mass->p[i])) return 1; return 0; } /* optimized under the assumption that p is usually in the window * return 1 (true) or 0 (false) */ int in_window_primitive(const tenm_primitive *p) { double temp_x; double temp_y; double temp_r; int i; if (window == NULL) { fprintf(stderr, "in_window_primitive: window is NULL\n"); return 0; } if (p == NULL) { fprintf(stderr, "in_window_primitive: p is NULL\n"); return 0; } switch (p->klass) { case TENM_POINT: return in_window_point(((const tenm_point *) p)->x, ((const tenm_point *) p)->y); break; case TENM_CIRCLE: temp_x = ((const tenm_circle *) p)->center->x; temp_y = ((const tenm_circle *) p)->center->y; temp_r = ((const tenm_circle *) p)->r; if ((temp_x + temp_r >= 0.0) && (temp_x - temp_r < window_width) && (temp_y >= 0.0) && (temp_y < window_height)) return 1; if ((temp_y + temp_r >= 0.0) && (temp_y - temp_r < window_height) && (temp_x >= 0.0) && (temp_x < window_width)) return 1; return tenm_collided_primitive(p, window); break; case TENM_SEGMENT: temp_x = ((const tenm_segment *) p)->a->x; temp_y = ((const tenm_segment *) p)->a->y; if (in_window_point(temp_x, temp_y)) return 1; temp_x = ((const tenm_segment *) p)->b->x; temp_y = ((const tenm_segment *) p)->b->y; if (in_window_point(temp_x, temp_y)) return 1; return tenm_collided_primitive(p, window); break; case TENM_POLYGON: for (i = 0; i < ((const tenm_polygon *) p)->n; i++) { temp_x = ((const tenm_polygon *) p)->v[i]->x; temp_y = ((const tenm_polygon *) p)->v[i]->y; if (in_window_point(temp_x, temp_y)) return 1; } return tenm_collided_primitive(p, window); break; default: fprintf(stderr, "primitive_in_window: strange primitive found (%d)\n", p->klass); return 0; break; } /* should not reach here */ return 0; } /* return 1 (true) or 0 (false) */ static int in_window_point(double x, double y) { /* sanity check */ if (window == NULL) { fprintf(stderr, "point_in_window: window is NULL\n"); return 0; } if ((x < 0) || (x >= window_width)) return 0; if ((y < 0) || (y >= window_height)) return 0; return 1; } /* rotate the vector v (arg 2) by theta (arg 3) degree * result (arg 1) and v (arg 2) must be double[2] (you must allocate enough * memory before calling this function) * the result is undefined if result (arg 1) and v (arg 2) overlap */ void vector_rotate(double *result, const double *v, int theta) { /* sanity check */ if (result == NULL) { fprintf(stderr, "vector_rotate: result is NULL\n"); return; } if (v == NULL) { fprintf(stderr, "vector_rotate: v is NULL\n"); return; } result[0] = tenm_cos(theta) * v[0] - tenm_sin(theta) * v[1]; result[1] = tenm_sin(theta) * v[0] + tenm_cos(theta) * v[1]; } /* rotate the vector v (arg 2) to the vector a (arg 4) * by at most theta (arg 3) degree * result (arg 1), v (arg 2) and a(arg 3) must be double[2] * (you must allocate enough memory before calling this function) * the result is undefined if any pair of result (arg 1), v (arg 2) * and a (arg 3) overlap */ void vector_rotate_bounded(double *result, const double *v, const double *a, int theta) { double length_v; double length_a; double dot; double c; double r1[2]; double r2[2]; double dot_r1; double dot_r2; /* sanity check */ if (result == NULL) { fprintf(stderr, "vector_rotate_bounded: result is NULL\n"); return; } if (v == NULL) { fprintf(stderr, "vector_rotate_bounded: v is NULL\n"); return; } if (a == NULL) { fprintf(stderr, "vector_rotate_bounded: a is NULL\n"); return; } if (theta <= 0) { result[0] = v[0]; result[1] = v[1]; return; } length_v = tenm_sqrt((int) (v[0] * v[0] + v[1] * v[1])); length_a = tenm_sqrt((int) (a[0] * a[0] + a[1] * a[1])); if (length_v < NEAR_ZERO) length_v = 1.0; if (length_a < NEAR_ZERO) length_a = 1.0; if (theta >= 180) { result[0] = a[0] * length_v / length_a; result[1] = a[1] * length_v / length_a; return; } dot = v[0] * a[0] + v[1] * a[1]; c = dot / (length_v * length_a); if (c > tenm_cos(theta)) { result[0] = a[0] * length_v / length_a; result[1] = a[1] * length_v / length_a; return; } r1[0] = 0.0; r1[1] = 0.0; vector_rotate(r1, v, theta); r2[0] = 0.0; r2[1] = 0.0; vector_rotate(r2, v, -theta); dot_r1 = r1[0] * a[0] + r1[1] * a[1]; dot_r2 = r2[0] * a[0] + r2[1] * a[1]; if (dot_r1 >= dot_r2) { result[0] = r1[0]; result[1] = r1[1]; return; } result[0] = r2[0]; result[1] = r2[1]; } int delete_enemy_shot(tenm_object *my, int n) { if (my == NULL) return 0; if (!(my->attr & ATTR_ENEMY_SHOT)) return 0; tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 20, my->count[0], 2.0, 8)); return 1; } int delete_enemy(tenm_object *my, int n) { if (my == NULL) return 0; if (my->attr & ATTR_BOSS) return 0; if (!(my->attr & (ATTR_ENEMY | ATTR_OBSTACLE | ATTR_OPAQUE))) return 0; return 1; } dangen-0.5/util.h0000644000175000017500000000137410276702742014560 0ustar00ooharaoohara00000000000000/* $Id: util.h,v 1.22 2005/06/29 05:49:21 oohara Exp $ */ #ifndef __DANGEN_UTIL_H__ #define __DANGEN_UTIL_H__ #include "tenm_object.h" int util_init(int width, int height); void util_quit(void); int draw_string(int x, int y, const char *string, int length); int draw_string_int(int x, int y, const int *string, int length); int in_window_object(const tenm_object *p); int in_window_primitive(const tenm_primitive *p); void vector_rotate(double *result, const double *v, int theta); void vector_rotate_bounded(double *result, const double *v, const double *a, int theta); /* table manipulation function */ int delete_enemy_shot(tenm_object *my, int n); int delete_enemy(tenm_object *my, int n); #endif /* not __DANGEN_UTIL_H__ */ dangen-0.5/Artistic-20000644000175000017500000002505310276702735015300 0ustar00ooharaoohara00000000000000 The Artistic License Version 2.0beta5, October 2001 Copyright (C) 2000, 2001 Larry Wall, Bradley M. Kuhn. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble This copyright license states the terms under which a given free software Package may be copied, modified and/or redistributed, while the Originator(s) maintain some artistic control over the future development of that Package (at least as much artistic control as can be given under copyright law while still making the Package open source and free software). This license is bound by copyright law, and thus it legally applies only to works which the copyright holder has permitted copying, distribution or modification under the terms of the Artistic License, Version 2.0. You are reminded that You are always permitted to make arrangements wholly outside of a given copyright license directly with the copyright holder(s) of a given Package. If the terms of this license impede your ability to make full use of the Package, You are encouraged to contact the copyright holder(s) and seek a different licensing arrangement. Definitions "Package" refers to the collection of files distributed by the Originator(s), and derivatives of that collection of files created through textual modification. "Standard Version" refers to the Package if it has not been modified, or has been modified only in ways suggested by the Originator(s). "Modified Version" refers to the Package, if it has been changed by You via textual modification of the source code, and such changes were not suggested by the Originator(s). "Originator" refers to the author(s) and/or copyright holder(s) of the Standard Version of the Package. "You" and "Your" refers to any person who would like to copy, distribute, or modify the Package. "Distribution Fee" is any fee that You charge for providing a copy of this Package to another party. It does not refer to licensing fees. "Freely Available" means that: (a) no fee is charged for the right to use the item (though a Distribution Fee may be charged). (b) recipients of the item may redistribute it under the same conditions they received it. (c) If the item is a binary, object code, bytecode, the complete corresponding machine-readable source code is included with the item. Permission for Use and Modification Without Redistribution (1) You are permitted to use the Standard Version and create and use Modified Versions for any purpose without restriction, provided that you do not redistribute the Modified Version to others outside of your company or organization. Permissions for Redistribution of the Standard Version (2) You may make available verbatim copies of the source code of the Standard Version of this Package in any medium without restriction, either gratis or for a Distribution Fee, provided that you duplicate all of the original copyright notices and associated disclaimers. At Your discretion, such verbatim copies may or may not include compiled bytecode, object code or binary versions of the corresponding source code in the same medium. (3) You may apply any bug fixes, portability changes, and other modifications made available from any of the Originator(s). The resulting modified Package will still be considered the Standard Version, and may be copied, modified and redistributed under the terms of the original license of the Standard Version as if it were the Standard Version. Permissions for Redistribution of Modified Versions of the Package as Sour= ce (4) You may modify your copy of the source code of this Package in any way and distribute that Modified Version (either gratis or for a Distribution Fee, and with or without a corresponding binary, bytecode or object code version of the Modified Version) provided that You clearly indicate what changes You made to the Package, and provided that You do at least ONE of the following: (a) make the Modified Version available to the Originator(s) of the Standard Version, under the exact license of the Standard Version, so that the Originator(s) may include your modifications into the Standard Version (at their discretion). (b) modify any installation scripts and procedures so that installation of the Modified Version will never conflict with an installation of the Standard Version, include for each program installed by the Modified Version clear documentation describing how it differs from the Standard Version, and rename your Modified Version so that the name is substantially different from the Standard Version. (c) permit and encourage anyone who receives a copy of the Modified Version to make your modifications Freely Available in some specific way. If Your Modified Version is in turn derived from a Modified Version made by a third party, then You are still required to ensure that Your Modified Version complies with the requirements of this license. Permissions for Redistribution of Non-Source Versions of Package (5) You may distribute binary, object code, bytecode or other non-source versions of the Standard Version of the Package, provided that you include complete instructions on where to get the source code of the Standard Version. Such instructions must be valid at the time of Your distribution. If these instructions, at any time while You are carrying our such distribution, become invalid, you must provide new instructions on demand or cease further distribution. If You cease distribution within thirty days after You become aware that the instructions are invalid, then You do not forfeit any of Your rights under this license. (6) You may distribute binary, object code, bytecode or other non-source versions of a Modified Version provided that You do at least ONE of the following: (a) include a copy of the corresponding source code for the Modified Version under the terms indicated in (4). (b) ensure that the installation of Your non-source Modified Version does not conflict in any way with an installation of the Standard Version, include for each program installed by the Modified Version clear documentation describing how it differs from the Standard Version, and rename your Modified Version so that the name is substantially different from the Standard Version. (c) ensure that the Modified Version includes notification of the changes made from the Standard Version, and offer to provide machine-readable source code (under a license that permits making that source code Freely Available) of the Modified Version via mail order. Permissions for Inclusion of the Package in Aggregate Works =20 (7) You may aggregate this Package (either the Standard Version or Modified Version) with other packages and distribute the resulting aggregation provided that You do not charge a licensing fee for the Package. Distribution Fees are permitted, and licensing fees for other packages in the aggregation are permitted. Your permission to distribute Standard or Modified Versions of the Package is still subject to the other terms set forth in other sections of this license. (8) In addition to the permissions given elsewhere by this license, You are also permitted to link Modified and Standard Versions of this Package with other works and distribute the result without restriction, provided You have produced binary program(s) that do not overtly expose the interfaces of the Package. This includes permission to embed the Package in a larger work of your own without exposing a direct interface to the Package. This also includes permission to build stand-alone binary or bytecode versions of your scripts that require the Package, but do not otherwise give the casual user direct access to the Package itself. Items That are Never Considered Part of a Modified Version Package (9) Works (including, but not limited to, subroutines and scripts) that you have linked or aggregated with the Package that merely extend or make use of the Package, but are not intended to cause the Package to operate differently from the Standard Version, do not, by themselves, cause the Package to be a Modified Version. In addition, such works are not considered parts of the Package itself, and are not bound by the terms of the Package's license. Acceptance of License and Disclaimer of Warranty (10) You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to copy, modify or distribute the Standard or Modified Versions of the Package. These actions are prohibited by copyright law if you do not accept this License. Therefore, by copying, modifying or distributing Standard and Modified Versions of the Package, you indicate your acceptance of the license of the Package. (11) Disclaimer of Warranty: 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 UNLESS REQUIRED BY LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER OR CONTRIBUTOR 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, 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. dangen-0.5/GPL-20000644000175000017500000004311010276702736014133 0ustar00ooharaoohara00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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 2 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, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. dangen-0.5/LICENSE0000644000175000017500000000117010276702736014434 0ustar00ooharaoohara00000000000000$Id: LICENSE,v 1.5 2005/07/10 17:41:24 oohara Exp $ dangen --- shoot 'em up game where accurate shooting matters Copyright (C) 2005 Oohara Yuuma This program is free software; you can redistribute it and/or modify it under the terms of either: a) the GNU General Public License version 2 as published by the Free Software Foundation (no other version is allowed), or b) the Artistic License Version 2.0beta5. A copy of the GNU General Public License version 2 is included in the source code as GPL-2. A copy of the Artistic License Version 2.0beta5 is included in the source code as Artistic-2. dangen-0.5/README-ja-utf80000644000175000017500000002206411276334375015571 0ustar00ooharaoohara00000000000000dangen --- 精密射撃重視のシューティングゲーム by 大原雄馬 published by Project Geeste $Id: README-ja-utf8,v 1.36 2009/11/10 19:03:25 oohara Exp $ * dangen とは何か dangen は射撃の正確さを重視するシューティングゲームです。カーソルキーと ショットボタンの組みあわせにより、側面や背後さえも撃つことができます。 外さずに敵を撃つことによりボーナス得点を獲得してください。異なる難易度の ステージを選択することができます。 * dangen のインストール方法 dangen のインストール方法については INSTALL ファイルをごらんください。 要約すると、libc、libSDL および libSDL_image をインストールし、 1) ./configure 2) make 3) make install と入力してください。 * コマンドラインオプション チートオプションを使用するとプレイ記録は保存されません。 --free-select すべてのステージを選択可能にします。このオプションを使用すると同じ ステージを複数回選択できます。これはチートオプションです。 --full-screen ゲームをフルスクリーンモードで実行します。 --help ヘルプメッセージを表示して終了します。 --slow スローモードを有効にします。このオプションを使用すると、s キーを 押すことによりゲームを半分の速度で実行できます。通常の速度で実行するには もう一度 s キーを押します。これはチートオプションです。 --version バージョン情報、ライセンス情報および免責条項を表示して終了します。 * キー操作 カーソルキー 移動 スペース 射撃 (以下参照) ESC 終了 p ポーズ / 再開 ジョイスティックで移動および射撃を行うこともできます。dangen の起動前に ジョイスティックを接続しておく必要があることに注意してください。 マウスカーソルがウィンドウの外に出るとゲームがポーズ状態になります。 これにより、ウインドウにフォーカスがあっていないときに自機が倒されることが 防げます。 * 射撃方法 スペースキーを押すだけでは弾は発射 _されません_。射撃方法は 2 通りあります: + スペースキーを押しながらカーソルキーのどれかを押すことにより、 そのカーソルキーが示す方向に弾を発射することができます。 方向は 4 通りから選べます: 上、下、左、右です。斜め方向への 入力は無視されます。 + スペースキーを押したあとカーソルキーを押さずにスペースキーを 離すと、スペースキーを _離した_ ときに弾が画面上方に向けて 発射されます。 スペースキーを押している間は自機は移動できません。これは弾がすでに 発射されたかどうかにかかわらずあてはまります。 自機は弾を 1 発撃つと、次の弾を用意するのにすこし時間がかかります。 自機が紫色で回転している間は射撃はできません。 スペースキーを 1 回押すたびに、弾はちょうど 1 発だけ発射されます。 いったんスペースキーを押したら、射撃をやめることはできません。 * こんこん移動 自機が動きはじめるとき、最高速に達するにはわずかながら時間がかかります。 したがって、カーソルキーをすばやく連打することにより自機の位置を調節 することができます。 * 自機 自機が敵弾、敵本体または何らかの障害物に接触すると、自機は破壊されます。 残り自機がないならゲームオーバーです。自機中央の円形部分だけが弱点です。 それ以外は安全です。 20 万点ごとに自機が 1 機増えます。全 5 面 (4 面ではありません) をクリア できたら、残っている (未使用の) 自機は各 3 万点になります。 * 自機の弾 自機の弾は 2 つの部分で構成されています: 先端と尾です。自機の弾は 先端だけが敵にダメージを与えます。尾は便利さのための単なる飾りです; 自機の弾が外れると尾が黒くなります。 自機の弾は 2 通りの方法でダメージを与えます: + 敵に直撃した場合、その敵に 20 ダメージを与えます。 + 自機の弾は何かにぶつかると爆発します。その爆風が敵に接触すると 毎フレーム 1 ダメージを与えます。爆風は 30 フレームの間残ります。 したがって、敵は一発あたり最大で 50 ダメージを受けます (直撃で 20 ダメージ、 爆風で 30 ダメージ)。敵のそばに表示される数字がその敵のヒットポイントです。 * 敵の色 敵の色は 3 種類あります: 茶色、緑色そして赤色です。ほとんどの敵は茶色で、 ときどきその色を緑色に変えます。緑色のときに敵を倒すことにより追加の得点を 得ることができます (以下参照)。赤色の敵は破壊できません。 * ボス敵 各ステージの最後にボス敵が出現します。それを倒せば、次のステージへ進む ことができます。2 種類以上の形態を持つボス敵がいること、2 体以上のボス敵が いるステージがあることに注意してください。 しかし、次のステージに進むには自らの手でボス敵を倒さなければならない というわけではありません。数分間生き残ればボス敵は自爆し (理由は聞かないで ください)、ステージクリアとなります。 ボス敵が死ぬと画面が光ります。白く光ったらプレイヤーがボス敵を倒したと いうことです。青く光ったらボス敵が自爆したということです。 * チェーンボーナス 弾を外すことなく緑色の敵を倒すと追加の得点を得ることができます。これを チェーンボーナスといいます。 チェーン数 ボーナス得点 1 1 2 2 3 4 4 8 5 16 6 32 7 64 8 128 9 256 10 512 11+ 1024 以下のいずれかが起きるとチェーン数が増えます: + 自機の弾が緑色の敵を破壊した + 自機の弾が緑色の敵に直撃した 自機の弾が緑色の敵に直撃し、そのダメージでその敵が破壊された場合、 チェーン数は 1 だけ増えます。 以下のいずれかが起きるとチェーン数は 0 に戻ります: + 自機の弾が外れた + 自機が破壊された + ボス敵が自爆した + ステージをクリアした チェーン数を維持するためには緑色の敵だけを撃たなければならないわけでは ないことに注意してください。自機の弾が何か (たとえそれが茶色の敵や 障害物であっても) に当たれば十分です。 * 隠しステージ 普通、プレイヤーは難易度 [hard] 以下のステージから 4 つを選択することに なります。熟練者のためにそれ以外のステージが用意されています: + 難易度 [normal] 以上のステージをクリアすると、難易度 [very hard] の ステージを選べるようになります。 + 4 面をクリアし、かつクリアしたステージのうちすくなくともひとつが 難易度 [hard] 以上ならば、難易度 [hardest] のステージを 5 面として 遊べます。5 面として他のステージを選べないことに注意してください。 これらの制限は各プレイごとに適用されます。 * ライセンス ライセンスについては LICENSE ファイルをごらんください。要約すれば、 ライセンスは GPL exactly version 2 または the Artistic License Version 2.0beta5 のうち、あなたが好きなほうです。 * 連絡先 バグ報告または感想は大原雄馬 へどうぞ。 dangen ウェブページもごらんください: http://www.interq.or.jp/libra/oohara/dangen/index.html * 歴史 dangen の最初のバージョンは 2005年 7 月 14 日 (木) にリリースされました。 dangen はふたつの意味を持つ日本語です; ひとつは「弾源」、敵弾が出現する 場所です; もうひとつは「断言」、きっぱりと言いきることで、これは日本では 失礼とみなされています。 面データ「spqr」は議会制弾幕回避機関で有名な shinichiro.h さん に捧げられました。面データの名前が 古代ローマの慣用句からとられているのはこのためです。 dangen-0.5/README-ja-sjis0000644000175000017500000001476311276334656015664 0ustar00ooharaoohara00000000000000dangen --- ˌd̃V[eBOQ[ by 匴Yn published by Project Geeste $Id: README-ja-utf8,v 1.36 2009/11/10 19:03:25 oohara Exp $ * dangen Ƃ͉ dangen ͎ˌ̐mdV[eBOQ[łBJ[\L[ Vbg{^̑g݂킹ɂAʂwコ‚Ƃł܂B OɓG‚Ƃɂ{[iX_lĂBقȂՓx Xe[WI邱Ƃł܂B * dangen ̃CXg[@ dangen ̃CXg[@ɂ‚Ă INSTALL t@C񂭂B v񂷂ƁAlibcAlibSDL libSDL_image CXg[A 1) ./configure 2) make 3) make install Ɠ͂ĂB * R}hCIvV `[gIvVgpƃvCL^͕ۑ܂B --free-select ׂẴXe[WI”\ɂ܂B̃IvVgpƓ Xe[W𕡐Ił܂B̓`[gIvVłB --full-screen Q[tXN[[hŎs܂B --help wvbZ[W\ďI܂B --slow X[[hLɂ܂B̃IvVgpƁAs L[ ƂɂQ[𔼕̑xŎsł܂Bʏ̑xŎsɂ x s L[܂B̓`[gIvVłB --version o[WACZX񂨂іƐӏ\ďI܂B * L[ J[\L[ ړ Xy[X ˌ (ȉQ) ESC I p |[Y / ĊJ WCXeBbNňړюˌsƂł܂Bdangen ̋NO WCXeBbNڑĂKv邱ƂɒӂĂB }EXJ[\EBhE̊OɏoƃQ[|[YԂɂȂ܂B ɂAEChEɃtH[JXĂȂƂɎ@|邱Ƃ h܂B * ˌ@ Xy[XL[ł͒e͔ _܂_Bˌ@ 2 ʂ肠܂: + Xy[XL[ȂJ[\L[̂ǂꂩƂɂA ̃J[\L[ɒe𔭎˂邱Ƃł܂B 4 ʂ肩Iׂ܂: AAAEłB΂ߕւ ͖͂܂B + Xy[XL[ƃJ[\L[ɃXy[XL[ ƁAXy[XL[ __ ƂɒeʏɌ ˂܂B Xy[XL[ĂԂ͎@͈ړł܂B͒eł ˂ꂽǂɂ炸Ă͂܂܂B @͒e 1 ‚ƁA̒epӂ̂ɂԂ܂B @Fʼn]ĂԂ͎ˌ͂ł܂B Xy[XL[ 1 񉟂тɁAe͂傤 1 ˂܂B Xy[XL[Aˌ߂邱Ƃ͂ł܂B * 񂱂ړ @͂߂ƂAōɒBɂ͂킸Ȃ玞Ԃ܂B āAJ[\L[΂₭Ał邱Ƃɂ莩@̈ʒu𒲐 邱Ƃł܂B * @ @GeAG{̂܂͉炩̏QɐڐGƁA@͔j󂳂܂B c莩@ȂȂQ[I[o[łB@̉~`_łB ȊO͈SłB 20 _ƂɎ@ 1 @܂BS 5 (4 ʂł͂܂) NA łAcĂ (gp) @͊e 3 _ɂȂ܂B * @̒e @̒e 2 ‚̕ō\Ă܂: [ƔłB@̒e [GɃ_[W^܂B͕֗̂߂̒PȂł; @̒eOƔȂ܂B @̒e 2 ʂ̕@Ń_[W^܂: + GɒꍇA̓G 20 _[W^܂B + @̒e͉ɂԂ‚Ɣ܂B̔GɐڐG t[ 1 _[W^܂B 30 t[̊Ԏc܂B āAG͈ꔭő 50 _[W󂯂܂ ( 20 _[WA 30 _[W)BĜ΂ɕ\鐔̓G̃qbg|CgłB * G̐F G̐F 3 ނ܂: FAΐFĐԐFłBقƂǂ̓G͒FŁA Ƃǂ̐FΐFɕς܂BΐF̂ƂɓG|Ƃɂlj̓_ 邱Ƃł܂ (ȉQ)BԐF̓G͔jł܂B * {XG eXe[W̍ŌɃ{XGo܂B|΁ÃXe[W֐i Ƃł܂B2 ވȏ̌`Ԃƒ{XG邱ƁA2 ̈ȏ̃{XG Xe[W邱ƂɒӂĂB ÃXe[Wɐiނɂ͎̎Ń{XG|Ȃ΂ȂȂ Ƃ킯ł͂܂BԐc΃{XG͎ (R͕Ȃ )AXe[WNAƂȂ܂B {XGʂƉʂ܂BvC[{XG| ƂłB‚{XGƂƂłB * `F[{[iX eOƂȂΐF̓G|ƒlj̓_𓾂邱Ƃł܂B `F[{[iXƂ܂B `F[ {[iX_ 1 1 2 2 3 4 4 8 5 16 6 32 7 64 8 128 9 256 10 512 11+ 1024 ȉ̂ꂩNƃ`F[܂: + @̒eΐF̓Gj󂵂 + @̒eΐF̓Gɒ @̒eΐF̓GɒÃ_[Wł̓Gj󂳂ꂽꍇA `F[ 1 ܂B ȉ̂ꂩNƃ`F[ 0 ɖ߂܂: + @̒eOꂽ + @j󂳂ꂽ + {XG + Xe[WNA `F[ێ邽߂ɂ͗ΐF̓GȂ΂ȂȂ킯ł ȂƂɒӂĂB@̒e (ƂꂪF̓G QłĂ) ɓΏ\łB * BXe[W ʁAvC[͓Փx [hard] ȉ̃Xe[W 4 ‚I邱Ƃ Ȃ܂Bn҂̂߂ɂȊÕXe[WpӂĂ܂: + Փx [normal] ȏ̃Xe[WNAƁAՓx [very hard] Xe[WIׂ悤ɂȂ܂B + 4 ʂNAAƒNAXe[ŴȂƂЂƂ‚ Փx [hard] ȏȂ΁AՓx [hardest] ̃Xe[W 5 ʂƂ Vׂ܂B5 ʂƂđ̃Xe[WIׂȂƂɒӂĂB ̐͊evCƂɓKp܂B * CZX CZXɂ‚Ă LICENSE t@C񂭂Bv񂷂΁A CZX GPL exactly version 2 ܂ the Artistic License Version 2.0beta5 ̂AȂDȂقłB * A oO񍐂܂͊z͑匴Yn ւǂB dangen EFuy[W񂭂: http://www.interq.or.jp/libra/oohara/dangen/index.html * j dangen ̍ŏ̃o[W 2005N 7 14 () Ƀ[X܂B dangen ͂ӂ‚̈Ӗ“{ł; ЂƂ‚́uevAGeo ꏊł; ЂƂ‚́ufvAςƌ邱ƂŁA͓{ł Ƃ݂ȂĂ܂B ʃf[^uspqrv͋ce@ւŗL shinichiro.h ɕ܂Bʃf[^̖O Ñネ[}̊p傩ƂĂ̂͂̂߂łB dangen-0.5/dangen.60000644000175000017500000000263711276334533014760 0ustar00ooharaoohara00000000000000.\" $Id: dangen.6,v 1.4 2009/11/10 19:04:59 oohara Exp $ .TH DANGEN 6 "Wed, 11 Nov 2009" "Project Geeste" "dangen manual" .SH NAME dangen \- shoot 'em up game where accurate shooting matters .SH SYNOPSIS .B dangen [ .BI "\-\-free\-select" ] [ .BI "\-\-full\-screen" ] [ .BI "\-\-help" ] [ .BI "\-\-slow" ] [ .BI "\-\-version" ] .SH DESCRIPTION dangen is a shoot 'em up game that attach importance to accuracy of shooting. With the combination of the cursor key and the shot button, you can shoot at your side or even at your back. Get the bonus point by hitting the enemy without a miss. You can choose stages of different difficulty. .SH OPTIONS .TP .BI "\-\-free\-select" Allow you to select any stage. You can select the same stage multiple times if you use this option. This is a cheat option. .TP .BI "\-\-full\-screen" Run the game in the full screen mode. .TP .BI "\-\-help" Print a help message and exit. .TP .BI "\-\-slow" Enable the slow mode. If you use this option, you can run the game at the half speed by pressing the s key. Press the s key again to play at the normal speed. This is a cheat option. .TP .BI "\-\-version" Print version information, license information and the disclaimer, then exit. .SH FILES .TP .I "$HOME/.dangen/" The play record is saved in this directory. .SH BUGS Please report any bugs you find to Oohara Yuuma . .SH AUTHOR Oohara Yuuma dangen-0.5/libtenm/0000777000175000017500000000000011625724131015056 5ustar00ooharaoohara00000000000000dangen-0.5/libtenm/Makefile.am0000644000175000017500000000215711625011756017115 0ustar00ooharaoohara00000000000000## Makefile.am for dangen/libtenm ## process this file with automake --foreign to generate Makefile.in # $Id: Makefile.am,v 1.21 2011/08/23 20:56:14 oohara Exp $ noinst_LIBRARIES = libtenm.a libtenm_a_SOURCES = tenm_collision.c \ tenm_collision.h \ tenm_graphic.c \ tenm_graphic.h \ tenm_input.c \ tenm_input.h \ tenm_math.c \ tenm_math.h \ tenm_object.c \ tenm_object.h \ tenm_primitive.c \ tenm_primitive.h \ tenm_sdl_init.c \ tenm_sdl_init.h \ tenm_table.c \ tenm_table.h \ tenm_timer.c \ tenm_timer.h #CC_WARNINGS = -Wall # the overkill warnings # I don't use -Wtraditional because I use string concatenation # use -Wno-long-long because -pedantic implies -Wlong-long CC_WARNINGS = -Wall -Wshadow -Wpointer-arith -Wcast-qual \ -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \ -Wmissing-declarations -Wnested-externs -Winline -pedantic -Wno-long-long # let's hardcode SDL flags here SDL_CFLAGS=`sdl-config --cflags` # sdl-config --libs is added to LIBS in configure # -g -O2 are in CFLAGS by default, don't use @CFLAGS@ here AM_CFLAGS = $(SDL_CFLAGS) $(CC_WARNINGS) dangen-0.5/libtenm/Makefile.in0000644000175000017500000003374211625012016017120 0ustar00ooharaoohara00000000000000# Makefile.in generated by automake 1.11 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # $Id: Makefile.am,v 1.21 2011/08/23 20:56:14 oohara Exp $ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : subdir = libtenm DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LIBRARIES = $(noinst_LIBRARIES) AR = ar ARFLAGS = cru libtenm_a_AR = $(AR) $(ARFLAGS) libtenm_a_LIBADD = am_libtenm_a_OBJECTS = tenm_collision.$(OBJEXT) tenm_graphic.$(OBJEXT) \ tenm_input.$(OBJEXT) tenm_math.$(OBJEXT) tenm_object.$(OBJEXT) \ tenm_primitive.$(OBJEXT) tenm_sdl_init.$(OBJEXT) \ tenm_table.$(OBJEXT) tenm_timer.$(OBJEXT) libtenm_a_OBJECTS = $(am_libtenm_a_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(libtenm_a_SOURCES) DIST_SOURCES = $(libtenm_a_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build_alias = @build_alias@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LIBRARIES = libtenm.a libtenm_a_SOURCES = tenm_collision.c \ tenm_collision.h \ tenm_graphic.c \ tenm_graphic.h \ tenm_input.c \ tenm_input.h \ tenm_math.c \ tenm_math.h \ tenm_object.c \ tenm_object.h \ tenm_primitive.c \ tenm_primitive.h \ tenm_sdl_init.c \ tenm_sdl_init.h \ tenm_table.c \ tenm_table.h \ tenm_timer.c \ tenm_timer.h #CC_WARNINGS = -Wall # the overkill warnings # I don't use -Wtraditional because I use string concatenation # use -Wno-long-long because -pedantic implies -Wlong-long CC_WARNINGS = -Wall -Wshadow -Wpointer-arith -Wcast-qual \ -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \ -Wmissing-declarations -Wnested-externs -Winline -pedantic -Wno-long-long # let's hardcode SDL flags here SDL_CFLAGS = `sdl-config --cflags` # sdl-config --libs is added to LIBS in configure # -g -O2 are in CFLAGS by default, don't use @CFLAGS@ here AM_CFLAGS = $(SDL_CFLAGS) $(CC_WARNINGS) all: all-am .SUFFIXES: .SUFFIXES: .c .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libtenm/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign libtenm/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) libtenm.a: $(libtenm_a_OBJECTS) $(libtenm_a_DEPENDENCIES) -rm -f libtenm.a $(libtenm_a_AR) libtenm.a $(libtenm_a_OBJECTS) $(libtenm_a_LIBADD) $(RANLIB) libtenm.a mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tenm_collision.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tenm_graphic.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tenm_input.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tenm_math.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tenm_object.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tenm_primitive.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tenm_sdl_init.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tenm_table.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tenm_timer.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-noinstLIBRARIES ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: dangen-0.5/libtenm/tenm_collision.c0000644000175000017500000005103510276702736020250 0ustar00ooharaoohara00000000000000/* $Id: tenm_collision.c,v 1.83 2003/01/14 01:03:14 oohara Exp $ */ #include /* malloc */ #include /* for tenm_polygon_new */ #include #include "tenm_collision.h" #define NEAR_ZERO 0.0001 static double tenm_same_side_temp(double p_x, double p_y, double a_x, double a_y, double b_x, double b_y); static double tenm_same_side_vertical_temp(double p_x, double p_y, double a_x, double a_y, double b_x, double b_y, double on_line_x, double on_line_y); static int tenm_collided_point_point(const tenm_point *p, const tenm_point *q); static int tenm_collided_point_circle(const tenm_point *p, const tenm_circle *q); static int tenm_collided_point_segment(const tenm_point *p, const tenm_segment *q); static int tenm_collided_point_polygon(const tenm_point *p, const tenm_polygon *q); static int tenm_collided_circle_circle(const tenm_circle *p, const tenm_circle *q); static int tenm_collided_circle_segment(const tenm_circle *p, const tenm_segment *q); static int tenm_collided_circle_segment2(double p_x, double p_y, double p_r, double q_a_x, double q_a_y, double q_b_x, double q_b_y); static int tenm_collided_circle_polygon(const tenm_circle *p, const tenm_polygon *q); static int tenm_collided_segment_segment(const tenm_segment *p, const tenm_segment *q); static int tenm_collided_segment_segment2(double p_a_x, double p_a_y, double p_b_x, double p_b_y, double q_a_x, double q_a_y, double q_b_x, double q_b_y); static int tenm_collided_segment_polygon(const tenm_segment *p, const tenm_polygon *q); static int tenm_collided_polygon_polygon(const tenm_polygon *p, const tenm_polygon *q); int tenm_same_point(double a_x, double a_y, double b_x, double b_y) { /* assume that a point (really a pixel) is a circle whose diameter is 1 */ return tenm_point_nearer(a_x, a_y, b_x, b_y, 1.0); } /* checks if the distance between point A(a_x, a_y) and point B(b_x, b_y) is * equal to or smaller than n * return 1 (true) or 0 (false) */ int tenm_point_nearer(double a_x, double a_y, double b_x, double b_y, double n) { /* distance^2 = temp = temp1 + temp2 */ double temp = 0; double temp1 = 0; double temp2 = 0; /* distance can't be negative*/ if (n < -NEAR_ZERO) { fprintf(stderr, "tenm_point_nearer: n is negative (%f)\n", n); return 0; } if ((n > -NEAR_ZERO) && (n < NEAR_ZERO)) return tenm_same_point(a_x, a_y, b_x, b_y); temp1 = a_x - b_x; temp1 = temp1 * temp1; temp2 = a_y - b_y; temp2 = temp2 * temp2; temp = temp1 + temp2; if (n * n >= temp) return 1; return 0; } /* checks if the distance between the point P and the line is equal to * or smaller than n * return 1 (true) or 0 (false) */ int tenm_line_nearer(double p_x, double p_y, double a_x, double a_y, double b_x, double b_y, double n) { /* distance^2 = temp/over */ double temp = 0; double over = 0; /* over = over1 + over2 */ double over1 = 0; double over2 = 0; /* distance can't be nagative */ if (n < -NEAR_ZERO) { fprintf(stderr, "tenm_line_nearer: n is negative (%f)\n", n); return 0; } /* check if line is really a point */ if(tenm_same_point(a_x, a_y, b_x, b_y)) { return tenm_point_nearer(p_x, p_y, a_x, a_y, n); } temp = (a_x - p_x) * (b_y - a_y) - (a_y - p_y) * (b_x - a_x); temp = temp * temp; over1= b_x - a_x; over1 = over1 * over1; over2 = b_y - a_y; over2 = over2 * over2; over = over1 + over2; if (over * n * n >= temp) return 1; return 0; } /* checks if the two points P(p_x, p_y) and Q(q_x, q_y) are on the same * side of the line which passes A(a_x, a_y) and B(b_x, b_y) * "on the line" counts as either side * return 1 (true) or 0 (false) */ int tenm_same_side(double p_x, double p_y, double q_x, double q_y, double a_x, double a_y, double b_x, double b_y) { double temp_p; double temp_q; /* check if we really have a line */ if (tenm_same_point(a_x, a_y, b_x, b_y)) { fprintf(stderr, "tenm_same_side: not a line\n"); return 0; } temp_p = tenm_same_side_temp(p_x, p_y, a_x, a_y, b_x, b_y); temp_q = tenm_same_side_temp(q_x, q_y, a_x, a_y, b_x, b_y); if ((temp_p >= 0) && (temp_q >= 0)) return 1; if ((temp_p <= 0) && (temp_q <= 0)) return 1; return 0; } /* local-only function used in tenm_same_side */ static double tenm_same_side_temp(double p_x, double p_y, double a_x, double a_y, double b_x, double b_y) { return (b_y - a_y) * p_x - (b_x - a_x) * p_y -((b_y - a_y) * a_x - (b_x - a_x) * a_y); } /* checks if the two points P(p_x, p_y) and Q(q_x, q_y) are on the same * side of the line L * such that: * 1) L passes the point (on_line_x, on_line_y) * 2) L is vertical to the line which passes (a_x, a_y) and (b_x, b_y) * "on the line" counts as either side * return 1 (true) or 0 (false) */ int tenm_same_side_vertical(double p_x, double p_y, double q_x, double q_y, double a_x, double a_y, double b_x, double b_y, double on_line_x, double on_line_y) { double temp_p; double temp_q; /* check if we really have a line */ if (tenm_same_point(a_x, a_y, b_x, b_y)) { fprintf(stderr, "tenm_same_side_vertical: not a line\n"); return 0; } temp_p = tenm_same_side_vertical_temp(p_x, p_y, a_x, a_y, b_x, b_y, on_line_x, on_line_y); temp_q = tenm_same_side_vertical_temp(q_x, q_y, a_x, a_y, b_x, b_y, on_line_x, on_line_y); if ((temp_p >= 0) && (temp_q >= 0)) return 1; if ((temp_p <= 0) && (temp_q <= 0)) return 1; return 0; } /* local-only function used in tenm_same_side_vertical */ static double tenm_same_side_vertical_temp(double p_x, double p_y, double a_x, double a_y, double b_x, double b_y, double on_line_x, double on_line_y) { return (b_x - a_x) * p_x + (b_y - a_y) * p_y -((b_x - a_x) * on_line_x + (b_y - a_y) * on_line_y); } /* optimized under the assumption that p and q are usually not collided */ int tenm_collided_primitive(const tenm_primitive *p, const tenm_primitive *q) { const tenm_primitive *p_temp; const tenm_primitive *q_temp; if (p == NULL) { fprintf(stderr, "tenm_collided_primitive: p is NULL\n"); return 0; } if (q == NULL) { fprintf(stderr, "tenm_collided_primitive: q is NULL\n"); return 0; } switch (p->klass + q->klass) { case TENM_POINT + TENM_POINT: return tenm_collided_point_point((const tenm_point *) p, (const tenm_point *) q); break; case TENM_POINT + TENM_CIRCLE: if (p->klass == TENM_POINT) { p_temp = p; q_temp = q; } else if (q->klass == TENM_POINT) { p_temp = q; q_temp = p; } else { fprintf(stderr, "tenm_collided_primitive: strange pointer found in " "TENM_POINT + TENM_CIRCLE\n"); return 0; } return tenm_collided_point_circle((const tenm_point *) p_temp, (const tenm_circle *) q_temp); break; case TENM_POINT + TENM_SEGMENT: if (p->klass == TENM_POINT) { p_temp = p; q_temp = q; } else if (q->klass == TENM_POINT) { p_temp = q; q_temp = p; } else { fprintf(stderr, "tenm_collided_primitive: strange pointer found in " "TENM_POINT + TENM_SEGMENT\n"); return 0; } return tenm_collided_point_segment((const tenm_point *) p_temp, (const tenm_segment *) q_temp); break; case TENM_POINT + TENM_POLYGON: if (p->klass == TENM_POINT) { p_temp = p; q_temp = q; } else if (q->klass == TENM_POINT) { p_temp = q; q_temp = p; } else { fprintf(stderr, "tenm_collided_primitive: strange pointer found in " "TENM_POINT + TENM_POLYGON\n"); return 0; } return tenm_collided_point_polygon((const tenm_point *) p_temp, (const tenm_polygon *) q_temp); break; case TENM_CIRCLE + TENM_CIRCLE: return tenm_collided_circle_circle((const tenm_circle *) p, (const tenm_circle *) q); break; case TENM_CIRCLE + TENM_SEGMENT: if (p->klass == TENM_CIRCLE) { p_temp = p; q_temp = q; } else if (q->klass == TENM_CIRCLE) { p_temp = q; q_temp = p; } else { fprintf(stderr, "tenm_collided_primitive: strange pointer found in " "TENM_CIRCLE + TENM_SEGMENT\n"); return 0; } return tenm_collided_circle_segment((const tenm_circle *) p_temp, (const tenm_segment *) q_temp); break; case TENM_CIRCLE + TENM_POLYGON: if (p->klass == TENM_CIRCLE) { p_temp = p; q_temp = q; } else if (q->klass == TENM_CIRCLE) { p_temp = q; q_temp = p; } else { fprintf(stderr, "tenm_collided_primitive: strange pointer found in " "TENM_CIRCLE + TENM_POLYGON\n"); return 0; } return tenm_collided_circle_polygon((const tenm_circle *) p_temp, (const tenm_polygon *) q_temp); break; case TENM_SEGMENT + TENM_SEGMENT: return tenm_collided_segment_segment((const tenm_segment *) p, (const tenm_segment *) q); break; case TENM_SEGMENT + TENM_POLYGON: if (p->klass == TENM_SEGMENT) { p_temp = p; q_temp = q; } else if (q->klass == TENM_SEGMENT) { p_temp = q; q_temp = p; } else { fprintf(stderr, "tenm_collided_primitive: strange pointer found in " "TENM_SEGMENT + TENM_POLYGON\n"); return 0; } return tenm_collided_segment_polygon((const tenm_segment *) p_temp, (const tenm_polygon *) q_temp); break; case TENM_POLYGON + TENM_POLYGON: return tenm_collided_polygon_polygon((const tenm_polygon *) p, (const tenm_polygon *) q); break; default: fprintf(stderr, "tenm_collided_primitive: strange combination of " "primitives (%d and %d)\n", p->klass, q->klass); return 0; break; } return 0; } static int tenm_collided_point_point(const tenm_point *p, const tenm_point *q) { return tenm_same_point(p->x, p->y, q->x, q->y); } static int tenm_collided_point_circle(const tenm_point *p, const tenm_circle *q) { return tenm_point_nearer(p->x, p->y, q->center->x, q->center->y, q->r); } static int tenm_collided_point_segment(const tenm_point *p, const tenm_segment *q) { /* assume that a point (really a pixel) is a circle whose diameter is 1 */ return tenm_collided_circle_segment2(p->x, p->y, 0.5, q->a->x, q->a->y, q->b->x, q->b->y); } static int tenm_collided_point_polygon(const tenm_point *p, const tenm_polygon *q) { /* I know that the best algorithm is O(n * log(n)), but it is hard * to implement */ int i; int j; int k; int l; if (q->n <= 0) { fprintf(stderr, "tenm_collided_point_polygon: strange point number in q " "(%d)\n", q->n); return 0; } if (q->n == 1) return tenm_same_point(p->x, p->y, q->v[0]->x, q->v[0]->y); if (q->n == 2) return tenm_collided_circle_segment2(p->x, p->y, 0.5, q->v[0]->x, q->v[0]->y, q->v[1]->x, q->v[1]->y); for (i = 0; i < q->n; i++) for (j = i + 1; j < q->n; j++) { for (k = 0; k < q->n; k++) { if (tenm_same_point(q->v[k]->x, q->v[k]->y, q->v[i]->x, q->v[i]->y)) continue; if (tenm_same_point(q->v[k]->x, q->v[k]->y, q->v[j]->x, q->v[j]->y)) continue; if (q->n >= 4) { for (l = 0;(l < q->n)&&((tenm_same_point(q->v[l]->x, q->v[l]->y, q->v[i]->x, q->v[i]->y)) ||(tenm_same_point(q->v[l]->x, q->v[l]->y, q->v[j]->x, q->v[j]->y)) ||(tenm_same_point(q->v[l]->x, q->v[l]->y, q->v[k]->x, q->v[k]->y))); l++) ; if ((l < q->n) && (! tenm_same_side(q->v[k]->x, q->v[k]->y, q->v[l]->x, q->v[l]->y, q->v[i]->x, q->v[i]->y, q->v[j]->x, q->v[j]->y))) break; } if (! tenm_same_side(p->x, p->y, q->v[k]->x, q->v[k]->y, q->v[i]->x, q->v[i]->y, q->v[j]->x, q->v[j]->y)) return 0; } } return 1; } static int tenm_collided_circle_circle(const tenm_circle *p, const tenm_circle *q) { return tenm_point_nearer(p->center->x, p->center->y, q->center->x, q->center->y, p->r + q->r); } static int tenm_collided_circle_segment(const tenm_circle *p, const tenm_segment *q) { return tenm_collided_circle_segment2(p->center->x, p->center->y, p->r, q->a->x, q->a->y, q->b->x, q->b->y); } static int tenm_collided_circle_segment2(double p_x, double p_y, double p_r, double q_a_x, double q_a_y, double q_b_x, double q_b_y) { if (tenm_point_nearer(p_x, p_y, q_a_x, q_a_y, p_r)) return 1; if (tenm_point_nearer(p_x, p_y, q_b_x, q_b_y, p_r)) return 1; if (! tenm_line_nearer(p_x, p_y, q_a_x, q_a_y, q_b_x, q_b_y, p_r)) return 0; if (tenm_same_side_vertical(q_a_x, q_a_y, q_b_x, q_b_y, q_a_x, q_a_y, q_b_x, q_b_y, p_x, p_y)) return 0; return 1; } static int tenm_collided_circle_polygon(const tenm_circle *p, const tenm_polygon *q) { int i; int j; int temp; /* first, assume a sufficiently large rectangle */ temp = 1; for (i = 0; i < q->n; i++) if (p->center->x + p->r >= q->v[i]->x) { temp = 0; break; } if (temp == 1) return 0; temp = 1; for (i = 0; i < q->n; i++) if (p->center->x - p->r <= q->v[i]->x) { temp = 0; break; } if (temp == 1) return 0; temp = 1; for (i = 0; i < q->n; i++) if (p->center->y + p->r >= q->v[i]->y) { temp = 0; break; } if (temp == 1) return 0; temp = 1; for (i = 0; i < q->n; i++) if (p->center->y - p->r <= q->v[i]->y) { temp = 0; break; } if (temp == 1) return 0; /* now, the expensive check */ for (i = 0; i < q->n; i++) for (j = i + 1; j < q->n; j++) if (tenm_collided_circle_segment2(p->center->x, p->center->y, p->r, q->v[i]->x, q->v[i]->y, q->v[j]->x, q->v[j]->y)) return 1; return tenm_collided_point_polygon(p->center, q); } static int tenm_collided_segment_segment(const tenm_segment *p, const tenm_segment *q) { return tenm_collided_segment_segment2(p->a->x, p->a->y, p->b->x, p->b->y, q->a->x, q->a->y, q->b->x, q->b->y); } static int tenm_collided_segment_segment2(double p_a_x, double p_a_y, double p_b_x, double p_b_y, double q_a_x, double q_a_y, double q_b_x, double q_b_y) { /* we need this point-on-segment checks first because tenm_same_side * counts "on the line" as either side */ if (tenm_collided_circle_segment2(p_a_x, p_a_y, 0.5, q_a_x, q_a_y, q_b_x, q_b_y)) return 1; if (tenm_collided_circle_segment2(p_b_x, p_b_y, 0.5, q_a_x, q_a_y, q_b_x, q_b_y)) return 1; if (tenm_collided_circle_segment2(q_a_x, q_a_y, 0.5, p_a_x, p_a_y, p_b_x, p_b_y)) return 1; if (tenm_collided_circle_segment2(q_b_x, q_b_y, 0.5, p_a_x, p_a_y, p_b_x, p_b_y)) return 1; if (tenm_same_side(p_a_x, p_a_y, p_b_x, p_b_y, q_a_x, q_a_y, q_b_x, q_b_y)) return 0; if (tenm_same_side(q_a_x, q_a_y, q_b_x, q_b_y, p_a_x, p_a_y, p_b_x, p_b_y)) return 0; return 1; } static int tenm_collided_segment_polygon(const tenm_segment *p, const tenm_polygon *q) { int i; int j; int temp; /* first, assume a sufficiently large rectangle */ temp = 1; for (i = 0; i < q->n; i++) { if (p->a->x >= q->v[i]->x) { temp = 0; break; } if (p->b->x >= q->v[i]->x) { temp = 0; break; } } if (temp == 1) return 0; temp = 1; for (i = 0; i < q->n; i++) { if (p->a->x <= q->v[i]->x) { temp = 0; break; } if (p->b->x <= q->v[i]->x) { temp = 0; break; } } if (temp == 1) return 0; temp = 1; for (i = 0; i < q->n; i++) { if (p->a->y >= q->v[i]->y) { temp = 0; break; } if (p->b->y >= q->v[i]->y) { temp = 0; break; } } if (temp == 1) return 0; temp = 1; for (i = 0; i < q->n; i++) { if (p->a->y <= q->v[i]->y) { temp = 0; break; } if (p->b->y <= q->v[i]->y) { temp = 0; break; } } if (temp == 1) return 0; /* now, the expensive check */ for (i = 0; i < q->n; i++) for (j = i + 1; j < q->n; j++) if (tenm_collided_segment_segment2(p->a->x, p->a->y, p->b->x, p->b->y, q->v[i]->x, q->v[i]->y, q->v[j]->x, q->v[j]->y)) return 1; if (tenm_collided_point_polygon(p->a, q)) return 1; if (tenm_collided_point_polygon(p->b, q)) return 1; return 0; } static int tenm_collided_polygon_polygon(const tenm_polygon *p, const tenm_polygon *q) { int i; int j; int k; int l; int temp; /* first, assume a sufficiently large rectangle */ temp = 1; for (i = 0; i < p->n; i++) for (j = 0; j < q->n; j++) if (p->v[i]->x >= q->v[j]->x) { temp = 0; break; } if (temp == 1) return 0; temp = 1; for (i = 0; i < p->n; i++) for (j = 0; j < q->n; j++) if (p->v[i]->x <= q->v[j]->x) { temp = 0; break; } if (temp == 1) return 0; temp = 1; for (i = 0; i < p->n; i++) for (j = 0; j < q->n; j++) if (p->v[i]->y >= q->v[j]->y) { temp = 0; break; } if (temp == 1) return 0; temp = 1; for (i = 0; i < p->n; i++) for (j = 0; j < q->n; j++) if (p->v[i]->y <= q->v[j]->y) { temp = 0; break; } if (temp == 1) return 0; /* now, the expensive check */ for (i = 0; i < p->n; i++) for (j = i + 1; j < p->n; j++) for (k = 0; k < q->n; k++) for (l = k + 1; l < q->n; l++) if (tenm_collided_segment_segment2(p->v[i]->x, p->v[i]->y, p->v[j]->x, p->v[j]->y, q->v[k]->x, q->v[k]->y, q->v[l]->x, q->v[l]->y)) return 1; for (i = 0; i < p->n; i++) if (tenm_collided_point_polygon(p->v[i], q)) return 1; for (i = 0; i < q->n; i++) if (tenm_collided_point_polygon(q->v[i], p)) return 1; return 0; } dangen-0.5/libtenm/tenm_collision.h0000644000175000017500000000201310276702736020245 0ustar00ooharaoohara00000000000000/* $Id: tenm_collision.h,v 1.21 2002/05/08 10:24:03 oohara Exp $ */ #ifndef __TENM_COLLISION_H__ #define __TENM_COLLISION_H__ #include "tenm_primitive.h" /* don't use tenm_* here to avoid creating new primitives */ int tenm_same_point(double a_x, double a_y, double b_x, double b_y); int tenm_point_nearer(double a_x, double a_y, double b_x, double b_y, double n); int tenm_line_nearer(double p_x, double p_y, double a_x, double a_y, double b_x, double b_y, double n); int tenm_same_side(double p_x, double p_y, double q_x, double q_y, double a_x, double a_y, double b_x, double b_y); int tenm_same_side_vertical(double p_x, double p_y, double q_x, double q_y, double a_x, double a_y, double b_x, double b_y, double on_line_x, double on_line_y); int tenm_collided_primitive(const tenm_primitive *p, const tenm_primitive *q); #endif /* not __TENM_COLLISION_H__ */ dangen-0.5/libtenm/tenm_graphic.c0000644000175000017500000006770710276702736017707 0ustar00ooharaoohara00000000000000/* $Id: tenm_graphic.c,v 1.133 2005/06/29 20:24:51 oohara Exp $ */ #include /* malloc */ #include #include /* for tenm_load_image */ #include /* isprint */ #include #include #include #include "tenm_math.h" #include "tenm_primitive.h" #include "tenm_object.h" #include "tenm_sdl_init.h" #include "tenm_graphic.h" /* number of printable characters */ #define TENM_FONT_NUMBER_CHAR 95 static SDL_Surface *dpy = NULL; static int tenm_font_index(int c); static int tenm_draw_line2(int a_x, int a_y, int b_x, int b_y, int width, tenm_color color, int xy_reversed); /* return 0 on success, 1 on error */ int tenm_graphic_init(int width, int height, int flag, const char *name) { Uint32 sdl_flag; /* sanity check */ if (name == NULL) { fprintf(stderr, "tenm_graphic_init: name is NULL\n"); return 1; } if (SDL_WasInit(SDL_INIT_VIDEO) != 0) { fprintf(stderr, "tenm_graphic_init: warning: video is already " "initialized\n"); return 0; } if (tenm_sdl_init(SDL_INIT_VIDEO) != 0) { fprintf(stderr, "tenm_graphic_init: cannot initialize SDL video\n"); return 1; } if (dpy != NULL) { fprintf(stderr, "tenm_graphic_init: " "dpy is already set\n"); /* this is a fatal error --- if we are here, video is not * initialized before tenm_graphic_init() is called, so * the situation is weird enough */ /* dpy should not be freed here --- it is the job of SDL_Quit() */ SDL_QuitSubSystem(SDL_INIT_VIDEO); return 1; } if (flag & TENM_FULLSCREEN) sdl_flag = SDL_FULLSCREEN; else sdl_flag = 0; dpy = SDL_SetVideoMode(width, height, 0, sdl_flag); if (dpy == NULL) { fprintf(stderr, "tenm_graphic_init: " "SDL_SetVideoMode failed (%s)\n", SDL_GetError()); SDL_QuitSubSystem(SDL_INIT_VIDEO); return 1; } SDL_WM_SetCaption(name, name); /* ignore the return value of SDL_ShowCursor() because the cursor * may be out of the window when it is called */ SDL_ShowCursor(SDL_DISABLE); return 0; } /* draw a line between A(a_x, a_y) and B(b_x, b_y) * return 0 on success, 1 on error */ int tenm_draw_line(int a_x, int a_y, int b_x, int b_y, int width, tenm_color color) { int dx; int dy; int dx_abs; int dy_abs; /* sanity check */ if (width <= 0) { fprintf(stderr, "tenm_draw_line: width is non-positive (%d)\n", width); return 1; } dx = b_x - a_x; dy = b_y - a_y; if (dx >= 0) dx_abs = dx; else dx_abs = -dx; if (dy >= 0) dy_abs = dy; else dy_abs = -dy; if ((dx == 0) && (dy == 0)) return tenm_draw_point(a_x, a_y, color); if (dx_abs >= dy_abs) { if (dx >= 0) return tenm_draw_line2(a_x, a_y, b_x, b_y, width, color, 0); else return tenm_draw_line2(b_x, b_y, a_x, a_y, width, color, 0); } else { if (dy >= 0) return tenm_draw_line2(a_y, a_x, b_y, b_x, width, color, 1); else return tenm_draw_line2(b_y, b_x, a_y, a_x, width, color, 1); } /* should not reach here */ fprintf(stderr, "tenm_draw_line: should not reach here\n"); return 1; } /* draw a circle whose center is (center_x, center_y) * with a line whose width is width (arg 4) * note that the center of the circle is always blank, * even if width == radius * return 0 on success, 1 on error */ int tenm_draw_circle(int center_x, int center_y, int radius, int width, tenm_color color) { int i; int x_outer; int x_inner; int y; int error_tilde_outer; int error_tilde_inner; int status = 0; /* sanity check */ if (radius <= 0) { fprintf(stderr, "tenm_draw_circle: radius is non-positive (%d)\n", radius); return 1; } if ((width <= 0) || (width > radius)) { fprintf(stderr, "tenm_draw_circle: width is out of range (%d)\n", width); return 1; } /* the Bresenham algorithm with the "wide line" hack */ x_outer = radius; x_inner = radius - width + 1; y = 0; /* the next point is either (x, y + 1) or (x - 1, y + 1) */ /* ((x)^2 + (y + 1)^2 - radius^2) + ((x - 1)^2 + (y + 1)^2 - radius^2) */ error_tilde_outer = 3 - 2 * radius; error_tilde_inner = 3 - 2 * (radius - width + 1); while (x_outer >= y) { for (i = x_outer; (i >= x_inner) && (i >= 0); i--) { if (tenm_draw_point(center_x + i, center_y + y, color) != 0) status = 1; if (tenm_draw_point(center_x + i, center_y - y, color) != 0) status = 1; if (tenm_draw_point(center_x - i, center_y + y, color) != 0) status = 1; if (tenm_draw_point(center_x - i, center_y - y, color) != 0) status = 1; if (tenm_draw_point(center_x + y, center_y + i, color) != 0) status = 1; if (tenm_draw_point(center_x + y, center_y - i, color) != 0) status = 1; if (tenm_draw_point(center_x - y, center_y + i, color) != 0) status = 1; if (tenm_draw_point(center_x - y, center_y - i, color) != 0) status = 1; } if (error_tilde_outer >= 0) { /* the next point is (x - 1, y + 1) */ /* error_tilde(next) - error_tilde * = (((x - 1)^2 + (y + 2)^2 - radius^2) * + ((x - 2)^2 + (y + 2)^2 - radius^2)) * - (((x)^2 + (y + 1)^2 - radius^2) * + ((x - 1)^2 + (y + 1)^2 - radius^2)) */ error_tilde_outer += (-4) * x_outer + 4 * y + 10; x_outer--; } else { /* the next point is (x, y + 1) */ /* error_tilde(next) - error_tilde * = (((x)^2 + (y + 2)^2 - radius^2) * + ((x - 1)^2 + (y + 2)^2 - radius^2)) * - (((x)^2 + (y + 1)^2 - radius^2) * + ((x - 1)^2 + (y + 1)^2 - radius^2)) */ error_tilde_outer += 4 * y + 6; } if (x_inner >= y) { if (error_tilde_inner >= 0) { error_tilde_inner += (-4) * x_inner + 4 * y + 10; x_inner--; } else { error_tilde_inner += 4 * y + 6; } } y++; } return status; } /* you must _NOT_ lock dpy before calling this function * return 0 on success, 1 on error */ int tenm_draw_point(int x, int y, tenm_color color) { return tenm_draw_rectangle(x, y, 1, 1, color); } /* you must _NOT_ lock dpy before calling this function * return 0 on success, 1 on error */ int tenm_draw_rectangle(int x, int y, int w, int h, tenm_color color) { SDL_Rect rec; /* sanity check */ if ((x + (w - 1) < 0) || (x - (w - 1) >= dpy->w)) return 0; if ((y + (h - 1) < 0) || (y - (h - 1) >= dpy->h)) return 0; rec.x = x; rec.y = y; rec.w = w; rec.h = h; if (SDL_FillRect(dpy, &rec, color) != 0) { fprintf(stderr, "tenm_draw_rectangle: SDL_FillRect failed " "(%s) (x = %d, y = %d, w = %d, h = %d)\n", SDL_GetError(), x, y, w, h); return 1; } return 0; } tenm_color tenm_map_color(int red, int green, int blue) { /* sanity check */ if (red < 0) { fprintf(stderr, "tenm_map_color: red (%d) too small\n", red); red = 0; } else if (red > 255) { fprintf(stderr, "tenm_map_color: red (%d) too big\n", red); red = 255; } if (green < 0) { fprintf(stderr, "tenm_map_color: green (%d) too small\n", green); green = 0; } else if (green > 255) { fprintf(stderr, "tenm_map_color: green (%d) too big\n", green); green = 255; } if (blue < 0) { fprintf(stderr, "tenm_map_color: blue (%d) too small\n", blue); blue = 0; } else if (blue > 255) { fprintf(stderr, "tenm_map_color: blue (%d) too big\n", blue); blue = 255; } /* I can't fix gcc "different width" warnings here */ return SDL_MapRGB(dpy->format, red, green, blue); } /* return 0 on success, 1 on error */ int tenm_clear_window(tenm_color color) { if (SDL_FillRect(dpy, NULL, color) != 0) { fprintf(stderr, "tenm_clear_window: SDL_FillRect failed (%s)\n", SDL_GetError()); return 1; } return 0; } /* return 0 on success, 1 on error */ int tenm_redraw_window(void) { if (SDL_Flip(dpy) != 0) { fprintf(stderr, "tenm_redraw_window: SDL_Flip failed (%s)\n", SDL_GetError()); return 1; } return 0; } /* return 0 on success, 1 on error */ int tenm_draw_primitive(tenm_primitive *p, tenm_color color) { int i; int j; int status = 0; if (p == NULL) { fprintf(stderr, "tenm_draw_primitive: p is NULL\n"); return 0; } switch (p->klass) { case TENM_POINT: if (tenm_draw_point((int) ((tenm_point *) p)->x, (int) ((tenm_point *) p)->y, color) != 0) return 1; else return 0; break; case TENM_CIRCLE: if (tenm_draw_circle((int) ((tenm_circle *) p)->center->x, (int) ((tenm_circle *) p)->center->y, (int) ((tenm_circle *) p)->r, 1, color) != 0) return 1; else return 0; break; case TENM_SEGMENT: if (tenm_draw_line((int) ((tenm_segment *) p)->a->x, (int) ((tenm_segment *) p)->a->y, (int) ((tenm_segment *) p)->b->x, (int) ((tenm_segment *) p)->b->y, 1, color) != 0) return 1; else return 0; break; case TENM_POLYGON: for (i = 0; i < ((tenm_polygon *) p)->n; i++) for (j = i + 1; j < ((tenm_polygon *) p)->n; j++) if (tenm_draw_line((int) ((tenm_polygon *) p)->v[i]->x, (int) ((tenm_polygon *) p)->v[i]->y, (int) ((tenm_polygon *) p)->v[j]->x, (int) ((tenm_polygon *) p)->v[j]->y, 1, color) != 0) status = 1; return status; break; default: fprintf(stderr, "tenm_draw_primitive: strange primitive (%d)\n", p->klass); return 1; break; } /* should not reach here */ fprintf(stderr, "tenm_draw_primitive: should not reach here\n"); return 1; } /* return 0 on success, 1 on error */ int tenm_draw_mass(tenm_mass *p, tenm_color color) { int i; int status = 0; /* sanity check */ if (p == NULL) { fprintf(stderr, "tenm_draw_mass: p is NULL\n"); return 1; } if (p->n <= 0) { fprintf(stderr, "tenm_draw_mass: p->n is non-negative\n"); return 1; } if (p->p == NULL) { fprintf(stderr, "tenm_draw_mass: p->p is NULL\n"); return 1; } for (i = 0; i < p->n; i++) { if (tenm_draw_primitive(p->p[i], color)) { fprintf(stderr, "tenm_draw_mass: tenm_draw_primitive failed (%d)\n", i); status = 1; } } return status; } /* load image files and split them * ... is one or more of * (const char *file_name, int row, int column, tenm_color transparent_color) * return NULL on error */ tenm_image * tenm_load_image(int number_file, ...) { int i; int j; int k; int l; const char *file_name; int row; int column; tenm_color transparent_color; int width; int height; int suffix; va_list ap; tenm_image *temp; SDL_Surface **temp_surface; SDL_Surface *master; SDL_Rect temp_rect_src; SDL_Rect temp_rect_dest; /* sanity check */ if (number_file <= 0) { fprintf(stderr, "tenm_load_image: strange number_file (%d)\n", number_file); return NULL; } temp = (tenm_image *) malloc(sizeof(tenm_image)); if (temp == NULL) { fprintf(stderr, "tenm_load_image: malloc failed\n"); return NULL; } temp->n = 0; temp->image = NULL; va_start(ap, number_file); for (i = 0; i < number_file; i++) { /* you can't use char in va_arg */ file_name = (const char *) va_arg(ap, const int *); row = va_arg(ap, int); column = va_arg(ap, int); transparent_color = va_arg(ap, tenm_color); /* sanity check */ if (file_name == NULL) { fprintf(stderr, "tenm_load_image: file_name is NULL (i = %d)\n", i); if (temp->image != NULL) { for (l = 0; l < temp->n; l++) SDL_FreeSurface(temp->image[l]); free(temp->image); } free(temp); va_end(ap); return NULL; } if (row <= 0) { fprintf(stderr, "tenm_load_image: row is non-positive (%d) " "(i = %d)\n", row, i); if (temp->image != NULL) { for (l = 0; l < temp->n; l++) SDL_FreeSurface(temp->image[l]); free(temp->image); } free(temp); va_end(ap); return NULL; } if (column <= 0) { fprintf(stderr, "tenm_load_image: column is non-positive (%d) " "(i = %d)\n", column, i); if (temp->image != NULL) { for (l = 0; l < temp->n; l++) SDL_FreeSurface(temp->image[l]); free(temp->image); } free(temp); va_end(ap); return NULL; } master = IMG_Load(file_name); if (master == NULL) { fprintf(stderr, "tenm_load_image: IMG_Load(%s) failed (%s) (%i)\n", file_name, IMG_GetError(), i); if (temp->image != NULL) { for (l = 0; l < temp->n; l++) SDL_FreeSurface(temp->image[l]); free(temp->image); } free(temp); va_end(ap); return NULL; } width = master->w / column; if (master->w % column != 0) fprintf(stderr, "tenm_load_image: warning: width (%d) of image (%s) " "cannot be divided by %d\n", master->w, file_name, column); height = master->h / row; if (master->h % row != 0) fprintf(stderr, "tenm_load_image: warning: height (%d) of image (%s) " "cannot be divided by %d\n", master->h, file_name, row); /* don't substitute tenm->image directly, or you will be in a trouble * if realloc fails */ if (temp->image == NULL) temp_surface = (SDL_Surface **) malloc(sizeof(SDL_Surface *) * row * column); else temp_surface = (SDL_Surface **) realloc(temp->image, sizeof(SDL_Surface *) * (row * column + temp->n)); if (temp_surface == NULL) { fprintf(stderr, "tenm_load_image: memory allocation to image " "(%d) failed\n", i); SDL_FreeSurface(master); if (temp->image != NULL) { for (l = 0; l < temp->n; l++) SDL_FreeSurface(temp->image[l]); free(temp->image); } free(temp); return NULL; } temp->image = temp_surface; for (j = 0; j < row; j++) for (k = 0; k < column; k++) { suffix = temp->n + j * column + k; /* plain malloc is not enough */ temp->image[suffix] = SDL_CreateRGBSurface(0, width, height, dpy->format->BitsPerPixel, dpy->format->Rmask, dpy->format->Gmask, dpy->format->Bmask, dpy->format->Amask); if (temp->image[suffix] == NULL) { fprintf(stderr, "tenm_load_image: SDL_CreateRGBSurface(%d) " "failed (%s)\n", suffix, SDL_GetError()); SDL_FreeSurface(master); for (l = 0; l < suffix; l++) SDL_FreeSurface(temp->image[l]); free(temp->image); free(temp); return NULL; } if (dpy->format->BitsPerPixel == 8) SDL_SetPalette(temp->image[suffix], SDL_LOGPAL|SDL_PHYSPAL, dpy->format->palette->colors, 0, dpy->format->palette->ncolors); temp_rect_src.x = width * k; temp_rect_src.y = row * j; temp_rect_src.w = width; temp_rect_src.h = height; temp_rect_dest.x = 0; temp_rect_dest.y = 0; temp_rect_dest.w = width; temp_rect_dest.h = height; if (SDL_BlitSurface(master, &temp_rect_src, temp->image[suffix], &temp_rect_dest) != 0) { fprintf(stderr, "tenm_load_image: SDL_BlitSurface failed (%s)\n", SDL_GetError()); SDL_FreeSurface(master); /* we need to free temp->image[suffix] too */ for (l = 0; l <= suffix; l++) SDL_FreeSurface(temp->image[l]); free(temp->image); free(temp); return NULL; } if (SDL_SetColorKey(temp->image[suffix], SDL_SRCCOLORKEY, transparent_color) != 0) { fprintf(stderr, "tenm_load_image: SDL_SetColorKey failed (%s)\n", SDL_GetError()); SDL_FreeSurface(master); /* we need to free temp->image[suffix] too */ for (l = 0; l <= suffix; l++) SDL_FreeSurface(temp->image[l]); free(temp->image); free(temp); return NULL; } } temp->n += row * column; SDL_FreeSurface(master); } va_end(ap); return temp; } void tenm_image_delete(tenm_image *p) { int i; /* sanity check */ if (p == NULL) { fprintf(stderr, "tenm_image_delete: p is NULL\n"); return; } if (p->n <= 0) { fprintf(stderr, "tenm_image_delete: p->n is non-positive (%d)\n", p->n); return; } if (p->image == NULL) { fprintf(stderr, "tenm_image_delete: p->image is NULL\n"); return; } for (i = 0; i < p->n; i++) SDL_FreeSurface(p->image[i]); free(p->image); free(p); } /* return 0 on success, 1 on error */ int tenm_draw_image(int x, int y, tenm_image *image, int number) { SDL_Rect temp; /* sanity check */ if (image == NULL) { fprintf(stderr, "tenm_draw_image: image is NULL\n"); return 1; } if (image->n <= 0) { fprintf(stderr, "tenm_draw_image: image->n is non-positive\n"); return 1; } if (image->image == NULL) { fprintf(stderr, "tenm_draw_image: image->image is NULL\n"); return 1; } if ((number < 0) || (number >= image->n)) { fprintf(stderr, "tenm_draw_image: number (%d) is out of range " "(0 -- %d)\n", number, image->n - 1); return 1; } temp.x = x; temp.y = y; temp.w = image->image[number]->w; temp.h = image->image[number]->h; if (SDL_BlitSurface(image->image[number], NULL, dpy, &temp) != 0) { fprintf(stderr, "tenm_draw_image: SDL_BlitSurface failed (%s)\n", SDL_GetError()); return 1; } return 0; } /* return 0 on success, 1 on error */ int tenm_draw_string(int x, int y, tenm_image *font, const char *string, int length) { int i; int suffix; int temp_x; int status = 0; /* sanity check */ if (font == NULL) { fprintf(stderr, "tenm_draw_string: font is NULL\n"); return 1; } if (font->n < TENM_FONT_NUMBER_CHAR) { fprintf(stderr, "tenm_draw_string: not enough images in font " "(%d) (%d required)\n", font->n, TENM_FONT_NUMBER_CHAR); return 1; } if (font->image == NULL) { fprintf(stderr, "tenm_draw_string: font->image is NULL\n"); return 1; } if (string == NULL) { fprintf(stderr, "tenm_draw_string: string is NULL\n"); return 1; } if (length <= 0) { fprintf(stderr, "tenm_draw_string: length is non-positive (%d)\n", length); return 1; } temp_x = x; for (i = 0; (i < length) && (string[i] != '\0'); i++) { if (!isprint(string[i])) { fprintf(stderr, "tenm_draw_string: char %d unprintable (\\x%x)\n", i, string[i]); status = 1; continue; } suffix = tenm_font_index(string[i]); if ((suffix < 0) || (suffix >= font->n)) { fprintf(stderr, "tenm_draw_string: tenm_font_index(%d) returned " "strange number (%d)\n", i, suffix); status = 1; continue; } if (tenm_draw_image(temp_x, y - font->image[suffix]->h / 2, font, suffix) != 0) { fprintf(stderr, "tenm_draw_string: tenm_draw_image(%d) failed\n", i); status = 1; continue; } temp_x += font->image[suffix]->w; } return status; } /* order of characters (ASCII order) * !"#$%&'()*+,-./0123456789:;<=>? * @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_ * `abcdefghijklmnopqrstuvwxyz{|}~ */ /* return a non-negative index for the character c * return -1 on error */ static int tenm_font_index(int c) { /* sanity check */ if (!isprint(c)) { fprintf(stderr, "tenm_font_index: unprintable char (\\x%x)\n", c); return -1; } /* don't assume ASCII */ switch (c) { case ' ': return 0; break; case '!': return 1; break; case '"': return 2; break; case '#': return 3; break; case '$': return 4; break; case '%': return 5; break; case '&': return 6; break; case '\'': return 7; break; case '(': return 8; break; case ')': return 9; break; case '*': return 10; break; case '+': return 11; break; case ',': return 12; break; case '-': return 13; break; case '.': return 14; break; case '/': return 15; break; case '0': return 16; break; case '1': return 17; break; case '2': return 18; break; case '3': return 19; break; case '4': return 20; break; case '5': return 21; break; case '6': return 22; break; case '7': return 23; break; case '8': return 24; break; case '9': return 25; break; case ':': return 26; break; case ';': return 27; break; case '<': return 28; break; case '=': return 29; break; case '>': return 30; break; case '?': return 31; break; case '@': return 32; break; case 'A': return 33; break; case 'B': return 34; break; case 'C': return 35; break; case 'D': return 36; break; case 'E': return 37; break; case 'F': return 38; break; case 'G': return 39; break; case 'H': return 40; break; case 'I': return 41; break; case 'J': return 42; break; case 'K': return 43; break; case 'L': return 44; break; case 'M': return 45; break; case 'N': return 46; break; case 'O': return 47; break; case 'P': return 48; break; case 'Q': return 49; break; case 'R': return 50; break; case 'S': return 51; break; case 'T': return 52; break; case 'U': return 53; break; case 'V': return 54; break; case 'W': return 55; break; case 'X': return 56; break; case 'Y': return 57; break; case 'Z': return 58; break; case '[': return 59; break; case '\\': return 60; break; case ']': return 61; break; case '^': return 62; break; case '_': return 63; break; case '`': return 64; break; case 'a': return 65; break; case 'b': return 66; break; case 'c': return 67; break; case 'd': return 68; break; case 'e': return 69; break; case 'f': return 70; break; case 'g': return 71; break; case 'h': return 72; break; case 'i': return 73; break; case 'j': return 74; break; case 'k': return 75; break; case 'l': return 76; break; case 'm': return 77; break; case 'n': return 78; break; case 'o': return 79; break; case 'p': return 80; break; case 'q': return 81; break; case 'r': return 82; break; case 's': return 83; break; case 't': return 84; break; case 'u': return 85; break; case 'v': return 86; break; case 'w': return 87; break; case 'x': return 88; break; case 'y': return 89; break; case 'z': return 90; break; case '{': return 91; break; case '|': return 92; break; case '}': return 93; break; case '~': return 94; break; default: fprintf(stderr, "tenm_font_index: unknown char (\\x%x)\n", c); return -1; break; } /* should not reach here */ fprintf(stderr, "tenm_font_index: should not reach here\n"); return -1; } /* draw a line between A(a_x, a_y) and B(b_x, b_y) * assumes b_x > a_x and abs(b_x - a_x) >= abs(b_y - a_x) * return 0 on success, 1 on error */ static int tenm_draw_line2(int a_x, int a_y, int b_x, int b_y, int width, tenm_color color, int xy_reversed) { int x; int y; int x2; int y2; int dx; int dy_abs; /* 2 * abs(b_x - a_x) * (y - y_real_line) */ int error_tilde; int error_tilde2; int y_changed; int x2_changed; int status = 0; int range; /* sanity check */ if (b_x <= a_x) { fprintf(stderr, "tenm_draw_line2: not (b_x <= a_x)\n"); return 1; } if ((b_x - a_x < a_y - b_y) || (b_x - a_x < b_y - a_y)) { fprintf(stderr, "tenm_draw_line2: not " "((b_x - a_x < a_y - b_y) || (b_x - a_x < b_y - a_y))\n"); return 1; } if (width <= 0) { fprintf(stderr, "tenm_draw_line2: width is non-positive (%d)\n", width); return 1; } dx = b_x - a_x; if (a_y >= b_y) dy_abs = a_y - b_y; else dy_abs = b_y - a_y; /* to minimize error */ if (dy_abs == 0) range = width; else range = (int) (((double) (dx * width)) / tenm_sqrt(dx * dx + dy_abs * dy_abs)); if (range <= 0) range = 1; /* the Bresenham algorithm with the "wide line" hack */ x = a_x; y = a_y; /* the next point is: * either (x + 1, y) or (x + 1, y + 1) if b_y >= a_y * either (x + 1, y) or (x + 1, y - 1) otherwise */ error_tilde = 0; y_changed = 0; while (x <= b_x) { /* Bresenham again */ x2 = 0; y2 = 0; /* not very accurate, but who cares? */ error_tilde2 = 0; x2_changed = 0; while (y2 < range) { if (xy_reversed) { if (tenm_draw_point(y + y2, x + x2, color) != 0) status = 1; if (tenm_draw_point(y - y2, x - x2, color) != 0) status = 1; } else { if (tenm_draw_point(x + x2, y + y2, color) != 0) status = 1; if (tenm_draw_point(x - x2, y - y2, color) != 0) status = 1; } if ((y_changed) && (x2_changed)) { if (xy_reversed) { if (b_y >= a_y) { if (tenm_draw_point(y + y2 - 1, x + x2, color) != 0) status = 1; if (tenm_draw_point(y - y2, x- x2 - 1, color) != 0) status = 1; } else { if (tenm_draw_point(y + y2, x + x2 - 1, color) != 0) status = 1; if (tenm_draw_point(y - y2 + 1, x - x2, color) != 0) status = 1; } } else { if (b_y >= a_y) { if (tenm_draw_point(x + x2, y + y2 - 1, color) != 0) status = 1; if (tenm_draw_point(x - x2 - 1, y - y2, color) != 0) status = 1; } else { if (tenm_draw_point(x + x2 - 1, y + y2, color) != 0) status = 1; if (tenm_draw_point(x - x2, y - y2 + 1, color) != 0) status = 1; } } } y2++; error_tilde2 += 2 * dy_abs; if (error_tilde2 >= dx) { error_tilde2 -= 2 * dx; if (b_y >= a_y) x2--; else x2++; x2_changed = 1; } else { x2_changed = 0; } } x++; error_tilde += 2 * dy_abs; if (error_tilde >= dx) { error_tilde -= 2 * dx; if (b_y >= a_y) y++; else y--; y_changed = 1; } else { y_changed = 0; } } return status; } dangen-0.5/libtenm/tenm_graphic.h0000644000175000017500000000252610276702736017700 0ustar00ooharaoohara00000000000000/* $Id: tenm_graphic.h,v 1.39 2003/02/14 17:56:16 oohara Exp $ */ #ifndef __TENM_GRAPHIC_H__ #define __TENM_GRAPHIC_H__ #include #include "tenm_primitive.h" #include "tenm_object.h" struct _tenm_image { /* number of images */ int n; SDL_Surface **image; }; typedef struct _tenm_image tenm_image; typedef Uint32 tenm_color; /* for flag in tenm_graphic_init */ #define TENM_FULLSCREEN 1 int tenm_graphic_init(int width, int height, int flag, const char *name); int tenm_draw_line(int a_x, int a_y, int b_x, int b_y, int width, tenm_color color); int tenm_draw_circle(int center_x, int center_y, int radius, int width, tenm_color color); int tenm_draw_point(int x, int y, tenm_color color); int tenm_draw_rectangle(int x, int y, int w, int h, tenm_color color); tenm_color tenm_map_color(int red, int green, int blue); int tenm_clear_window(tenm_color color); int tenm_redraw_window(void); int tenm_draw_primitive(tenm_primitive *p, tenm_color color); int tenm_draw_mass(tenm_mass *p, tenm_color color); tenm_image *tenm_load_image(int number_file, ...); void tenm_image_delete(tenm_image *p); int tenm_draw_image(int x, int y, tenm_image *image, int number); int tenm_draw_string(int x, int y, tenm_image *font, const char *string, int length); #endif /* not __TENM_GRAPHIC_H__ */ dangen-0.5/libtenm/tenm_input.c0000644000175000017500000003202210276702736017407 0ustar00ooharaoohara00000000000000/* $Id: tenm_input.c,v 1.91 2004/02/15 14:43:09 oohara Exp $ */ #include /* atexit, malloc */ #include /* for tenm_polygon_new */ #include /* errno */ #include /* strerror */ #include #include /* tenm_redraw_window() */ #include "tenm_graphic.h" /* tenm_pow2() */ #include "tenm_math.h" #include "tenm_sdl_init.h" #include "tenm_input.h" static int number_key_mask = 0; static tenm_key *key_mask = NULL; static void (*focus_handler)(int) = NULL; static SDL_Joystick *js = NULL; static int *joystick_axis_set = NULL; static tenm_key *joystick_axis_mask = NULL; static int *joystick_button_set = NULL; static tenm_key *joystick_button_mask = NULL; static int neutral_range = 8192; static int key_status; static int tenm_add_key_status(tenm_key key, int delta); static void tenm_key_quit(void); static void tenm_joystick_quit(void); /* there is no init() for keyboard because it is initialized * along with video and there is tenm_graphic_init() */ /* ... is 0 -- TENM_NUMBER_KEY_MAX (16) of (tenm_key key) * return 0 on success, 1 on error */ int tenm_set_key(int number_key, ...) { int i; va_list ap; tenm_key *temp_key_mask = NULL; /* sanity check */ if (number_key <= -1) { fprintf(stderr, "tenm_set_key: number_key is negative\n"); return 1; } if (number_key > TENM_NUMBER_KEY_MAX) { fprintf(stderr, "tenm_set_key: warning: registering only the first " "%d keys and ignoring the rest\n", TENM_NUMBER_KEY_MAX); number_key = TENM_NUMBER_KEY_MAX; } /* initialize SDL if necessary */ if (tenm_sdl_init(SDL_INIT_VIDEO) != 0) { fprintf(stderr, "tenm_set_key: cannot initialize SDL video \n"); return 1; } errno = 0; if (atexit(tenm_key_quit) != 0) { fprintf(stderr, "tenm_set_key: cannot register tenm_key_quit " "to exit"); if (errno != 0) fprintf(stderr, " (%s)", strerror(errno)); fprintf(stderr, "\n"); tenm_key_quit(); return 1; } /* don't substitute key_mask directly, or you will be in a trouble * if realloc fails */ if (key_mask == NULL) temp_key_mask = (tenm_key *) malloc(sizeof(tenm_key) * number_key); else temp_key_mask = (tenm_key *) realloc(key_mask, sizeof(tenm_key) * number_key); if (temp_key_mask == NULL) { fprintf(stderr, "tenm_event_init: memory allocation to key_mask failed\n"); tenm_key_quit(); return 1; } key_mask = temp_key_mask; number_key_mask = number_key; va_start(ap, number_key); for (i = 0; i < number_key; i++) key_mask[i] = va_arg(ap, tenm_key); va_end(ap); return 0; } void tenm_set_focus_handler(void (*handler)(int)) { focus_handler = (void (*)(int)) handler; } /* range is the maximum of the absolute value of event.jaxis.axis * that is considered to be neutral * return TENM_JOYSTICK_INIT_SUCCESS, TENM_JOYSTICK_INIT_NO_JOYSTICK * or TENM_JOYSTICK_INIT_ERROR */ int tenm_joystick_init(int range) { int i; /* sanity check */ if (range <= 0) { fprintf(stderr, "tenm_joystick_init: strange range (%d)\n", range); return TENM_JOYSTICK_INIT_ERROR; } if (SDL_WasInit(SDL_INIT_JOYSTICK) != 0) { fprintf(stderr, "tenm_joystick_init: warning: joystick is already " "initialized\n"); return TENM_JOYSTICK_INIT_SUCCESS; } if (tenm_sdl_init(SDL_INIT_JOYSTICK) != 0) { fprintf(stderr, "tenm_joystick_init: cannot initialize SDL joystick " "(%s)\n", SDL_GetError()); return TENM_JOYSTICK_INIT_ERROR; } errno = 0; if (atexit(tenm_joystick_quit) != 0) { fprintf(stderr, "tenm_joystick_init: cannot register tenm_joystick_quit " "to exit"); if (errno != 0) fprintf(stderr, " (%s)", strerror(errno)); fprintf(stderr, "\n"); tenm_joystick_quit(); return TENM_JOYSTICK_INIT_ERROR; } if (SDL_NumJoysticks() <= 0) { fprintf(stderr, "tenm_joystick_init: no joystick found\n"); /* this is not a fatal error --- you should fall back to a keyboard */ return TENM_JOYSTICK_INIT_NO_JOYSTICK; } if (js != NULL) { fprintf(stderr, "tenm_joystick_init: js is already set\n"); /* this is a fatal error --- if we are here, joystick is not * initialized before tenm_joystick_init() is called, so * the situation is weird enough */ tenm_joystick_quit(); return TENM_JOYSTICK_INIT_ERROR; } js = SDL_JoystickOpen(0); if (js == NULL) { fprintf(stderr, "tenm_joystick_init: cannot open joystick 1 (%s)\n", SDL_GetError()); tenm_joystick_quit(); return TENM_JOYSTICK_INIT_ERROR; } if (SDL_JoystickEventState(SDL_ENABLE) != SDL_ENABLE) { fprintf(stderr, "tenm_set_key: cannot enable SDL joystick event " "processing (%s)\n", SDL_GetError()); tenm_joystick_quit(); return TENM_JOYSTICK_INIT_ERROR; } if (joystick_axis_set != NULL) { fprintf(stderr, "tenm_joystick_init: warning: joystick_axis_set is " "not NULL, freeing\n"); free(joystick_axis_set); joystick_axis_set = NULL; } joystick_axis_set = (int *) malloc(sizeof(int) * 4); if (joystick_axis_set == NULL) { fprintf(stderr, "tenm_joystick_init: malloc(joystick_axis_set) failed\n"); tenm_joystick_quit(); return TENM_JOYSTICK_INIT_ERROR; } for (i = 0; i < 4; i++) joystick_axis_set[i] = 0; if (joystick_axis_mask != NULL) { fprintf(stderr, "tenm_joystick_init: warning: joystick_axis_mask is " "not NULL, freeing\n"); free(joystick_axis_mask); joystick_axis_mask = NULL; } joystick_axis_mask = (tenm_key *) malloc(sizeof(tenm_key) * 4); if (joystick_axis_mask == NULL) { fprintf(stderr, "tenm_joystick_init: malloc(joystick_axis_mask) failed\n"); tenm_joystick_quit(); return TENM_JOYSTICK_INIT_ERROR; } if (joystick_button_set != NULL) { fprintf(stderr, "tenm_joystick_init: warning: joystick_button_set is " "not NULL, freeing\n"); free(joystick_button_set); joystick_button_set = NULL; } joystick_button_set = (int *) malloc(sizeof(int) * (TENM_NUMBER_KEY_MAX -4)); if (joystick_button_set == NULL) { fprintf(stderr, "tenm_joystick_init: malloc(joystick_button_set) " "failed\n"); tenm_joystick_quit(); return TENM_JOYSTICK_INIT_ERROR; } for (i = 0; i < TENM_NUMBER_KEY_MAX - 4; i++) joystick_button_set[i] = 0; if (joystick_button_mask != NULL) { fprintf(stderr, "tenm_joystick_init: warning: joystick_button_mask is " "not NULL, freeing\n"); free(joystick_button_mask); joystick_button_mask = NULL; } joystick_button_mask = (tenm_key *) malloc(sizeof(tenm_key) * (TENM_NUMBER_KEY_MAX - 4)); if (joystick_button_mask == NULL) { fprintf(stderr, "tenm_joystick_init: malloc(joystick_button_mask) " "failed\n"); tenm_joystick_quit(); return TENM_JOYSTICK_INIT_ERROR; } neutral_range = range; return TENM_JOYSTICK_INIT_SUCCESS; } /* translate a direction of a joystick axis into a key * return 0 on success, 1 on error */ int tenm_joystick_map_axis(int direction, tenm_key key) { /* sanity check */ if ((direction < 0) || (direction >= 4)) { fprintf(stderr, "tenm_joystick_map_axis: strange direction (%d)\n", direction); return 1; } if ((joystick_axis_set == NULL) || (joystick_axis_mask == NULL)) { fprintf(stderr, "tenm_joystick_map_axis: joystick is not initialized\n"); return 1; } joystick_axis_set[direction] = 1; joystick_axis_mask[direction] = key; return 0; } /* translate a button of a joystick axis into a key * return 0 on success, 1 on error */ int tenm_joystick_map_button(int button_index, tenm_key key) { /* sanity check */ if ((button_index < 0) || (button_index >= 12)) { fprintf(stderr, "tenm_joystick_map_button: strange button_index (%d)\n", button_index); return 1; } if ((joystick_button_set == NULL) || (joystick_button_mask == NULL)) { fprintf(stderr, "tenm_joystick_map_button: joystick is not initialized\n"); return 1; } joystick_button_set[button_index] = 1; joystick_button_mask[button_index] = key; return 0; } int tenm_get_key_status(void) { return key_status; } /* return 1 if the program should quit, 0 if not */ int tenm_event_handle(void) { SDL_Event event; while (SDL_PollEvent(&event) > 0) { if (event.type == SDL_QUIT) return 1; if (event.type == SDL_VIDEOEXPOSE) { tenm_redraw_window(); } else if (event.type == SDL_ACTIVEEVENT) { if (event.active.gain == 1) { /* the mouse cursor entered the window */ if (focus_handler != NULL) (*focus_handler)(1); } else { /* the mouse cursor left the window */ if (focus_handler != NULL) (*focus_handler)(0); } } else if (event.type == SDL_KEYDOWN) { tenm_add_key_status(event.key.keysym.sym, 1); } else if (event.type == SDL_KEYUP) { tenm_add_key_status(event.key.keysym.sym, -1); } else if (event.type == SDL_JOYAXISMOTION) { if ((joystick_axis_set == NULL) || (joystick_axis_mask == NULL)) { fprintf(stderr, "tenm_event_handle: SDL_JOYAXISMOTION event happened " "while joystick is not initialized, ignoring\n"); continue; } if (event.jaxis.axis == 0) { /* left/right (mutually exclusive) */ if (joystick_axis_set[TENM_JOYSTICK_LEFT]) { if (event.jaxis.value < -neutral_range) tenm_add_key_status(joystick_axis_mask[TENM_JOYSTICK_LEFT], 1); else tenm_add_key_status(joystick_axis_mask[TENM_JOYSTICK_LEFT], -1); } if (joystick_axis_set[TENM_JOYSTICK_RIGHT]) { if (event.jaxis.value > neutral_range) tenm_add_key_status(joystick_axis_mask[TENM_JOYSTICK_RIGHT], 1); else tenm_add_key_status(joystick_axis_mask[TENM_JOYSTICK_RIGHT], -1); } } else if (event.jaxis.axis == 1) { /* up/down (mutually exclusive) */ if (joystick_axis_set[TENM_JOYSTICK_UP]) { if (event.jaxis.value < -neutral_range) tenm_add_key_status(joystick_axis_mask[TENM_JOYSTICK_UP], 1); else tenm_add_key_status(joystick_axis_mask[TENM_JOYSTICK_UP], -1); } if (joystick_axis_set[TENM_JOYSTICK_DOWN]) { if (event.jaxis.value > neutral_range) tenm_add_key_status(joystick_axis_mask[TENM_JOYSTICK_DOWN], 1); else tenm_add_key_status(joystick_axis_mask[TENM_JOYSTICK_DOWN], -1); } } } else if (event.type == SDL_JOYBUTTONDOWN) { if ((joystick_button_set == NULL) || (joystick_button_mask == NULL)) { fprintf(stderr, "tenm_event_handle: SDL_JOYBUTTONDOWN event happened " "while joystick is not initialized, ignoring\n"); continue; } /* event.jbutton.button is always nonnegative because it is unsigned */ if ((event.jbutton.button < TENM_NUMBER_KEY_MAX - 4) && (joystick_button_set[event.jbutton.button])) tenm_add_key_status(joystick_button_mask[event.jbutton.button], 1); } else if (event.type == SDL_JOYBUTTONUP) { if ((joystick_button_set == NULL) || (joystick_button_mask == NULL)) { fprintf(stderr, "tenm_event_handle: SDL_JOYBUTTONUP event happened " "while joystick is not initialized, ignoring\n"); continue; } /* event.jbutton.button is always nonnegative because it is unsigned */ if ((event.jbutton.button < TENM_NUMBER_KEY_MAX - 4) && (joystick_button_set[event.jbutton.button])) tenm_add_key_status(joystick_button_mask[event.jbutton.button], -1); } } return 0; } /* positive delta means the key is pressed * negative delta means the key is released */ static int tenm_add_key_status(tenm_key key, int delta) { int i; int value = 0; for (i = 0; i < number_key_mask; i++) if (key == key_mask[i]) value = tenm_pow2(i); if (value == 0) { /* unknown key */ return 0; } if (delta > 0) key_status |= value; else if (delta < 0) key_status &= ~value; else return 1; return 0; } static void tenm_key_quit(void) { number_key_mask = 0; if (key_mask != NULL) { free(key_mask); key_mask = NULL; } } static void tenm_joystick_quit(void) { if (js != NULL) { SDL_JoystickClose(js); js = NULL; } if (joystick_axis_set != NULL) { free(joystick_axis_set); joystick_axis_set = NULL; } if (joystick_axis_mask != NULL) { free(joystick_axis_mask); joystick_axis_mask = NULL; } if (joystick_button_set != NULL) { free(joystick_button_set); joystick_button_set = NULL; } if (joystick_button_mask != NULL) { free(joystick_button_mask); joystick_button_mask = NULL; } neutral_range = 8192; if (SDL_WasInit(SDL_INIT_JOYSTICK) != 0) SDL_QuitSubSystem(SDL_INIT_JOYSTICK); } dangen-0.5/libtenm/tenm_input.h0000644000175000017500000001235410276702736017422 0ustar00ooharaoohara00000000000000/* $Id: tenm_input.h,v 1.28 2002/07/13 07:50:20 oohara Exp $ */ #ifndef __TENM_INPUT_H__ #define __TENM_INPUT_H__ #include typedef SDLKey tenm_key; /* we assume int is at least 32 bit long, so 16 is a safe value */ #define TENM_NUMBER_KEY_MAX 16 /* renaming key flags just for its own sake --- well, it will save you * when you try to port this to non-SDL system */ #define TENM_KEY_BACKSPACE SDLK_BACKSPACE #define TENM_KEY_TAB SDLK_TAB #define TENM_KEY_CLEAR SDLK_CLEAR #define TENM_KEY_RETURN SDLK_RETURN #define TENM_KEY_PAUSE SDLK_PAUSE #define TENM_KEY_ESCAPE SDLK_ESCAPE #define TENM_KEY_SPACE SDLK_SPACE #define TENM_KEY_EXCLAIM SDLK_EXCLAIM #define TENM_KEY_QUOTEDBL SDLK_QUOTEDBL #define TENM_KEY_HASH SDLK_HASH #define TENM_KEY_DOLLAR SDLK_DOLLAR #define TENM_KEY_AMPERSAND SDLK_AMPERSAND #define TENM_KEY_QUOTE SDLK_QUOTE #define TENM_KEY_LEFTPAREN SDLK_LEFTPAREN #define TENM_KEY_RIGHTPAREN SDLK_RIGHTPAREN #define TENM_KEY_ASTERISK SDLK_ASTERISK #define TENM_KEY_PLUS SDLK_PLUS #define TENM_KEY_COMMA SDLK_COMMA #define TENM_KEY_MINUS SDLK_MINUS #define TENM_KEY_PERIOD SDLK_PERIOD #define TENM_KEY_SLASH SDLK_SLASH #define TENM_KEY_0 SDLK_0 #define TENM_KEY_1 SDLK_1 #define TENM_KEY_2 SDLK_2 #define TENM_KEY_3 SDLK_3 #define TENM_KEY_4 SDLK_4 #define TENM_KEY_5 SDLK_5 #define TENM_KEY_6 SDLK_6 #define TENM_KEY_7 SDLK_7 #define TENM_KEY_8 SDLK_8 #define TENM_KEY_9 SDLK_9 #define TENM_KEY_COLON SDLK_COLON #define TENM_KEY_SEMICOLON SDLK_SEMICOLON #define TENM_KEY_LESS SDLK_LESS #define TENM_KEY_EQUALS SDLK_EQUALS #define TENM_KEY_GREATER SDLK_GREATER #define TENM_KEY_QUESTION SDLK_QUESTION #define TENM_KEY_AT SDLK_AT #define TENM_KEY_LEFTBRACKET SDLK_LEFTBRACKET #define TENM_KEY_BACKSLASH SDLK_BACKSLASH #define TENM_KEY_RIGHTBRACKET SDLK_RIGHTBRACKET #define TENM_KEY_CARET SDLK_CARET #define TENM_KEY_UNDERSCORE SDLK_UNDERSCORE #define TENM_KEY_BACKQUOTE SDLK_BACKQUOTE #define TENM_KEY_a SDLK_a #define TENM_KEY_b SDLK_b #define TENM_KEY_c SDLK_c #define TENM_KEY_d SDLK_d #define TENM_KEY_e SDLK_e #define TENM_KEY_f SDLK_f #define TENM_KEY_g SDLK_g #define TENM_KEY_h SDLK_h #define TENM_KEY_i SDLK_i #define TENM_KEY_j SDLK_j #define TENM_KEY_k SDLK_k #define TENM_KEY_l SDLK_l #define TENM_KEY_m SDLK_m #define TENM_KEY_n SDLK_n #define TENM_KEY_o SDLK_o #define TENM_KEY_p SDLK_p #define TENM_KEY_q SDLK_q #define TENM_KEY_r SDLK_r #define TENM_KEY_s SDLK_s #define TENM_KEY_t SDLK_t #define TENM_KEY_u SDLK_u #define TENM_KEY_v SDLK_v #define TENM_KEY_w SDLK_w #define TENM_KEY_x SDLK_x #define TENM_KEY_y SDLK_y #define TENM_KEY_z SDLK_z #define TENM_KEY_DELETE SDLK_DELETE #define TENM_KEY_KP0 SDLK_KP0 #define TENM_KEY_KP1 SDLK_KP1 #define TENM_KEY_KP2 SDLK_KP2 #define TENM_KEY_KP3 SDLK_KP3 #define TENM_KEY_KP4 SDLK_KP4 #define TENM_KEY_KP5 SDLK_KP5 #define TENM_KEY_KP6 SDLK_KP6 #define TENM_KEY_KP7 SDLK_KP7 #define TENM_KEY_KP8 SDLK_KP8 #define TENM_KEY_KP9 SDLK_KP9 #define TENM_KEY_KP_PERIOD SDLK_KP_PERIOD #define TENM_KEY_KP_DIVIDE SDLK_KP_DIVIDE #define TENM_KEY_KP_MULTIPLY SDLK_KP_MULTIPLY #define TENM_KEY_KP_MINUS SDLK_KP_MINUS #define TENM_KEY_KP_PLUS SDLK_KP_PLUS #define TENM_KEY_KP_ENTER SDLK_KP_ENTER #define TENM_KEY_KP_EQUALS SDLK_KP_EQUALS #define TENM_KEY_UP SDLK_UP #define TENM_KEY_DOWN SDLK_DOWN #define TENM_KEY_RIGHT SDLK_RIGHT #define TENM_KEY_LEFT SDLK_LEFT #define TENM_KEY_INSERT SDLK_INSERT #define TENM_KEY_HOME SDLK_HOME #define TENM_KEY_END SDLK_END #define TENM_KEY_PAGEUP SDLK_PAGEUP #define TENM_KEY_PAGEDOWN SDLK_PAGEDOWN #define TENM_KEY_F1 SDLK_F1 #define TENM_KEY_F2 SDLK_F2 #define TENM_KEY_F3 SDLK_F3 #define TENM_KEY_F4 SDLK_F4 #define TENM_KEY_F5 SDLK_F5 #define TENM_KEY_F6 SDLK_F6 #define TENM_KEY_F7 SDLK_F7 #define TENM_KEY_F8 SDLK_F8 #define TENM_KEY_F9 SDLK_F9 #define TENM_KEY_F10 SDLK_F10 #define TENM_KEY_F11 SDLK_F11 #define TENM_KEY_F12 SDLK_F12 #define TENM_KEY_F13 SDLK_F13 #define TENM_KEY_F14 SDLK_F14 #define TENM_KEY_F15 SDLK_F15 #define TENM_KEY_NUMLOCK SDLK_NUMLOCK #define TENM_KEY_CAPSLOCK SDLK_CAPSLOCK #define TENM_KEY_SCROLLOCK SDLK_SCROLLOCK #define TENM_KEY_RSHIFT SDLK_RSHIFT #define TENM_KEY_LSHIFT SDLK_LSHIFT #define TENM_KEY_RCTRL SDLK_RCTRL #define TENM_KEY_LCTRL SDLK_LCTRL #define TENM_KEY_RALT SDLK_RALT #define TENM_KEY_LALT SDLK_LALT #define TENM_KEY_RMETA SDLK_RMETA #define TENM_KEY_LMETA SDLK_LMETA #define TENM_KEY_LSUPER SDLK_LSUPER #define TENM_KEY_RSUPER SDLK_RSUPER #define TENM_KEY_MODE SDLK_MODE #define TENM_KEY_HELP SDLK_HELP #define TENM_KEY_PRINT SDLK_PRINT #define TENM_KEY_SYSREQ SDLK_SYSREQ #define TENM_KEY_BREAK SDLK_BREAK #define TENM_KEY_MENU SDLK_MENU #define TENM_KEY_POWER SDLK_POWER #define TENM_KEY_EURO SDLK_EURO /* for the return value of tenm_joystick_init() */ #define TENM_JOYSTICK_INIT_SUCCESS 0 #define TENM_JOYSTICK_INIT_NO_JOYSTICK 1 #define TENM_JOYSTICK_INIT_ERROR 2 /* for direction (arg 1) of tenm_joystick_map_axis() */ #define TENM_JOYSTICK_UP 0 #define TENM_JOYSTICK_DOWN 1 #define TENM_JOYSTICK_RIGHT 2 #define TENM_JOYSTICK_LEFT 3 int tenm_set_key(int number_key, ...); void tenm_set_focus_handler(void (*handler)(int)); int tenm_joystick_init(int range); int tenm_joystick_map_axis(int direction, tenm_key key); int tenm_joystick_map_button(int button_index, tenm_key key); int tenm_get_key_status(void); int tenm_event_handle(void); #endif /* not __TENM_INPUT_H__ */ dangen-0.5/libtenm/tenm_math.c0000644000175000017500000001075210276702736017207 0ustar00ooharaoohara00000000000000/* $Id: tenm_math.c,v 1.24 2003/01/14 03:03:58 oohara Exp $ */ #include /* malloc, atexit */ #include #include /* errno */ #include /* strerror */ #include #include "tenm_math.h" /* L said, "Easy, it's 3.1415926... [2.38M digits followed]" */ static double pi = 3.1415; static double *sin_table = NULL; static double *cos_table = NULL; static double *sqrt_table = NULL; static int sqrt_table_size = 0; static int *pow2_table = NULL; static int pow2_table_size = 0; static void tenm_math_quit(void); /* return 0 on success, 1 on error */ int tenm_math_init(int sqrt_size, int pow2_size) { int i; int temp = 1; pi = acos(-1.0); /* sanity check */ if (sqrt_size <= 0) { fprintf(stderr, "tenm_math_init: sqrt_size is non-positive\n"); return 1; } if (pow2_size <= 0) { fprintf(stderr, "tenm_math_init: pow2_size is non-positive\n"); return 1; } if (sin_table != NULL) { fprintf(stderr, "tenm_math_init: warning: sin_table is not NULL," "freeing\n"); free(sin_table); sin_table = NULL; } sin_table = (double *) malloc(sizeof(double) * 360); if (sin_table == NULL) { fprintf(stderr, "tenm_math_init: malloc(sin_table) failed\n"); tenm_math_quit(); return 1; } sin_table[0] = 0.0; sin_table[90] = 1.0; sin_table[180] = 0.0; sin_table[270] = -1.0; if (cos_table != NULL) { fprintf(stderr, "tenm_math_init: warning: cos_table is not NULL," "freeing\n"); free(cos_table); cos_table = NULL; } cos_table = (double *) malloc(sizeof(double) * 360); if (cos_table == NULL) { fprintf(stderr, "tenm_math_init: malloc(cos_table) failed\n"); tenm_math_quit(); return 1; } cos_table[0] = 1.0; cos_table[90] = 0.0; cos_table[180] = -1.0; cos_table[270] = 0.0; if (sqrt_table != NULL) { fprintf(stderr, "tenm_math_init: warning: sqrt_table is not NULL," "freeing\n"); free(sqrt_table); sqrt_table = NULL; } sqrt_table = (double *) malloc(sizeof(double) * sqrt_size); if (sqrt_table == NULL) { fprintf(stderr, "tenm_math_init: malloc(sqrt_table) failed\n"); tenm_math_quit(); return 1; } if (pow2_table != NULL) { fprintf(stderr, "tenm_math_init: warning: pow2_table is not NULL," "freeing\n"); free(pow2_table); pow2_table = NULL; } pow2_table = (int *) malloc(sizeof(int) * pow2_size); if (pow2_table == NULL) { fprintf(stderr, "tenm_math_init: malloc(pow2_table) failed\n"); tenm_math_quit(); return 1; } errno = 0; if (atexit(tenm_math_quit) != 0) { fprintf(stderr, "tenm_math_init: cannot register tenm_math_quit " " to exit"); if (errno != 0) fprintf(stderr, " (%s)", strerror(errno)); fprintf(stderr, "\n"); tenm_math_quit(); return 1; } for (i = 0; i < 360; i++) sin_table[i] = sin(2.0 * pi * ((double) i) / 360.0); for (i = 0; i < 360; i++) cos_table[i] = cos(2.0 * pi * ((double) i) / 360.0); sqrt_table_size = sqrt_size; for (i = 0; i < sqrt_size; i++) sqrt_table[i] = sqrt((double) i); temp = 1; pow2_table_size = pow2_size; for (i = 0; i < pow2_size; i++) { pow2_table[i] = temp; temp *= 2; } return 0; } double tenm_sin(int theta) { if (sin_table == NULL) return sin(2.0 * pi * ((double) theta) / 360.0); while (theta < 0) theta += 360; while (theta >= 360) theta -= 360; return sin_table[theta]; } double tenm_cos(int theta) { if (cos_table == NULL) return cos(2.0 * pi * ((double) theta) / 360.0); while (theta < 0) theta += 360; while (theta >= 360) theta -= 360; return cos_table[theta]; } double tenm_sqrt(int n) { if (n < 0) return 0.0; if (sqrt_table == NULL) return sqrt((double) n); if (n >= sqrt_table_size) return sqrt((double) n); return sqrt_table[n]; } /* return 0 if n is negative */ int tenm_pow2(int n) { int temp = 1; if (n < 0) return 0; if ((pow2_table == NULL) || (n >= pow2_table_size)) { for (; n > 0; n--) temp *= 2; return temp; } return pow2_table[n]; } static void tenm_math_quit(void) { pi = 3.1415; if (sin_table != NULL) { free(sin_table); sin_table = NULL; } if (cos_table != NULL) { free(cos_table); cos_table = NULL; } if (sqrt_table != NULL) { free(sqrt_table); sqrt_table = NULL; } sqrt_table_size = 0; if (pow2_table != NULL) { free(pow2_table); pow2_table = NULL; } pow2_table_size = 0; } dangen-0.5/libtenm/tenm_math.h0000644000175000017500000000045210276702736017210 0ustar00ooharaoohara00000000000000/* $Id: tenm_math.h,v 1.6 2002/05/10 11:01:25 oohara Exp $ */ #ifndef __TENM_MATH_H__ #define __TENM_MATH_H__ int tenm_math_init(int sqrt_size, int pow2_size); double tenm_sin(int theta); double tenm_cos(int theta); double tenm_sqrt(int n); int tenm_pow2(int n); #endif /* not __TENM_MATH_H__ */ dangen-0.5/libtenm/tenm_object.c0000644000175000017500000001227210276702736017523 0ustar00ooharaoohara00000000000000/* $Id: tenm_object.c,v 1.43 2003/02/11 11:39:35 oohara Exp $ */ #include /* malloc */ #include /* strlen, strncpy */ #include #include "tenm_collision.h" #include "tenm_object.h" tenm_mass * tenm_mass_new(int number_primitive, tenm_primitive **p) { tenm_mass *temp; /* sanity check */ if (number_primitive <= 0) { fprintf(stderr, "tenm_mass_new: number_primitive is non-positive (%d)\n", number_primitive); return NULL; } temp = (tenm_mass *) malloc(sizeof(tenm_mass)); if (temp == NULL) { fprintf(stderr, "tenm_mass_new: malloc failed\n"); return NULL; } temp->n = number_primitive; temp->p = p; return temp; } void tenm_mass_delete(tenm_mass *p) { int i; if (p == NULL) { fprintf(stderr, "tenm_mass_delete: p is NULL\n"); return; } if (p->n <= 0) { fprintf(stderr, "tenm_mass_delete: p->n is non-positive (%d)\n", p->n); return; } if (p->p == NULL) { fprintf(stderr, "tenm_mass_delete: p->p is NULL\n"); return; } for (i = 0; i < p->n; i++) if (p->p[i] != NULL) (*(p->p[i]->delete))(p->p[i]); free(p->p); free(p); } /* name (arg 1) is duplicated * count (arg 8), count_d (arg 10), p (arg 12) and the callback functions * (arg 13 -- 16) are passed directly --- you must NOT free them manually * (tenm_object_delete() does not free the callback functions) */ tenm_object * tenm_object_new(const char *name, int attr, int hit_mask, int hit_point, double x, double y, int number_count, int *count, int number_count_d, double *count_d, int number_primitive, tenm_primitive **p, int (*move)(tenm_object *, double), int (*hit)(tenm_object *, tenm_object *), int (*act)(tenm_object *, const tenm_object *), int (*draw)(tenm_object *, int)) { tenm_object *temp; temp = (tenm_object *) malloc(sizeof(tenm_object)); if (temp == NULL) { fprintf(stderr, "tenm_object_new: malloc(temp) failed\n"); return NULL; } if (name != NULL) { /* +1 is for the trailing \0 */ temp->name = (char *) malloc(sizeof(char) * (strlen(name) + 1)); if (temp->name == NULL) { fprintf(stderr, "tenm_object_new: malloc(temp->name) failed\n"); free(temp); return NULL; } strncpy(temp->name, name, strlen(name)); temp->name[strlen(name)] = '\0'; } temp->mass = NULL; if (number_primitive >= 1) { if (p == NULL) { fprintf(stderr, "tenm_object_new: p is NULL\n"); if (name != NULL) free(temp->name); free(temp); return NULL; } temp->mass = tenm_mass_new(number_primitive, p); if (temp->mass == NULL) { fprintf(stderr, "tenm_object_new: tenm_mass_new failed\n"); if (name != NULL) free(temp->name); free(temp); return NULL; } } temp->table_index = -1; /* temp->name is set above */ temp->attr = attr; temp->hit_mask = hit_mask; temp->hit_point = hit_point; temp->x = x; temp->y = y; temp->n = number_count; temp->count = count; temp->n_d = number_count_d; temp->count_d = count_d; temp->move = (int (*)(void *, double)) move; temp->hit = (int (*)(void *, void *)) hit; temp->act = (int (*)(void *, const void *)) act; temp->draw = (int (*)(void *, int)) draw; return temp; } void tenm_object_delete(tenm_object *p) { if (p == NULL) { fprintf(stderr, "tenm_object_delete: p is NULL\n"); return; } if (p->name != NULL) free(p->name); if (p->mass != NULL) tenm_mass_delete(p->mass); if (p->count_d != NULL) free(p->count_d); if (p->count != NULL) free(p->count); free(p); } /* return 1 (true) or 0 (false) */ int tenm_collided_mass(tenm_mass *p, tenm_mass *q) { int i; int j; /* sanity check */ if (p == NULL) { fprintf(stderr, "tenm_collided_mass: p is NULL\n"); return 0; } if (p->n <= 0) { fprintf(stderr, "tenm_collided_mass: p->n is non-positive\n"); return 0; } if (p->p == NULL) { fprintf(stderr, "tenm_collided_mass: p->p is NULL\n"); return 0; } if (q == NULL) { fprintf(stderr, "tenm_collided_mass: q is NULL\n"); return 0; } if (q->n <= 0) { fprintf(stderr, "tenm_collided_mass: q->n is non-positive\n"); return 0; } if (q->p == NULL) { fprintf(stderr, "tenm_collided_mass: q->p is NULL\n"); return 0; } for (i = 0; i < p->n; i++) for (j = 0; j < q->n; j++) if (tenm_collided_primitive(p->p[i], q->p[j])) return 1; return 0; } /* return 0 on success, 1 on error */ int tenm_move_mass(tenm_mass *p, double dx, double dy) { int i; int status = 0; /* sanity check */ if (p == NULL) { fprintf(stderr, "tenm_move_mass: p is NULL\n"); return 1; } if (p->n <= 0) { fprintf(stderr, "tenm_move_mass: p->n is non-positive\n"); return 1; } if (p->p == NULL) { fprintf(stderr, "tenm_move_mass: p->p is NULL\n"); return 1; } for (i = 0; i < p->n; i++) { if (tenm_move_primitive(p->p[i], dx, dy) != 0) { fprintf(stderr, "tenm_move_mass: tenm_move_primitive(%d) failed\n", i); status = 1; } } return status; } dangen-0.5/libtenm/tenm_object.h0000644000175000017500000000337310276702736017532 0ustar00ooharaoohara00000000000000/* $Id: tenm_object.h,v 1.44 2003/02/11 11:19:37 oohara Exp $ */ #ifndef __TENM_OBJECT_H__ #define __TENM_OBJECT_H__ #include "tenm_primitive.h" struct _tenm_mass { /* number of primitives */ int n; tenm_primitive **p; }; typedef struct _tenm_mass tenm_mass; struct _tenm_object { int table_index; char *name; int attr; int hit_mask; int hit_point; double x; double y; /* number of count */ int n; int *count; /* number of count_d */ int n_d; double *count_d; tenm_mass *mass; /* pointer for these functions must be void because tenm_object is not * yet defined */ int (*move)(void *, double); int (*hit)(void *, void *); /* action other than move (such as shoot) */ int (*act)(void *, const void *); int (*draw)(void *, int); /* there is no need to put *tenm_image in this struct */ }; typedef struct _tenm_object tenm_object; tenm_mass *tenm_mass_new(int number_primitive, tenm_primitive **p); void tenm_mass_delete(tenm_mass *p); tenm_object *tenm_object_new(const char *name, int attr, int hit_mask, int hit_point, double x, double y, int number_count, int *count, int number_count_d, double *count_d, int number_primitive, tenm_primitive **p, int (*move)(tenm_object *, double), int (*hit)(tenm_object *, tenm_object *), int (*act)(tenm_object *, const tenm_object *), int (*draw)(tenm_object *, int)); void tenm_object_delete(tenm_object *p); int tenm_collided_mass(tenm_mass *p, tenm_mass *q); int tenm_move_mass(tenm_mass *p, double dx, double dy); #endif /* not __TENM_OBJECT_H__ */ dangen-0.5/libtenm/tenm_primitive.c0000644000175000017500000001567110276702736020273 0ustar00ooharaoohara00000000000000/* $Id: tenm_primitive.c,v 1.8 2003/01/14 02:58:24 oohara Exp $ */ #include /* malloc */ #include /* for tenm_polygon_new */ #include #include "tenm_primitive.h" #define NEAR_ZERO 0.0001 tenm_point * tenm_point_new(double x, double y) { tenm_point *temp; temp = (tenm_point *) malloc(sizeof(tenm_point)); if (temp == NULL) { fprintf(stderr, "tenm_point_new: malloc failed\n"); return NULL; } ((tenm_primitive *) temp)->klass = TENM_POINT; ((tenm_primitive *) temp)->delete = (void (*)(void *)) tenm_point_delete; temp->x = x; temp->y = y; return temp; } void tenm_point_delete(tenm_point *p) { /* sanity check */ if (p == NULL) { fprintf(stderr, "tenm_point_delete: p is NULL\n"); return; } free(p); } tenm_circle * tenm_circle_new(double center_x, double center_y, double radius) { tenm_circle *temp; /* sanity check */ if (radius < NEAR_ZERO) { fprintf(stderr, "tenm_circle_new: radius is non-positive (%f)\n", radius); return NULL; } temp = (tenm_circle *) malloc(sizeof(tenm_circle)); if (temp == NULL) { fprintf(stderr, "tenm_circle_new: malloc failed\n"); return NULL; } ((tenm_primitive *) temp)->klass = TENM_CIRCLE; ((tenm_primitive *) temp)->delete = (void (*)(void *)) tenm_circle_delete; temp->center = tenm_point_new(center_x, center_y); if (temp->center == NULL) { fprintf(stderr, "tenm_circle_new: tenm_point_new failed\n"); free(temp); return NULL; } temp->r = radius; return temp; } void tenm_circle_delete(tenm_circle *p) { /* sanity check */ if (p == NULL) { fprintf(stderr, "tenm_circle_delete: p is NULL"); return; } if (p->center == NULL) { fprintf(stderr, "tenm_circle_delete: p->center is NULL"); return; } tenm_point_delete(p->center); free(p); } tenm_segment * tenm_segment_new(double a_x, double a_y, double b_x, double b_y) { tenm_segment *temp; temp = (tenm_segment *) malloc(sizeof(tenm_segment)); if (temp == NULL) { fprintf(stderr, "tenm_segment_new: malloc failed\n"); return NULL; } ((tenm_primitive *) temp)->klass = TENM_SEGMENT; ((tenm_primitive *) temp)->delete = (void (*)(void *)) tenm_segment_delete; temp->a = tenm_point_new(a_x, a_y); if (temp->a == NULL) { fprintf(stderr, "tenm_segment_new: tenm_point_new(a) failed\n"); free(temp); return NULL; } temp->b = tenm_point_new(b_x, b_y); if (temp->b == NULL) { fprintf(stderr, "tenm_segment_new: tenm_point_new(b) failed\n"); tenm_point_delete(temp->a); free(temp); return NULL; } return temp; } void tenm_segment_delete(tenm_segment *p) { if (p == NULL) { fprintf(stderr, "tenm_segment_delete: p is NULL\n"); return; } if (p->a == NULL) { fprintf(stderr, "tenm_segment_delete: p->a is NULL\n"); return; } if (p->b == NULL) { fprintf(stderr, "tenm_segment_delete: p->b is NULL\n"); return; } tenm_point_delete(p->b); tenm_point_delete(p->a); free(p); } /* ... is 3 or more of (double x, double y) */ tenm_polygon * tenm_polygon_new(int number_vertex, ...) { va_list ap; int i; int j; double x; double y; tenm_polygon *temp; /* sanity check */ if (number_vertex < 3) { fprintf(stderr, "tenm_polygon_new: strange number_vertex (%d)\n", number_vertex); return NULL; } temp = (tenm_polygon *) malloc(sizeof(tenm_polygon)); if (temp == NULL) { fprintf(stderr, "tenm_polygon_new: malloc failed\n"); return NULL; } temp->v = (tenm_point **) malloc(sizeof(tenm_point *) * number_vertex); if (temp->v == NULL) { fprintf(stderr, "tenm_polygon_new: malloc(v) failed\n"); free(temp); return NULL; } ((tenm_primitive *) temp)->klass = TENM_POLYGON; ((tenm_primitive *) temp)->delete = (void (*)(void *)) tenm_polygon_delete; va_start(ap, number_vertex); for (i = 0; i < number_vertex; i++) { x = va_arg(ap, double); y = va_arg(ap, double); temp->v[i] = tenm_point_new(x, y); if (temp->v[i] == NULL) { fprintf(stderr, "tenm_polygon_new: tenm_point_new(%d) failed\n", i); for (j = 0; j < i; j++) tenm_point_delete(temp->v[j]); free(temp); va_end(ap); return NULL; } } temp->n = number_vertex; va_end(ap); return temp; } void tenm_polygon_delete(tenm_polygon *p) { int j; if (p == NULL) { fprintf(stderr, "tenm_polygon_delete: p is NULL\n"); return; } if (p->n < 3) { fprintf(stderr, "tenm_polygon_delete: strange p->n (%d)\n", p->n); return; } if (p->v == NULL) { fprintf(stderr, "tenm_polygon_delete: p->v is NULL\n"); return; } for (j = 0; j < p->n; j++) { if (p->v[j] == NULL) { fprintf(stderr, "tenm_polygon_delete: p->v[%d] is NULL\n", j); return; } tenm_point_delete(p->v[j]); } free(p->v); free(p); } int tenm_move_primitive(tenm_primitive *p, double dx, double dy) { int i; if (p == NULL) { fprintf(stderr, "tenm_move_primitive: p is NULL\n"); return 1; } switch (p->klass) { case TENM_POINT: ((tenm_point *) p)->x += dx; ((tenm_point *) p)->y += dy; return 0; break; case TENM_CIRCLE: if (((tenm_circle *) p)->center == NULL) { fprintf(stderr, "tenm_move_primitive: " "((tenm_circle *) p)->center is NULL\n"); return 1; } ((tenm_circle *) p)->center->x += dx; ((tenm_circle *) p)->center->y += dy; return 0; break; case TENM_SEGMENT: if (((tenm_segment *) p)->a == NULL) { fprintf(stderr, "tenm_move_primitive: " "((tenm_segment *) p)->a is NULL\n"); return 1; } if (((tenm_segment *) p)->b == NULL) { fprintf(stderr, "tenm_move_primitive: " "((tenm_segment *) p)->b is NULL\n"); return 1; } ((tenm_segment *) p)->a->x += dx; ((tenm_segment *) p)->a->y += dy; ((tenm_segment *) p)->b->x += dx; ((tenm_segment *) p)->b->y += dy; return 0; break; case TENM_POLYGON: if (((tenm_polygon *) p)->v == NULL) { fprintf(stderr, "tenm_move_primitive: " "((tenm_polygon *) p)->v is NULL\n"); return 1; } if (((tenm_polygon *) p)->n < 3) { fprintf(stderr, "tenm_move_primitive: " "strange ((tenm_polygon *) p)->n (%d)\n", ((tenm_polygon *) p)->n); return 1; } for (i = 0; i < ((tenm_polygon *) p)->n; i++) { if (((tenm_polygon *) p)->v[i] == NULL) { fprintf(stderr, "tenm_move_primitive: " "((tenm_polygon *) p)->v[%d] is NULL\n", i); return 1; } ((tenm_polygon *) p)->v[i]->x += dx; ((tenm_polygon *) p)->v[i]->y += dy; } return 0; break; default: fprintf(stderr, "tenm_move_primitive: strange primitive found (%d)\n", p->klass); return 1; break; } /* should not reach here */ fprintf(stderr, "tenm_move_primitive: should not reach here\n"); return 1; } dangen-0.5/libtenm/tenm_primitive.h0000644000175000017500000000314410276702736020270 0ustar00ooharaoohara00000000000000/* $Id: tenm_primitive.h,v 1.6 2003/02/11 11:14:23 oohara Exp $ */ #ifndef __TENM_PRIMITIVE_H__ #define __TENM_PRIMITIVE_H__ struct _tenm_primitive { int klass; void (*delete)(void *); }; typedef struct _tenm_primitive tenm_primitive; /* "parent" must be first to to use inheritance in C (not C++) */ struct _tenm_point { tenm_primitive parent; double x; double y; }; typedef struct _tenm_point tenm_point; struct _tenm_circle { tenm_primitive parent; tenm_point *center; /* radius */ double r; }; typedef struct _tenm_circle tenm_circle; struct _tenm_segment { tenm_primitive parent; /* each end of the segment */ tenm_point *a; tenm_point *b; }; typedef struct _tenm_segment tenm_segment; struct _tenm_polygon { tenm_primitive parent; /* number of vertexes */ int n; /* coordinates of vertexes */ tenm_point **v; }; typedef struct _tenm_polygon tenm_polygon; /* these values must be one of 3^n so that we can add any two of them * and get a unique number */ #define TENM_POINT 1 #define TENM_CIRCLE 3 #define TENM_SEGMENT 9 #define TENM_POLYGON 27 tenm_point *tenm_point_new(double x, double y); void tenm_point_delete(tenm_point *p); tenm_circle *tenm_circle_new(double center_x, double center_y, double radius); void tenm_circle_delete(tenm_circle *p); tenm_segment *tenm_segment_new(double a_x, double a_y, double b_x, double b_y); void tenm_segment_delete(tenm_segment *p); tenm_polygon *tenm_polygon_new(int number_vertex, ...); void tenm_polygon_delete(tenm_polygon *p); int tenm_move_primitive(tenm_primitive *p, double dx, double dy); #endif /* not __TENM_PRIMITIVE_H__ */ dangen-0.5/libtenm/tenm_sdl_init.c0000644000175000017500000000216710276702736020064 0ustar00ooharaoohara00000000000000/* $Id: tenm_sdl_init.c,v 1.2 2003/01/14 03:04:59 oohara Exp $ */ #include /* atexit */ #include /* errno */ #include /* strerror */ #include #include #include "tenm_sdl_init.h" /* return 0 on success, 1 on error */ int tenm_sdl_init(Uint32 flags) { if (SDL_WasInit(flags) != flags) { if (SDL_WasInit(SDL_INIT_EVERYTHING) != 0) { if (SDL_InitSubSystem(flags) != 0) { { fprintf(stderr, "tenm_sdl_init: cannot initialize subsystem of SDL " "(%s)\n", SDL_GetError()); return 1; } } } else { if (SDL_Init(flags) != 0) { fprintf(stderr, "tenm_sdl_init: cannot initialize SDL " "(%s)\n", SDL_GetError()); return 1; } errno = 0; if (atexit(SDL_Quit) != 0) { fprintf(stderr, "tenm_sdl_init: " "cannot register SDL_Quit to exit"); if (errno != 0) fprintf(stderr, " (%s)", strerror(errno)); fprintf(stderr, "\n"); SDL_Quit(); return 1; } } } return 0; } dangen-0.5/libtenm/tenm_sdl_init.h0000644000175000017500000000041510276702736020063 0ustar00ooharaoohara00000000000000/* $Id: tenm_sdl_init.h,v 1.1 2002/07/09 23:28:31 oohara Exp $ */ #ifndef __TENM_SDL_INIT_H__ #define __TENM_SDL_INIT_H__ #include /* we use Uint32 here this is for internal use only */ int tenm_sdl_init(Uint32 flags); #endif /* not __TENM_SDL_INIT_H__ */ dangen-0.5/libtenm/tenm_table.c0000644000175000017500000002504510276702736017346 0ustar00ooharaoohara00000000000000/* $Id: tenm_table.c,v 1.56 2003/08/31 12:34:01 oohara Exp $ */ #include /* malloc, atexit */ #include /* errno */ #include /* strerror */ #include #include "tenm_object.h" #include "tenm_table.h" static int table_size = 0; static int table_draw_min_priority = 0; static int table_draw_max_priority = -1; static tenm_object **object_table = NULL; static int *action_needed = NULL; static void tenm_table_quit(void); /* return 0 on success, 1 on error */ int tenm_table_init(int size, int draw_min_priority, int draw_max_priority) { int i; /* sanity check */ if (draw_min_priority > draw_max_priority) { fprintf(stderr, "tenm_table_init: draw_min_priority > " "draw_max_priority\n"); /* this is a fatal error */ return 1; } if (object_table != NULL) { fprintf(stderr, "tenm_table_init: warning: object_table is not NULL," "freeing\n"); tenm_table_clear_all(); free(object_table); object_table = NULL; } object_table = (tenm_object **) malloc(sizeof(tenm_object *) * size); if (object_table == NULL) { fprintf(stderr, "tenm_table_init: malloc(object_table) failed\n"); tenm_table_quit(); return 1; } if (action_needed != NULL) { fprintf(stderr, "tenm_table_init: warning: action_needed is not NULL," "freeing\n"); free(action_needed); action_needed = NULL; } action_needed = (int *) malloc(sizeof(int) * size); if (action_needed == NULL) { fprintf(stderr, "tenm_table_init: malloc(action_needed) failed\n"); tenm_table_quit(); return 1; } errno = 0; if (atexit(tenm_table_quit) != 0) { fprintf(stderr, "tenm_table_init: cannot register tenm_table_quit " "to exit"); if (errno != 0) fprintf(stderr, " (%s)", strerror(errno)); fprintf(stderr, "\n"); tenm_table_quit(); return 1; } table_size = size; for (i = 0; i < size; i++) { object_table[i] = NULL; action_needed[i] = 1; } table_draw_min_priority = draw_min_priority; table_draw_max_priority = draw_max_priority; return 0; } /* return the index of the table on success, -1 on error */ int tenm_table_add(tenm_object *object) { int i; /* sanity check */ if (object == NULL) { fprintf(stderr, "tenm_table_add: object is NULL\n"); return -1; } if ((object_table == NULL) || (action_needed == NULL)) { fprintf(stderr, "tenm_table_add: table is not initialized\n"); return -1; } for (i = 0; i < table_size; i++) if (object_table[i] == NULL) { object->table_index = i; object_table[i] = object; action_needed[i] = 0; return i; } fprintf(stderr, "tenm_table_add: no more space\n"); return -1; } void tenm_table_delete(int i) { if (object_table == NULL) return; if (object_table[i] == NULL) return; if (action_needed == NULL) return; tenm_object_delete(object_table[i]); object_table[i] = NULL; action_needed[i] = 1; } void tenm_table_clear_all(void) { int i; if (object_table == NULL) return; for (i = 0; i < table_size; i++) if (object_table[i] != NULL) tenm_table_delete(i); } /* return 1 if player is deleted, 0 if not */ int tenm_table_move(tenm_object *player, int turn_per_frame) { int i; double tpf = (double) turn_per_frame; /* sanity check */ if ((object_table == NULL) || (action_needed == NULL)) { fprintf(stderr, "tenm_table_move: table is not initialized\n"); return 0; } if (turn_per_frame < 1) { fprintf(stderr, "tenm_table_move: strange turn_per_frame (%d)\n", turn_per_frame); return 0; } for (i = 0; i < table_size; i++) { if (object_table[i] == NULL) continue; if (object_table[i]->move == NULL) continue; if ((*(object_table[i]->move))(object_table[i], tpf)) tenm_table_delete(i); } if (player == NULL) return 0; if (player->move == NULL) return 0; if ((*(player->move))(player, tpf)) { tenm_object_delete(player); /* note that this "player" is a local variable */ player = NULL; return 1; } return 0; } /* return 1 if player is deleted, 0 if not */ int tenm_table_detect_collision(tenm_object *player) { int i; int j; int i_need_delete = 0; int j_need_delete = 0; int status = 0; /* sanity check */ if ((object_table == NULL) || (action_needed == NULL)) { fprintf(stderr, "tenm_table_detect_collision: table is not initialized\n"); return 0; } /* collision between objects */ for (i = 0; i < table_size; i++) for (j = i + 1; j < table_size; j++) { if (object_table[i] == NULL) continue; if (object_table[j] == NULL) continue; /* no need to detect collision if there is nothing to do when * they collide */ if ((!(object_table[i]->hit_mask & object_table[j]->attr)) && (!(object_table[j]->hit_mask & object_table[i]->attr))) continue; if ((object_table[i]->hit == NULL) && (object_table[j]->hit == NULL)) continue; if (object_table[i]->mass == NULL) continue; if (object_table[j]->mass == NULL) continue; if (! tenm_collided_mass(object_table[i]->mass, object_table[j]->mass)) continue; i_need_delete = 0; j_need_delete = 0; if ((object_table[i] != NULL) && (object_table[j] != NULL) && (object_table[i]->hit_mask & object_table[j]->attr)) if ((object_table[i]->hit != NULL) && ((*(object_table[i]->hit))(object_table[i], object_table[j]) != 0)) i_need_delete = 1; /* we have to check if the objects are not NULL because * hit() of object_table[i] may delete object_table[j] * via tenm_table_apply() */ if ((object_table[i] != NULL) && (object_table[j] != NULL) && (object_table[j]->hit_mask & object_table[i]->attr)) if ((object_table[j]->hit != NULL) && ((*(object_table[j]->hit))(object_table[j], object_table[i]) != 0)) j_need_delete = 1; if (i_need_delete) tenm_table_delete(i); if (j_need_delete) tenm_table_delete(j); } /* collison between player and object */ for (i = 0; i < table_size; i++) { if (object_table[i] == NULL) continue; if (player == NULL) continue; /* no need to detect collision if there is nothing to do when * they collide */ if ((!(object_table[i]->hit_mask & player->attr)) && (!(player->hit_mask & object_table[i]->attr))) continue; if ((object_table[i]->hit == NULL) && (player->hit == NULL)) continue; if (object_table[i]->mass == NULL) continue; if (player->mass == NULL) continue; if (! tenm_collided_mass(object_table[i]->mass, player->mass)) continue; i_need_delete = 0; j_need_delete = 0; if ((object_table[i] != NULL) && (player != NULL) && (object_table[i]->hit_mask & player->attr)) if ((object_table[i]->hit != NULL) && ((*(object_table[i]->hit))(object_table[i], player) != 0)) i_need_delete = 1; if ((object_table[i] != NULL) && (player != NULL) && (player->hit_mask & object_table[i]->attr)) if ((player->hit != NULL) && ((*(player->hit))(player, object_table[i]) != 0)) j_need_delete = 1; if (i_need_delete) tenm_table_delete(i); if (j_need_delete) { tenm_object_delete(player); /* note that this "player" is a local variable */ player = NULL; status = 1; } } return status; } /* return 1 if player is deleted, 0 if not */ int tenm_table_do_action(tenm_object *player) { int i; /* sanity check */ if ((object_table == NULL) || (action_needed == NULL)) { fprintf(stderr, "tenm_table_do_action: table is not initialized\n"); return 0; } for (i = 0; i < table_size; i++) { if (object_table[i] == NULL) continue; if (object_table[i]->act == NULL) continue; if (action_needed[i] == 0) continue; if ((*(object_table[i]->act))(object_table[i], player) != 0) tenm_table_delete(i); } if (player == NULL) return 0; if (player->act == NULL) return 0; if ((*(player->act))(player, NULL) != 0) { tenm_object_delete(player); /* note that this "player" is a local variable */ player = NULL; return 1; } for (i = 0; i < table_size; i++) action_needed[i] = 1; return 0; } /* return 0 on success, 1 on error */ int tenm_table_draw(tenm_object *player) { int i; int j; int status = 0; /* sanity check */ if ((object_table == NULL) || (action_needed == NULL)) { fprintf(stderr, "tenm_table_draw: table is not initialized\n"); return 0; } for (i = table_draw_min_priority; i <= table_draw_max_priority; i++) { if ((player != NULL) && (player->draw != NULL)) { if ((*(player->draw))(player, i) != 0) status = 1; } for (j = 0; j < table_size; j++) { if (object_table[j] == NULL) continue; if (object_table[j]->draw == NULL) continue; if ((*(object_table[j]->draw))(object_table[j], i) != 0) status = 1; } } return status; } void tenm_table_apply(int i, int (*func)(tenm_object *, int), int n) { /* sanity check */ if ((object_table == NULL) || (action_needed == NULL)) { fprintf(stderr, "tenm_table_apply: table is not initialized\n"); return; } if (func == NULL) { fprintf(stderr, "tenm_table_apply: func is NULL\n"); return; } if ((i < 0) || (i >= table_size)) { fprintf(stderr, "tenm_table_apply: i (%d) is out of range (0 -- %d)\n", i, table_size - 1); return; } if (object_table[i] == NULL) return; if ((*func)(object_table[i], n) != 0) tenm_table_delete(i); } void tenm_table_apply_all(int (*func)(tenm_object *, int), int n) { int i; /* sanity check */ if ((object_table == NULL) || (action_needed == NULL)) { fprintf(stderr, "tenm_table_apply_all: table is not initialized\n"); return; } if (func == NULL) { fprintf(stderr, "tenm_table_apply_all: func is NULL\n"); return; } for (i = 0; i < table_size; i++) tenm_table_apply(i, (int (*)(tenm_object *, int)) func, n); } static void tenm_table_quit(void) { table_size = 0; table_draw_min_priority = 0; table_draw_max_priority = -1; if (object_table != NULL) { tenm_table_clear_all(); free(object_table); object_table = NULL; } if (action_needed != NULL) { free(action_needed); action_needed = NULL; } } dangen-0.5/libtenm/tenm_table.h0000644000175000017500000000127510276702736017352 0ustar00ooharaoohara00000000000000/* $Id: tenm_table.h,v 1.16 2002/05/30 21:45:58 oohara Exp $ */ #ifndef __TENM_TABLE_H__ #define __TENM_TABLE_H__ #include "tenm_object.h" int tenm_table_init(int size, int draw_min_priority, int draw_max_priority); int tenm_table_add(tenm_object *object); void tenm_table_delete(int i); void tenm_table_clear_all(void); int tenm_table_move(tenm_object *player, int turn_per_frame); int tenm_table_detect_collision(tenm_object *player); int tenm_table_do_action(tenm_object *player); int tenm_table_draw(tenm_object *player); void tenm_table_apply(int i, int (*func)(tenm_object *, int), int n); void tenm_table_apply_all(int (*func)(tenm_object *, int), int n); #endif /* not __TENM_TABLE_H__ */ dangen-0.5/libtenm/tenm_timer.c0000644000175000017500000000527711276326165017403 0ustar00ooharaoohara00000000000000/* $Id: tenm_timer.c,v 1.65 2009/11/10 18:09:57 oohara Exp $ */ #include /* exit */ #include #include #include "tenm_sdl_init.h" #include "tenm_timer.h" /* The problem of SDL timer is that its granularity is 10 ms, that is, * if the machine doesn't have a good hardware clock, whenever SDL_Delay() * returns, (SDL_GetTicks() % 10) is always same. In this case, * a simple SDL_Delay(delay - (now - past)) is not enough. */ static Uint32 tick = 0; static Uint32 tick_master = 0; static int number_wait = 0; static int clock_granularity = 0; /* return 0 on success, 1 on error */ int tenm_timer_init(int num_wait) { int i; int t; Uint32 tick_begin; /* sanity check */ if (num_wait <= 0) { fprintf(stderr, "tenm_timer_init: strange num_wait (%d)\n", num_wait); return 1; } if (tenm_sdl_init(SDL_INIT_TIMER) != 0) { fprintf(stderr, "tenm_timer_init: cannot initialize SDL timer\n"); return 1; } number_wait = num_wait; /* jump to another 10 ms */ SDL_Delay(10); /* clock accuracy tests */ tick_begin = SDL_GetTicks(); for (i = 0; i < 10; i++) SDL_Delay(1); t = SDL_GetTicks() - tick_begin; if (t > 0) t = t / 10 + 1; if (t < 1) t = 1; clock_granularity = t; tenm_timer_reset(); return 0; } void tenm_timer_reset(void) { tick_master = SDL_GetTicks(); tick = tick_master; } /* return 0 on success, 1 on error */ int tenm_wait_next_frame(void) { Uint32 tick_now; tick_now = SDL_GetTicks(); if (tick_now < tick) { fprintf(stderr, "tenm_wait_next_frame: SDL_GetTicks ticks backward!\n"); return 1; } /* yes, this is stupid, but it offers maximum accuracy */ if (clock_granularity> 0) { while (tick_now + clock_granularity < tick + number_wait * 10) { SDL_Delay(1); tick_now = SDL_GetTicks(); } } while (tick_now < tick + number_wait * 10) tick_now = SDL_GetTicks(); tick = SDL_GetTicks(); return 0; } /* return average number of frames per second since tenm_timer_init() or * tenm_timer_reset() is called * return -1.0 on error */ double tenm_calculate_fps(int frame_passed) { Uint32 time_passed; /* sanity check */ if (frame_passed < 0) { fprintf(stderr, "tenm_calculate_fps: " "negative frame_passed\n"); return -1.0; } time_passed = SDL_GetTicks(); if (time_passed < tick_master) { fprintf(stderr, "tenm_calculate_fps: " "SDL_GetTicks ticks backward!\n"); return -1.0; } if (time_passed == tick_master) { fprintf(stderr, "tenm_calculate_fps: " "no time passed\n"); return -1.0; } time_passed -= tick_master; return 1000.0 * ((double) frame_passed) / ((double) time_passed); } dangen-0.5/libtenm/tenm_timer.h0000644000175000017500000000044310276702736017377 0ustar00ooharaoohara00000000000000/* $Id: tenm_timer.h,v 1.8 2002/05/27 11:17:46 oohara Exp $ */ #ifndef __TENM_TIMER_H__ #define __TENM_TIMER_H__ int tenm_timer_init(int num_wait); void tenm_timer_reset(void); int tenm_wait_next_frame(void); double tenm_calculate_fps(int frame_passed); #endif /* not __TENM_TIMER_H__ */ dangen-0.5/record/0000777000175000017500000000000011625724131014702 5ustar00ooharaoohara00000000000000dangen-0.5/record/Makefile.am0000644000175000017500000000230711625011657016736 0ustar00ooharaoohara00000000000000## Makefile.am for dangen/record ## process this file with automake --foreign to generate Makefile.in # $Id: Makefile.am,v 1.12 2011/08/23 20:55:11 oohara Exp $ noinst_LIBRARIES = librecord.a # automake doesn't know that bison generates .h from .y, # so we must add .h to SOURCES and BUILT_SOURCES librecord_a_SOURCES = record_data.c \ record_data.h \ record_io.c \ record_io.h \ record_lexical.h \ record_lexical.l \ record_parser.h \ record_parser.y \ record_parser_private.h \ record_parser_public.h \ record_util.c \ record_util.h BUILT_SOURCES = record_parser.h AM_YFLAGS = -d # -olex.yy.c is a workaround for automake braindamage AM_LFLAGS = -Precord_ -olex.yy.c -Cfe -8 #CC_WARNINGS = -Wall # the overkill warnings # I don't use -Wtraditional because I use string concatenation # use -Wno-long-long because -pedantic implies -Wlong-long CC_WARNINGS = -Wall -Wshadow -Wpointer-arith -Wcast-qual \ -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \ -Wmissing-declarations -Wnested-externs -Winline -pedantic -Wno-long-long # -g -O2 are in CFLAGS by default, don't use @CFLAGS@ here AM_CFLAGS = $(CC_WARNINGS) AM_CPPFLAGS = -I$(top_srcdir) \ -I$(top_srcdir)/spqr dangen-0.5/record/Makefile.in0000644000175000017500000003473611625012016016750 0ustar00ooharaoohara00000000000000# Makefile.in generated by automake 1.11 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # $Id: Makefile.am,v 1.12 2011/08/23 20:55:11 oohara Exp $ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : subdir = record DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ record_lexical.c record_parser.c record_parser.h ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LIBRARIES = $(noinst_LIBRARIES) AR = ar ARFLAGS = cru librecord_a_AR = $(AR) $(ARFLAGS) librecord_a_LIBADD = am_librecord_a_OBJECTS = record_data.$(OBJEXT) record_io.$(OBJEXT) \ record_lexical.$(OBJEXT) record_parser.$(OBJEXT) \ record_util.$(OBJEXT) librecord_a_OBJECTS = $(am_librecord_a_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ LEXCOMPILE = $(LEX) $(LFLAGS) $(AM_LFLAGS) YLWRAP = $(top_srcdir)/ylwrap YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS) SOURCES = $(librecord_a_SOURCES) DIST_SOURCES = $(librecord_a_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build_alias = @build_alias@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LIBRARIES = librecord.a # automake doesn't know that bison generates .h from .y, # so we must add .h to SOURCES and BUILT_SOURCES librecord_a_SOURCES = record_data.c \ record_data.h \ record_io.c \ record_io.h \ record_lexical.h \ record_lexical.l \ record_parser.h \ record_parser.y \ record_parser_private.h \ record_parser_public.h \ record_util.c \ record_util.h BUILT_SOURCES = record_parser.h AM_YFLAGS = -d # -olex.yy.c is a workaround for automake braindamage AM_LFLAGS = -Precord_ -olex.yy.c -Cfe -8 #CC_WARNINGS = -Wall # the overkill warnings # I don't use -Wtraditional because I use string concatenation # use -Wno-long-long because -pedantic implies -Wlong-long CC_WARNINGS = -Wall -Wshadow -Wpointer-arith -Wcast-qual \ -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \ -Wmissing-declarations -Wnested-externs -Winline -pedantic -Wno-long-long # -g -O2 are in CFLAGS by default, don't use @CFLAGS@ here AM_CFLAGS = $(CC_WARNINGS) AM_CPPFLAGS = -I$(top_srcdir) \ -I$(top_srcdir)/spqr all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .c .l .o .obj .y $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign record/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign record/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) record_parser.h: record_parser.c @if test ! -f $@; then \ rm -f record_parser.c; \ $(MAKE) $(AM_MAKEFLAGS) record_parser.c; \ else :; fi librecord.a: $(librecord_a_OBJECTS) $(librecord_a_DEPENDENCIES) -rm -f librecord.a $(librecord_a_AR) librecord.a $(librecord_a_OBJECTS) $(librecord_a_LIBADD) $(RANLIB) librecord.a mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/record_data.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/record_io.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/record_lexical.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/record_parser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/record_util.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .l.c: $(am__skiplex) $(SHELL) $(YLWRAP) $< $(LEX_OUTPUT_ROOT).c $@ -- $(LEXCOMPILE) .y.c: $(am__skipyacc) $(SHELL) $(YLWRAP) $< y.tab.c $@ y.tab.h $*.h y.output $*.output -- $(YACCCOMPILE) ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-am all-am: Makefile $(LIBRARIES) installdirs: install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -rm -f record_lexical.c -rm -f record_parser.c -rm -f record_parser.h -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) clean: clean-am clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: all check install install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-noinstLIBRARIES ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: dangen-0.5/record/record_lexical.c0000644000175000017500000017064611625461012020033 0ustar00ooharaoohara00000000000000#line 2 "record_lexical.c" #line 4 "record_lexical.c" #define YY_INT_ALIGNED short int /* A lexical scanner generated by flex */ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 #define YY_FLEX_SUBMINOR_VERSION 33 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ #include #include #include #include /* end standard C headers. */ /* flex integer type definitions */ #ifndef FLEXINT_H #define FLEXINT_H /* C99 systems have . Non-C99 systems may or may not. */ #if __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 #endif #include typedef int8_t flex_int8_t; typedef uint8_t flex_uint8_t; typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; #endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN #define INT8_MIN (-128) #endif #ifndef INT16_MIN #define INT16_MIN (-32767-1) #endif #ifndef INT32_MIN #define INT32_MIN (-2147483647-1) #endif #ifndef INT8_MAX #define INT8_MAX (127) #endif #ifndef INT16_MAX #define INT16_MAX (32767) #endif #ifndef INT32_MAX #define INT32_MAX (2147483647) #endif #ifndef UINT8_MAX #define UINT8_MAX (255U) #endif #ifndef UINT16_MAX #define UINT16_MAX (65535U) #endif #ifndef UINT32_MAX #define UINT32_MAX (4294967295U) #endif #endif /* ! FLEXINT_H */ #ifdef __cplusplus /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST #else /* ! __cplusplus */ #if __STDC__ #define YY_USE_CONST #endif /* __STDC__ */ #endif /* ! __cplusplus */ #ifdef YY_USE_CONST #define yyconst const #else #define yyconst #endif /* Returned upon end-of-file. */ #define YY_NULL 0 /* Promotes a possibly negative, possibly signed char to an unsigned * integer for use as an array index. If the signed char is negative, * we want to instead treat it as an 8-bit unsigned char, hence the * double cast. */ #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN (yy_start) = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START (((yy_start) - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) /* Special action meaning "start processing a new file". */ #define YY_NEW_FILE record_restart(record_in ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ #ifndef YY_BUF_SIZE #define YY_BUF_SIZE 16384 #endif /* The state buf must be large enough to hold one state per character in the main buffer. */ #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) #ifndef YY_TYPEDEF_YY_BUFFER_STATE #define YY_TYPEDEF_YY_BUFFER_STATE typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif extern int record_leng; extern FILE *record_in, *record_out; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires * access to the local variable yy_act. Since yyless() is a macro, it would break * existing scanners that call yyless() from OUTSIDE record_lex. * One obvious solution it to make yy_act a global. I tried that, and saw * a 5% performance hit in a non-record_lineno scanner, because yy_act is * normally declared as a register variable-- so it is not worth it. */ #define YY_LESS_LINENO(n) \ do { \ int yyl;\ for ( yyl = n; yyl < record_leng; ++yyl )\ if ( record_text[yyl] == '\n' )\ --record_lineno;\ }while(0) /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ { \ /* Undo effects of setting up record_text. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ *yy_cp = (yy_hold_char); \ YY_RESTORE_YY_MORE_OFFSET \ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ YY_DO_BEFORE_ACTION; /* set up record_text again */ \ } \ while ( 0 ) #define unput(c) yyunput( c, (yytext_ptr) ) /* The following is because we cannot portably get our hands on size_t * (without autoconf's help, which isn't available because we want * flex-generated scanners to compile on their own). */ #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T typedef unsigned int yy_size_t; #endif #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state { FILE *yy_input_file; char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ /* Size of input buffer in bytes, not including room for EOB * characters. */ yy_size_t yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. */ int yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to * delete it. */ int yy_is_our_buffer; /* Whether this is an "interactive" input source; if so, and * if we're using stdio for input, then we want to use getc() * instead of fread(), to make sure we stop fetching input after * each newline. */ int yy_is_interactive; /* Whether we're considered to be at the beginning of a line. * If so, '^' rules will be active on the next match, otherwise * not. */ int yy_at_bol; int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ /* Whether to try to fill the input buffer when we reach the * end of it. */ int yy_fill_buffer; int yy_buffer_status; #define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 /* When an EOF's been seen but there's still some text to process * then we mark the buffer as YY_EOF_PENDING, to indicate that we * shouldn't try reading from the input source any more. We might * still have a bunch of tokens to match, though, because of * possible backing-up. * * When we actually see the EOF, we change the status to "new" * (via record_restart()), so that the user can continue scanning by * just pointing record_in at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ /* Stack of input buffers. */ static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general * "scanner state". * * Returns the top of the stack, or NULL. */ #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ : NULL) /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] /* yy_hold_char holds the character lost when record_text is formed. */ static char yy_hold_char; static int yy_n_chars; /* number of characters read into yy_ch_buf */ int record_leng; /* Points to current character in buffer. */ static char *yy_c_buf_p = (char *) 0; static int yy_init = 0; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ /* Flag which is used to allow record_wrap()'s to do buffer switches * instead of setting up a fresh record_in. A bit of a hack ... */ static int yy_did_buffer_switch_on_eof; void record_restart (FILE *input_file ); void record__switch_to_buffer (YY_BUFFER_STATE new_buffer ); YY_BUFFER_STATE record__create_buffer (FILE *file,int size ); void record__delete_buffer (YY_BUFFER_STATE b ); void record__flush_buffer (YY_BUFFER_STATE b ); void record_push_buffer_state (YY_BUFFER_STATE new_buffer ); void record_pop_buffer_state (void ); static void record_ensure_buffer_stack (void ); static void record__load_buffer_state (void ); static void record__init_buffer (YY_BUFFER_STATE b,FILE *file ); #define YY_FLUSH_BUFFER record__flush_buffer(YY_CURRENT_BUFFER ) YY_BUFFER_STATE record__scan_buffer (char *base,yy_size_t size ); YY_BUFFER_STATE record__scan_string (yyconst char *yy_str ); YY_BUFFER_STATE record__scan_bytes (yyconst char *bytes,int len ); void *record_alloc (yy_size_t ); void *record_realloc (void *,yy_size_t ); void record_free (void * ); #define yy_new_buffer record__create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ record_ensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ record__create_buffer(record_in,YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ record_ensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ record__create_buffer(record_in,YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ #define record_wrap() 1 #define YY_SKIP_YYWRAP typedef unsigned char YY_CHAR; FILE *record_in = (FILE *) 0, *record_out = (FILE *) 0; typedef int yy_state_type; extern int record_lineno; int record_lineno = 1; extern char *record_text; #define yytext_ptr record_text static yyconst flex_int16_t yy_nxt[][28] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 3, 4, 5, 5, 4, 6, 6, 7, 8, 9, 4, 4, 4, 4, 10, 4, 4, 4, 4, 11, 4, 12, 4, 13, 14, 4, 4, 4 }, { 3, 4, 5, 5, 4, 6, 6, 7, 8, 9, 4, 4, 4, 4, 10, 4, 4, 4, 4, 11, 4, 12, 4, 13, 14, 4, 4, 4 }, { -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3 }, { 3, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4 }, { 3, -5, 15, 15, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5 }, { 3, -6, -6, -6, -6, -6, -6, -6, 16, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6 }, { 3, -7, -7, -7, 17, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7 }, { 3, -8, -8, -8, -8, -8, -8, -8, 16, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8 }, { 3, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9 }, { 3, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, 18, -10, -10, -10, -10, -10, -10, -10, -10 }, { 3, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, 19, -11, -11 }, { 3, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, 20, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12 }, { 3, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, 21, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, 22, -13, -13, -13 }, { 3, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, 23, -14, -14, -14, -14, -14, -14, -14 }, { 3, -15, 15, 15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15 }, { 3, -16, -16, -16, -16, -16, -16, -16, 16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16 }, { 3, 24, 24, 24, 25, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24 }, { 3, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, 26, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18 }, { 3, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, 27, -19, -19, -19, -19, -19, -19, -19, -19, -19 }, { 3, -20, -20, -20, -20, -20, -20, -20, -20, -20, 28, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20 }, { 3, -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, 29, -21, -21, -21, -21, -21, -21, -21 }, { 3, -22, -22, -22, -22, -22, -22, -22, -22, -22, 30, -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, -22 }, { 3, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, 31, -23, -23, -23 }, { 3, 24, 24, 24, 25, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24 }, { 3, 24, 24, 24, 24, 24, 24, 32, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24 }, { 3, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26 }, { 3, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, 33, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27 }, { 3, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, 34, -28, -28, -28, -28, -28, -28, -28, -28 }, { 3, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, 35, -29, -29, -29, -29, -29 }, { 3, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, 36, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30 }, { 3, -31, -31, -31, -31, -31, -31, -31, -31, -31, 37, -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, -31 }, { 3, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32 }, { 3, -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, 38, -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, -33 }, { 3, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34 }, { 3, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, 39, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35 }, { 3, -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, 40, -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, -36, -36 }, { 3, -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, -37, 41, -37, -37, -37, -37, -37, -37, -37, -37, -37, -37 }, { 3, -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, 42, -38, -38, -38, -38, -38 }, { 3, -39, -39, -39, -39, -39, 43, -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, -39, -39 }, { 3, -40, -40, -40, -40, -40, 44, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40 }, { 3, -41, -41, -41, -41, -41, 45, -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, -41 }, { 3, -42, -42, -42, -42, -42, 46, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42 }, { 3, -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, 47, -43, -43, -43, -43, -43, -43, -43, -43, -43 }, { 3, -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, 48, -44, -44, -44, 49, -44, -44, -44, -44, -44, -44, 50, -44, -44, -44, -44 }, { 3, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, 51, -45, -45, -45, -45 }, { 3, -46, -46, -46, -46, -46, -46, -46, -46, -46, -46, -46, 52, -46, -46, -46, -46, -46, -46, -46, -46, 53, -46, -46, -46, -46, -46, -46 }, { 3, -47, -47, -47, -47, -47, -47, -47, -47, -47, 54, -47, -47, -47, -47, -47, 55, -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, -47 }, { 3, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, 56, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48 }, { 3, -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, 57, -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, -49 }, { 3, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, 58, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50 }, { 3, -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, 59, -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, -51 }, { 3, -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, 60, -52, -52, -52, -52, -52, -52, -52, -52, -52, -52 }, { 3, -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, 61, -53, -53, -53, -53, -53, -53, -53, -53, -53, -53 }, { 3, -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, 62, -54 }, { 3, -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, 63, -55, -55, -55, -55, -55, -55, -55, -55 }, { 3, -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, 64, -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, -56, -56 }, { 3, -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, -57, -57 }, { 3, -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, -58, 65, -58, -58, -58, -58, -58, -58, -58 }, { 3, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, 66, -59, -59, -59, -59, -59, -59, -59 }, { 3, -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, 67, -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, -60 }, { 3, -61, -61, -61, -61, -61, -61, -61, -61, -61, 68, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61 }, { 3, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62, -62 }, { 3, -63, -63, -63, -63, -63, 69, -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, -63, -63 }, { 3, -64, -64, -64, -64, -64, -64, -64, -64, -64, 70, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64 }, { 3, -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, -65, 71, -65, -65, -65, -65, -65 }, { 3, -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, 72, -66, -66, -66, -66, -66 }, { 3, -67, -67, -67, -67, -67, -67, -67, -67, -67, 73, -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, -67 }, { 3, -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, -68, 74 }, { 3, -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, 75, -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, -69, -69 }, { 3, -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, -70, 76, -70, -70, -70, -70, -70 }, { 3, -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, 77, -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, -71, -71 }, { 3, -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, 78, -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, -72, -72 }, { 3, -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, -73, 79, -73, -73, -73, -73, -73 }, { 3, -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, -74 }, { 3, -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, -75, 80, -75, -75, -75, -75, -75, -75, -75, -75, -75, -75 }, { 3, -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, 81, -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, -76, -76 }, { 3, -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, -77, -77 }, { 3, -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, -78 }, { 3, -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, -79, -79 }, { 3, -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, 82, -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, -80 }, { 3, -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, 83, -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, -81, -81 }, { 3, -82, -82, -82, -82, -82, -82, -82, -82, -82, 84, -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, -82 }, { 3, -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, -83, -83 }, { 3, -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, -84, 85, -84, -84, -84, -84, -84 }, { 3, -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, 86, -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, -85, -85 }, { 3, -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, 87, -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, -86 }, { 3, -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, -87, -87 }, } ; static yy_state_type yy_get_previous_state (void ); static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); static int yy_get_next_buffer (void ); static void yy_fatal_error (yyconst char msg[] ); /* Done after the current pattern has been matched and before the * corresponding action - sets up record_text. */ #define YY_DO_BEFORE_ACTION \ (yytext_ptr) = yy_bp; \ record_leng = (size_t) (yy_cp - yy_bp); \ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; #define YY_NUM_RULES 16 #define YY_END_OF_BUFFER 17 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info { flex_int32_t yy_verify; flex_int32_t yy_nxt; }; static yyconst flex_int16_t yy_accept[88] = { 0, 0, 0, 17, 15, 1, 15, 15, 3, 2, 15, 15, 15, 15, 15, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 1, 0, 6, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 13, 11, 8, 0, 0, 0, 14, 0, 0, 0, 9 } ; static yyconst flex_int32_t yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 5, 1, 6, 1, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 11, 12, 13, 14, 1, 15, 1, 16, 1, 1, 17, 18, 19, 20, 21, 1, 22, 23, 24, 25, 1, 1, 26, 27, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; /* Table of booleans, true if rule could match eol. */ static yyconst flex_int32_t yy_rule_can_match_eol[17] = { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, }; static yy_state_type yy_last_accepting_state; static char *yy_last_accepting_cpos; extern int record__flex_debug; int record__flex_debug = 0; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ #define REJECT reject_used_but_not_detected #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *record_text; #line 1 "record_lexical.l" /* hi emacs, this is a part of -*- C -*- source */ /* $Id: record_lexical.l,v 1.30 2011/08/24 16:49:12 oohara Exp $ */ /* process this file with flex -Precord_ */ /* definitions */ #define YY_NO_INPUT 1 #line 23 "record_lexical.l" #include /* strchr */ #include #include "record_util.h" #include "record_parser_private.h" #include "record_lexical.h" static int value_int = 0; /* rules */ /* this comment must be before %% */ #line 1034 "record_lexical.c" #define INITIAL 0 #ifndef YY_NO_UNISTD_H /* Special case for "unistd.h", since it is non-ANSI. We include it way * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ #include #endif #ifndef YY_EXTRA_TYPE #define YY_EXTRA_TYPE void * #endif static int yy_init_globals (void ); /* Macros after this point can all be overridden by user definitions in * section 1. */ #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus extern "C" int record_wrap (void ); #else extern int record_wrap (void ); #endif #endif #ifndef yytext_ptr static void yy_flex_strncpy (char *,yyconst char *,int ); #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * ); #endif #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput (void ); #else static int input (void ); #endif #endif /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE #define YY_READ_BUF_SIZE 8192 #endif /* Copy whatever the last rule matched to the standard output. */ #ifndef ECHO /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ #define ECHO (void) fwrite( record_text, record_leng, 1, record_out ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ size_t n; \ for ( n = 0; n < max_size && \ (c = getc( record_in )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ buf[n++] = (char) c; \ if ( c == EOF && ferror( record_in ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ else \ { \ errno=0; \ while ( (result = fread(buf, 1, max_size, record_in))==0 && ferror(record_in)) \ { \ if( errno != EINTR) \ { \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ break; \ } \ errno=0; \ clearerr(record_in); \ } \ }\ \ #endif /* No semi-colon after return; correct usage is to write "yyterminate();" - * we don't want an extra ';' after the "return" because that will cause * some compilers to complain about unreachable statements. */ #ifndef yyterminate #define yyterminate() return YY_NULL #endif /* Number of entries by which start-condition stack grows. */ #ifndef YY_START_STACK_INCR #define YY_START_STACK_INCR 25 #endif /* Report a fatal error. */ #ifndef YY_FATAL_ERROR #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) #endif /* end tables serialization structures and prototypes */ /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL_IS_OURS 1 extern int record_lex (void); #define YY_DECL int record_lex (void) #endif /* !YY_DECL */ /* Code executed at the beginning of each rule, after record_text and record_leng * have been set up. */ #ifndef YY_USER_ACTION #define YY_USER_ACTION #endif /* Code executed at the end of each rule. */ #ifndef YY_BREAK #define YY_BREAK break; #endif #define YY_RULE_SETUP \ YY_USER_ACTION /** The main scanner function which does all the work. */ YY_DECL { register yy_state_type yy_current_state; register char *yy_cp, *yy_bp; register int yy_act; #line 38 "record_lexical.l" #line 1187 "record_lexical.c" if ( !(yy_init) ) { (yy_init) = 1; #ifdef YY_USER_INIT YY_USER_INIT; #endif if ( ! (yy_start) ) (yy_start) = 1; /* first start state */ if ( ! record_in ) record_in = stdin; if ( ! record_out ) record_out = stdout; if ( ! YY_CURRENT_BUFFER ) { record_ensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = record__create_buffer(record_in,YY_BUF_SIZE ); } record__load_buffer_state( ); } while ( 1 ) /* loops until end-of-file is reached */ { yy_cp = (yy_c_buf_p); /* Support of record_text. */ *yy_cp = (yy_hold_char); /* yy_bp points to the position in yy_ch_buf of the start of * the current run. */ yy_bp = yy_cp; yy_current_state = (yy_start); yy_match: while ( (yy_current_state = yy_nxt[yy_current_state][ yy_ec[YY_SC_TO_UI(*yy_cp)] ]) > 0 ) { if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; (yy_last_accepting_cpos) = yy_cp; } ++yy_cp; } yy_current_state = -yy_current_state; yy_find_action: yy_act = yy_accept[yy_current_state]; YY_DO_BEFORE_ACTION; if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) { int yyl; for ( yyl = 0; yyl < record_leng; ++yyl ) if ( record_text[yyl] == '\n' ) record_lineno++; ; } do_action: /* This label is used only to access EOF actions. */ switch ( yy_act ) { /* beginning of action switch */ case 0: /* must back up */ /* undo the effects of YY_DO_BEFORE_ACTION */ *yy_cp = (yy_hold_char); yy_cp = (yy_last_accepting_cpos) + 1; yy_current_state = (yy_last_accepting_state); goto yy_find_action; case 1: /* rule 1 can match eol */ YY_RULE_SETUP #line 39 "record_lexical.l" { record_lval.n0 = -1; record_lval.n1 = -1; return SPACE; } YY_BREAK case 2: YY_RULE_SETUP #line 45 "record_lexical.l" { record_lval.n0 = -1; record_lval.n1 = -1; return SEMICOLON; } YY_BREAK case 3: YY_RULE_SETUP #line 51 "record_lexical.l" { /* you can write 7 as 007 for example, but it is always decimal, * not octal */ convert_to_number(&value_int, record_text); record_lval.n0 = value_int; record_lval.n1 = -1; return VALUE_INT; } YY_BREAK case 4: YY_RULE_SETUP #line 60 "record_lexical.l" { record_lval.n0 = -1; record_lval.n1 = -1; return NUMBER_PLAY; } YY_BREAK case 5: YY_RULE_SETUP #line 66 "record_lexical.l" { record_lval.n0 = -1; record_lval.n1 = -1; return END; } YY_BREAK case 6: YY_RULE_SETUP #line 72 "record_lexical.l" { record_lval.n0 = -1; record_lval.n1 = -1; return PLAN; } YY_BREAK case 7: YY_RULE_SETUP #line 78 "record_lexical.l" { record_lval.n0 = -1; record_lval.n1 = -1; return SCORE_MAX; } YY_BREAK case 8: YY_RULE_SETUP #line 84 "record_lexical.l" { record_lval.n0 = -1; record_lval.n1 = -1; return NUMBER_CLEAR; } YY_BREAK case 9: YY_RULE_SETUP #line 90 "record_lexical.l" { record_lval.n0 = -1; record_lval.n1 = -1; return SCORE_MIN_CLEARED; } YY_BREAK case 10: YY_RULE_SETUP #line 96 "record_lexical.l" { record_lval.n0 = -1; record_lval.n1 = -1; return TOTAL; } YY_BREAK case 11: YY_RULE_SETUP #line 102 "record_lexical.l" { record_lval.n0 = -1; record_lval.n1 = -1; return TOTAL_SCORE; } YY_BREAK case 12: YY_RULE_SETUP #line 108 "record_lexical.l" { record_lval.n0 = -1; record_lval.n1 = -1; return STAGE_ID; } YY_BREAK case 13: YY_RULE_SETUP #line 114 "record_lexical.l" { record_lval.n0 = -1; record_lval.n1 = -1; return STAGE_SCORE; } YY_BREAK case 14: YY_RULE_SETUP #line 120 "record_lexical.l" { record_lval.n0 = -1; record_lval.n1 = -1; return STAGE_CLEARED; } YY_BREAK case 15: /* rule 15 can match eol */ YY_RULE_SETUP #line 126 "record_lexical.l" { /* catch-all */ record_lval.n0 = -1; record_lval.n1 = -1; return NO_MATCH; } YY_BREAK case 16: YY_RULE_SETUP #line 132 "record_lexical.l" ECHO; YY_BREAK #line 1414 "record_lexical.c" case YY_STATE_EOF(INITIAL): yyterminate(); case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; /* Undo the effects of YY_DO_BEFORE_ACTION. */ *yy_cp = (yy_hold_char); YY_RESTORE_YY_MORE_OFFSET if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed record_in at a new source and called * record_lex(). If so, then we have to assure * consistency between YY_CURRENT_BUFFER and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. */ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; YY_CURRENT_BUFFER_LVALUE->yy_input_file = record_in; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; } /* Note that here we test for yy_c_buf_p "<=" to the position * of the first EOB in the buffer, since yy_c_buf_p will * already have been incremented past the NUL character * (since all states make transitions on EOB to the * end-of-buffer state). Contrast this with the test * in input(). */ if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) { /* This was really a NUL. */ yy_state_type yy_next_state; (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state( ); /* Okay, we're now positioned to make the NUL * transition. We couldn't have * yy_get_previous_state() go ahead and do it * for us because it doesn't know how to deal * with the possibility of jamming (and we don't * want to build jamming into it because then it * will run more slowly). */ yy_next_state = yy_try_NUL_trans( yy_current_state ); yy_bp = (yytext_ptr) + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ yy_cp = ++(yy_c_buf_p); yy_current_state = yy_next_state; goto yy_match; } else { yy_cp = (yy_c_buf_p); goto yy_find_action; } } else switch ( yy_get_next_buffer( ) ) { case EOB_ACT_END_OF_FILE: { (yy_did_buffer_switch_on_eof) = 0; if ( record_wrap( ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up * record_text, we can now set up * yy_c_buf_p so that if some total * hoser (like flex itself) wants to * call the scanner after we return the * YY_NULL, it'll still work - another * YY_NULL will get returned. */ (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; yy_act = YY_STATE_EOF(YY_START); goto do_action; } else { if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; } break; } case EOB_ACT_CONTINUE_SCAN: (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state( ); yy_cp = (yy_c_buf_p); yy_bp = (yytext_ptr) + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: (yy_c_buf_p) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; yy_current_state = yy_get_previous_state( ); yy_cp = (yy_c_buf_p); yy_bp = (yytext_ptr) + YY_MORE_ADJ; goto yy_find_action; } break; } default: YY_FATAL_ERROR( "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ } /* end of record_lex */ /* yy_get_next_buffer - try to read in a new buffer * * Returns a code representing an action: * EOB_ACT_LAST_MATCH - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ static int yy_get_next_buffer (void) { register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; register char *source = (yytext_ptr); register int number_to_move, i; int ret_val; if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) { /* Don't try to fill the buffer, so this is an EOF. */ if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. */ return EOB_ACT_END_OF_FILE; } else { /* We matched some text prior to the EOB, first * process it. */ return EOB_ACT_LAST_MATCH; } } /* Try to read more data. */ /* First move last chars to start of buffer. */ number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; else { int num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ /* just a shorter name for the current buffer */ YY_BUFFER_STATE b = YY_CURRENT_BUFFER; int yy_c_buf_p_offset = (int) ((yy_c_buf_p) - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; else b->yy_buf_size *= 2; b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ record_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); } else /* Can't grow it, we don't own it. */ b->yy_ch_buf = 0; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; } if ( num_to_read > YY_READ_BUF_SIZE ) num_to_read = YY_READ_BUF_SIZE; /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), (yy_n_chars), (size_t) num_to_read ); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } if ( (yy_n_chars) == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; record_restart(record_in ); } else { ret_val = EOB_ACT_LAST_MATCH; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING; } } else ret_val = EOB_ACT_CONTINUE_SCAN; (yy_n_chars) += number_to_move; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; return ret_val; } /* yy_get_previous_state - get the state just before the EOB char was reached */ static yy_state_type yy_get_previous_state (void) { register yy_state_type yy_current_state; register char *yy_cp; yy_current_state = (yy_start); for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) { yy_current_state = yy_nxt[yy_current_state][(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1)]; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; (yy_last_accepting_cpos) = yy_cp; } } return yy_current_state; } /* yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis * next_state = yy_try_NUL_trans( current_state ); */ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) { register int yy_is_jam; register char *yy_cp = (yy_c_buf_p); yy_current_state = yy_nxt[yy_current_state][1]; yy_is_jam = (yy_current_state <= 0); if ( ! yy_is_jam ) { if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; (yy_last_accepting_cpos) = yy_cp; } } return yy_is_jam ? 0 : yy_current_state; } #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput (void) #else static int input (void) #endif { int c; *(yy_c_buf_p) = (yy_hold_char); if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) /* This was really a NUL. */ *(yy_c_buf_p) = '\0'; else { /* need more input */ int offset = (yy_c_buf_p) - (yytext_ptr); ++(yy_c_buf_p); switch ( yy_get_next_buffer( ) ) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() * sees that we've accumulated a * token and flags that we need to * try matching the token before * proceeding. But for input(), * there's no matching to consider. * So convert the EOB_ACT_LAST_MATCH * to EOB_ACT_END_OF_FILE. */ /* Reset buffer status. */ record_restart(record_in ); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { if ( record_wrap( ) ) return EOF; if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; #ifdef __cplusplus return yyinput(); #else return input(); #endif } case EOB_ACT_CONTINUE_SCAN: (yy_c_buf_p) = (yytext_ptr) + offset; break; } } } c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ *(yy_c_buf_p) = '\0'; /* preserve record_text */ (yy_hold_char) = *++(yy_c_buf_p); if ( c == '\n' ) record_lineno++; ; return c; } #endif /* ifndef YY_NO_INPUT */ /** Immediately switch to a different input stream. * @param input_file A readable stream. * * @note This function does not reset the start condition to @c INITIAL . */ void record_restart (FILE * input_file ) { if ( ! YY_CURRENT_BUFFER ){ record_ensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = record__create_buffer(record_in,YY_BUF_SIZE ); } record__init_buffer(YY_CURRENT_BUFFER,input_file ); record__load_buffer_state( ); } /** Switch to a different input buffer. * @param new_buffer The new input buffer. * */ void record__switch_to_buffer (YY_BUFFER_STATE new_buffer ) { /* TODO. We should be able to replace this entire function body * with * record_pop_buffer_state(); * record_push_buffer_state(new_buffer); */ record_ensure_buffer_stack (); if ( YY_CURRENT_BUFFER == new_buffer ) return; if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *(yy_c_buf_p) = (yy_hold_char); YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } YY_CURRENT_BUFFER_LVALUE = new_buffer; record__load_buffer_state( ); /* We don't actually know whether we did this switch during * EOF (record_wrap()) processing, but the only time this flag * is looked at is after record_wrap() is called, so it's safe * to go ahead and always set it. */ (yy_did_buffer_switch_on_eof) = 1; } static void record__load_buffer_state (void) { (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; record_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file; (yy_hold_char) = *(yy_c_buf_p); } /** Allocate and initialize an input buffer state. * @param file A readable stream. * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. * * @return the allocated buffer state. */ YY_BUFFER_STATE record__create_buffer (FILE * file, int size ) { YY_BUFFER_STATE b; b = (YY_BUFFER_STATE) record_alloc(sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in record__create_buffer()" ); b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ b->yy_ch_buf = (char *) record_alloc(b->yy_buf_size + 2 ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in record__create_buffer()" ); b->yy_is_our_buffer = 1; record__init_buffer(b,file ); return b; } /** Destroy the buffer. * @param b a buffer created with record__create_buffer() * */ void record__delete_buffer (YY_BUFFER_STATE b ) { if ( ! b ) return; if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) record_free((void *) b->yy_ch_buf ); record_free((void *) b ); } #ifndef __cplusplus extern int isatty (int ); #endif /* __cplusplus */ /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a record_restart() or at EOF. */ static void record__init_buffer (YY_BUFFER_STATE b, FILE * file ) { int oerrno = errno; record__flush_buffer(b ); b->yy_input_file = file; b->yy_fill_buffer = 1; /* If b is the current buffer, then record__init_buffer was _probably_ * called from record_restart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ if (b != YY_CURRENT_BUFFER){ b->yy_bs_lineno = 1; b->yy_bs_column = 0; } b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; errno = oerrno; } /** Discard all buffered characters. On the next scan, YY_INPUT will be called. * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * */ void record__flush_buffer (YY_BUFFER_STATE b ) { if ( ! b ) return; b->yy_n_chars = 0; /* We always need two end-of-buffer characters. The first causes * a transition to the end-of-buffer state. The second causes * a jam in that state. */ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; b->yy_buf_pos = &b->yy_ch_buf[0]; b->yy_at_bol = 1; b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) record__load_buffer_state( ); } /** Pushes the new state onto the stack. The new state becomes * the current state. This function will allocate the stack * if necessary. * @param new_buffer The new state. * */ void record_push_buffer_state (YY_BUFFER_STATE new_buffer ) { if (new_buffer == NULL) return; record_ensure_buffer_stack(); /* This block is copied from record__switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *(yy_c_buf_p) = (yy_hold_char); YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } /* Only push if top exists. Otherwise, replace top. */ if (YY_CURRENT_BUFFER) (yy_buffer_stack_top)++; YY_CURRENT_BUFFER_LVALUE = new_buffer; /* copied from record__switch_to_buffer. */ record__load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } /** Removes and deletes the top of the stack, if present. * The next element becomes the new top. * */ void record_pop_buffer_state (void) { if (!YY_CURRENT_BUFFER) return; record__delete_buffer(YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; if ((yy_buffer_stack_top) > 0) --(yy_buffer_stack_top); if (YY_CURRENT_BUFFER) { record__load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } } /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ static void record_ensure_buffer_stack (void) { int num_to_alloc; if (!(yy_buffer_stack)) { /* First allocation is just for 2 elements, since we don't know if this * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ num_to_alloc = 1; (yy_buffer_stack) = (struct yy_buffer_state**)record_alloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); (yy_buffer_stack_max) = num_to_alloc; (yy_buffer_stack_top) = 0; return; } if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ /* Increase the buffer to prepare for a possible push. */ int grow_size = 8 /* arbitrary grow size */; num_to_alloc = (yy_buffer_stack_max) + grow_size; (yy_buffer_stack) = (struct yy_buffer_state**)record_realloc ((yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state*) ); /* zero only the new slots.*/ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); (yy_buffer_stack_max) = num_to_alloc; } } /** Setup the input buffer state to scan directly from a user-specified character buffer. * @param base the character buffer * @param size the size in bytes of the character buffer * * @return the newly allocated buffer state object. */ YY_BUFFER_STATE record__scan_buffer (char * base, yy_size_t size ) { YY_BUFFER_STATE b; if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ return 0; b = (YY_BUFFER_STATE) record_alloc(sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in record__scan_buffer()" ); b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; b->yy_input_file = 0; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; b->yy_at_bol = 1; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; record__switch_to_buffer(b ); return b; } /** Setup the input buffer state to scan a string. The next call to record_lex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan * * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use * record__scan_bytes() instead. */ YY_BUFFER_STATE record__scan_string (yyconst char * yystr ) { return record__scan_bytes(yystr,strlen(yystr) ); } /** Setup the input buffer state to scan the given bytes. The next call to record_lex() will * scan from a @e copy of @a bytes. * @param bytes the byte buffer to scan * @param len the number of bytes in the buffer pointed to by @a bytes. * * @return the newly allocated buffer state object. */ YY_BUFFER_STATE record__scan_bytes (yyconst char * yybytes, int _yybytes_len ) { YY_BUFFER_STATE b; char *buf; yy_size_t n; int i; /* Get memory for full buffer, including space for trailing EOB's. */ n = _yybytes_len + 2; buf = (char *) record_alloc(n ); if ( ! buf ) YY_FATAL_ERROR( "out of dynamic memory in record__scan_bytes()" ); for ( i = 0; i < _yybytes_len; ++i ) buf[i] = yybytes[i]; buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; b = record__scan_buffer(buf,n ); if ( ! b ) YY_FATAL_ERROR( "bad buffer in record__scan_bytes()" ); /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. */ b->yy_is_our_buffer = 1; return b; } #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 #endif static void yy_fatal_error (yyconst char* msg ) { (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } /* Redefine yyless() so it works in section 3 code. */ #undef yyless #define yyless(n) \ do \ { \ /* Undo effects of setting up record_text. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ record_text[record_leng] = (yy_hold_char); \ (yy_c_buf_p) = record_text + yyless_macro_arg; \ (yy_hold_char) = *(yy_c_buf_p); \ *(yy_c_buf_p) = '\0'; \ record_leng = yyless_macro_arg; \ } \ while ( 0 ) /* Accessor methods (get/set functions) to struct members. */ /** Get the current token. * */ static int yy_init_globals (void) { /* Initialization is the same as for the non-reentrant scanner. * This function is called from record_lex_destroy(), so don't allocate here. */ /* We do not touch record_lineno unless the option is enabled. */ record_lineno = 1; (yy_buffer_stack) = 0; (yy_buffer_stack_top) = 0; (yy_buffer_stack_max) = 0; (yy_c_buf_p) = (char *) 0; (yy_init) = 0; (yy_start) = 0; /* Defined in main.c */ #ifdef YY_STDINIT record_in = stdin; record_out = stdout; #else record_in = (FILE *) 0; record_out = (FILE *) 0; #endif /* For future reference: Set errno on error, since we are called by * record_lex_init() */ return 0; } /* record_lex_destroy is for both reentrant and non-reentrant scanners. */ int record_lex_destroy (void) { /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ record__delete_buffer(YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; record_pop_buffer_state(); } /* Destroy the stack itself. */ record_free((yy_buffer_stack) ); (yy_buffer_stack) = NULL; /* Reset the globals. This is important in a non-reentrant scanner so the next time * record_lex() is called, initialization will occur. */ yy_init_globals( ); return 0; } /* * Internal utility routines. */ #ifndef yytext_ptr static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) { register int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * s ) { register int n; for ( n = 0; s[n]; ++n ) ; return n; } #endif void *record_alloc (yy_size_t size ) { return (void *) malloc( size ); } void *record_realloc (void * ptr, yy_size_t size ) { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter * because both ANSI C and C++ allow castless assignment from * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ return (void *) realloc( (char *) ptr, size ); } void record_free (void * ptr ) { free( (char *) ptr ); /* see record_realloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" #line 132 "record_lexical.l" /* user code */ void record_read_from_file(FILE *file) { /* record_restart */ record_restart(file); } void record_read_from_string(const char *string) { /* record__scan_string */ record__scan_string(string); } dangen-0.5/record/record_parser.c0000644000175000017500000016122611625461012017700 0ustar00ooharaoohara00000000000000/* A Bison parser, made by GNU Bison 2.3. */ /* Skeleton implementation for Bison's Yacc-like parsers in C Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. 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 2, 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ #define YYBISON_VERSION "2.3" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 0 /* Using locations. */ #define YYLSP_NEEDED 0 /* Substitute the variable and function names. */ #define yyparse record_parse #define yylex record_lex #define yyerror record_error #define yylval record_lval #define yychar record_char #define yydebug record_debug #define yynerrs record_nerrs /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ enum yytokentype { SPACE = 258, SEMICOLON = 259, VALUE_INT = 260, NUMBER_PLAY = 261, END = 262, PLAN = 263, SCORE_MAX = 264, NUMBER_CLEAR = 265, SCORE_MIN_CLEARED = 266, TOTAL = 267, TOTAL_SCORE = 268, STAGE_ID = 269, STAGE_SCORE = 270, STAGE_CLEARED = 271, NO_MATCH = 272 }; #endif /* Tokens. */ #define SPACE 258 #define SEMICOLON 259 #define VALUE_INT 260 #define NUMBER_PLAY 261 #define END 262 #define PLAN 263 #define SCORE_MAX 264 #define NUMBER_CLEAR 265 #define SCORE_MIN_CLEARED 266 #define TOTAL 267 #define TOTAL_SCORE 268 #define STAGE_ID 269 #define STAGE_SCORE 270 #define STAGE_CLEARED 271 #define NO_MATCH 272 /* Copy the first part of user declarations. */ #line 5 "record_parser.y" #include #include "record_data.h" #include "record_lexical.h" #include "record_parser_private.h" #include "record_parser_public.h" static game_record *p = NULL; /* yyerror */ static void record_error(const char *s); /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else # define YYERROR_VERBOSE 0 #endif /* Enabling the token table. */ #ifndef YYTOKEN_TABLE # define YYTOKEN_TABLE 0 #endif #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 #endif /* Copy the second part of user declarations. */ /* Line 216 of yacc.c. */ #line 163 "record_parser.c" #ifdef short # undef short #endif #ifdef YYTYPE_UINT8 typedef YYTYPE_UINT8 yytype_uint8; #else typedef unsigned char yytype_uint8; #endif #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; #elif (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) typedef signed char yytype_int8; #else typedef short int yytype_int8; #endif #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else typedef unsigned short int yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else typedef short int yytype_int16; #endif #ifndef YYSIZE_T # ifdef __SIZE_TYPE__ # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else # define YYSIZE_T unsigned int # endif #endif #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ # if YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) # endif # endif # ifndef YY_ # define YY_(msgid) msgid # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(e) ((void) (e)) #else # define YYUSE(e) /* empty */ #endif /* Identity function, used to suppress warnings about constant conditions. */ #ifndef lint # define YYID(n) (n) #else #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int YYID (int i) #else static int YYID (i) int i; #endif { return i; } #endif #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ # ifdef YYSTACK_USE_ALLOCA # if YYSTACK_USE_ALLOCA # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca # elif defined __BUILTIN_VA_ARG_INCR # include /* INFRINGES ON USER NAME SPACE */ # elif defined _AIX # define YYSTACK_ALLOC __alloca # elif defined _MSC_VER # include /* INFRINGES ON USER NAME SPACE */ # define alloca _alloca # else # define YYSTACK_ALLOC alloca # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ # ifndef _STDLIB_H # define _STDLIB_H 1 # endif # endif # endif # endif # endif # ifdef YYSTACK_ALLOC /* Pacify GCC's `empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely invoke alloca (N) if N exceeds 4096. Use a slightly smaller number to allow for a few compiler-allocated temporary stack slots. */ # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ # endif # else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif # if (defined __cplusplus && ! defined _STDLIB_H \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ # ifndef _STDLIB_H # define _STDLIB_H 1 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { yytype_int16 yyss; YYSTYPE yyvs; }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else # define YYCOPY(To, From, Count) \ do \ { \ YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ while (YYID (0)) # endif # endif /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ # define YYSTACK_RELOCATE(Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack, Stack, yysize); \ Stack = &yyptr->Stack; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (YYID (0)) #endif /* YYFINAL -- State number of the termination state. */ #define YYFINAL 2 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 93 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 18 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 20 /* YYNRULES -- Number of rules. */ #define YYNRULES 39 /* YYNRULES -- Number of states. */ #define YYNSTATES 88 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 272 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }; #if YYDEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ static const yytype_uint8 yyprhs[] = { 0, 0, 3, 4, 7, 10, 13, 15, 17, 20, 22, 25, 28, 31, 34, 37, 40, 45, 52, 59, 66, 69, 71, 74, 77, 80, 83, 86, 89, 92, 95, 102, 109, 116, 123, 130, 133, 135, 138, 140 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { 19, 0, -1, -1, 19, 3, -1, 19, 4, -1, 19, 20, -1, 21, -1, 27, -1, 22, 35, -1, 23, -1, 22, 3, -1, 22, 4, -1, 22, 24, -1, 22, 25, -1, 22, 26, -1, 22, 34, -1, 8, 37, 5, 36, -1, 9, 37, 5, 37, 5, 36, -1, 10, 37, 5, 37, 5, 36, -1, 11, 37, 5, 37, 5, 36, -1, 28, 35, -1, 29, -1, 28, 3, -1, 28, 4, -1, 28, 30, -1, 28, 31, -1, 28, 32, -1, 28, 33, -1, 28, 34, -1, 12, 36, -1, 13, 37, 5, 37, 5, 36, -1, 14, 37, 5, 37, 5, 36, -1, 15, 37, 5, 37, 5, 36, -1, 16, 37, 5, 37, 5, 36, -1, 6, 37, 5, 37, 5, 36, -1, 7, 36, -1, 4, -1, 37, 4, -1, 3, -1, 37, 3, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { 0, 46, 46, 50, 55, 60, 67, 72, 79, 106, 128, 150, 172, 196, 220, 244, 270, 294, 303, 312, 321, 344, 349, 354, 359, 377, 404, 431, 458, 478, 485, 494, 503, 512, 521, 530, 537, 538, 545, 546 }; #endif #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "SPACE", "SEMICOLON", "VALUE_INT", "NUMBER_PLAY", "END", "PLAN", "SCORE_MAX", "NUMBER_CLEAR", "SCORE_MIN_CLEARED", "TOTAL", "TOTAL_SCORE", "STAGE_ID", "STAGE_SCORE", "STAGE_CLEARED", "NO_MATCH", "$accept", "play_record", "block", "plan_record_block", "plan_record_stmt", "plan_record_begin", "score_max_stmt", "number_clear_stmt", "score_min_cleared_stmt", "total_record_block", "total_record_stmt", "total_record_begin", "total_score_stmt", "stage_id_stmt", "stage_score_stmt", "stage_cleared_stmt", "number_play_stmt", "block_end", "stmt_end", "spaces", 0 }; #endif # ifdef YYPRINT /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to token YYLEX-NUM. */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { 0, 18, 19, 19, 19, 19, 20, 20, 21, 22, 22, 22, 22, 22, 22, 22, 23, 24, 25, 26, 27, 28, 28, 28, 28, 28, 28, 28, 28, 29, 30, 31, 32, 33, 34, 35, 36, 36, 37, 37 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 0, 2, 2, 2, 1, 1, 2, 1, 2, 2, 2, 2, 2, 2, 4, 6, 6, 6, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 6, 6, 6, 6, 6, 2, 1, 2, 1, 2 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state STATE-NUM when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const yytype_uint8 yydefact[] = { 2, 0, 1, 3, 4, 0, 0, 5, 6, 0, 9, 7, 0, 21, 38, 0, 36, 29, 0, 10, 11, 0, 0, 0, 0, 0, 12, 13, 14, 15, 8, 22, 23, 0, 0, 0, 0, 24, 25, 26, 27, 28, 20, 39, 0, 37, 0, 35, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 34, 17, 18, 19, 30, 31, 32, 33 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { -1, 1, 7, 8, 9, 10, 26, 27, 28, 11, 12, 13, 37, 38, 39, 40, 29, 30, 17, 18 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ #define YYPACT_NINF -13 static const yytype_int8 yypact[] = { -13, 33, -13, -13, -13, 0, 31, -13, -13, 65, -13, -13, -2, -13, -13, 3, -13, -13, 89, -13, -13, 0, 31, 0, 0, 0, -13, -13, -13, -13, -13, -13, -13, 0, 0, 0, 0, -13, -13, -13, -13, -13, -13, -13, 31, -13, 4, -13, 12, 18, 19, 22, 35, 39, 43, -13, 0, 0, 0, 0, 0, 0, 0, 0, 44, 74, 75, 78, 79, 82, 83, 86, 31, 31, 31, 31, 31, 31, 31, 31, -13, -13, -13, -13, -13, -13, -13, -13 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, 14, 27, -12, -5 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -1 static const yytype_uint8 yytable[] = { 15, 31, 32, 14, 21, 22, 43, 43, 44, 56, 47, 33, 34, 35, 36, 43, 46, 57, 48, 49, 50, 43, 43, 58, 59, 43, 41, 60, 51, 52, 53, 54, 55, 2, 14, 16, 3, 4, 43, 42, 61, 5, 43, 0, 62, 6, 43, 43, 63, 72, 0, 64, 65, 66, 67, 68, 69, 70, 71, 0, 80, 81, 82, 83, 84, 85, 86, 87, 19, 20, 0, 21, 22, 0, 23, 24, 25, 43, 43, 73, 74, 43, 43, 75, 76, 43, 43, 77, 78, 43, 0, 79, 43, 45 }; static const yytype_int8 yycheck[] = { 5, 3, 4, 3, 6, 7, 3, 3, 5, 5, 22, 13, 14, 15, 16, 3, 21, 5, 23, 24, 25, 3, 3, 5, 5, 3, 12, 5, 33, 34, 35, 36, 44, 0, 3, 4, 3, 4, 3, 12, 5, 8, 3, -1, 5, 12, 3, 3, 5, 5, -1, 56, 57, 58, 59, 60, 61, 62, 63, -1, 72, 73, 74, 75, 76, 77, 78, 79, 3, 4, -1, 6, 7, -1, 9, 10, 11, 3, 3, 5, 5, 3, 3, 5, 5, 3, 3, 5, 5, 3, -1, 5, 3, 4 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { 0, 19, 0, 3, 4, 8, 12, 20, 21, 22, 23, 27, 28, 29, 3, 37, 4, 36, 37, 3, 4, 6, 7, 9, 10, 11, 24, 25, 26, 34, 35, 3, 4, 13, 14, 15, 16, 30, 31, 32, 33, 34, 35, 3, 5, 4, 37, 36, 37, 37, 37, 37, 37, 37, 37, 36, 5, 5, 5, 5, 5, 5, 5, 5, 37, 37, 37, 37, 37, 37, 37, 37, 5, 5, 5, 5, 5, 5, 5, 5, 36, 36, 36, 36, 36, 36, 36, 36 }; #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrorlab /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { \ yychar = (Token); \ yylval = (Value); \ yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK (1); \ goto yybackup; \ } \ else \ { \ yyerror (YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (YYID (0)) #define YYTERROR 1 #define YYERRCODE 256 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. If N is 0, then set CURRENT to the empty location which ends the previous symbol: RHS[0] (always defined). */ #define YYRHSLOC(Rhs, K) ((Rhs)[K]) #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ do \ if (YYID (N)) \ { \ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ } \ else \ { \ (Current).first_line = (Current).last_line = \ YYRHSLOC (Rhs, 0).last_line; \ (Current).first_column = (Current).last_column = \ YYRHSLOC (Rhs, 0).last_column; \ } \ while (YYID (0)) #endif /* YY_LOCATION_PRINT -- Print the location on the stream. This macro was not mandated originally: define only if we know we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT # if YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ (Loc).last_line, (Loc).last_column) # else # define YY_LOCATION_PRINT(File, Loc) ((void) 0) # endif #endif /* YYLEX -- calling `yylex' with the right arguments. */ #ifdef YYLEX_PARAM # define YYLEX yylex (YYLEX_PARAM) #else # define YYLEX yylex () #endif /* Enable debugging if requested. */ #if YYDEBUG # ifndef YYFPRINTF # include /* INFRINGES ON USER NAME SPACE */ # define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (YYID (0)) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ Type, Value); \ YYFPRINTF (stderr, "\n"); \ } \ } while (YYID (0)) /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ /*ARGSUSED*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) #else static void yy_symbol_value_print (yyoutput, yytype, yyvaluep) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; #endif { if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); # else YYUSE (yyoutput); # endif switch (yytype) { default: break; } } /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) #else static void yy_symbol_print (yyoutput, yytype, yyvaluep) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; #endif { if (yytype < YYNTOKENS) YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); else YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); yy_symbol_value_print (yyoutput, yytype, yyvaluep); YYFPRINTF (yyoutput, ")"); } /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) #else static void yy_stack_print (bottom, top) yytype_int16 *bottom; yytype_int16 *top; #endif { YYFPRINTF (stderr, "Stack now"); for (; bottom <= top; ++bottom) YYFPRINTF (stderr, " %d", *bottom); YYFPRINTF (stderr, "\n"); } # define YY_STACK_PRINT(Bottom, Top) \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ } while (YYID (0)) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_reduce_print (YYSTYPE *yyvsp, int yyrule) #else static void yy_reduce_print (yyvsp, yyrule) YYSTYPE *yyvsp; int yyrule; #endif { int yynrhs = yyr2[yyrule]; int yyi; unsigned long int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { fprintf (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) ); fprintf (stderr, "\n"); } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ yy_reduce_print (yyvsp, Rule); \ } while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only if the built-in stack extension method is used). Do not make this value too large; the results are undefined if YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif #if YYERROR_VERBOSE # ifndef yystrlen # if defined __GLIBC__ && defined _STRING_H # define yystrlen strlen # else /* Return the length of YYSTR. */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static YYSIZE_T yystrlen (const char *yystr) #else static YYSIZE_T yystrlen (yystr) const char *yystr; #endif { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) continue; return yylen; } # endif # endif # ifndef yystpcpy # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static char * yystpcpy (char *yydest, const char *yysrc) #else static char * yystpcpy (yydest, yysrc) char *yydest; const char *yysrc; #endif { char *yyd = yydest; const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } # endif # endif # ifndef yytnamerr /* Copy to YYRES the contents of YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is that double-quoting is unnecessary unless the string contains an apostrophe, a comma, or backslash (other than backslash-backslash). YYSTR is taken from yytname. If YYRES is null, do not copy; instead, return the length of what the result would have been. */ static YYSIZE_T yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') { YYSIZE_T yyn = 0; char const *yyp = yystr; for (;;) switch (*++yyp) { case '\'': case ',': goto do_not_strip_quotes; case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; /* Fall through. */ default: if (yyres) yyres[yyn] = *yyp; yyn++; break; case '"': if (yyres) yyres[yyn] = '\0'; return yyn; } do_not_strip_quotes: ; } if (! yyres) return yystrlen (yystr); return yystpcpy (yyres, yystr) - yyres; } # endif /* Copy into YYRESULT an error message about the unexpected token YYCHAR while in state YYSTATE. Return the number of bytes copied, including the terminating null byte. If YYRESULT is null, do not copy anything; just return the number of bytes that would be copied. As a special case, return 0 if an ordinary "syntax error" message will do. Return YYSIZE_MAXIMUM if overflow occurs during size calculation. */ static YYSIZE_T yysyntax_error (char *yyresult, int yystate, int yychar) { int yyn = yypact[yystate]; if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) return 0; else { int yytype = YYTRANSLATE (yychar); YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); YYSIZE_T yysize = yysize0; YYSIZE_T yysize1; int yysize_overflow = 0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; int yyx; # if 0 /* This is so xgettext sees the translatable formats that are constructed on the fly. */ YY_("syntax error, unexpected %s"); YY_("syntax error, unexpected %s, expecting %s"); YY_("syntax error, unexpected %s, expecting %s or %s"); YY_("syntax error, unexpected %s, expecting %s or %s or %s"); YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); # endif char *yyfmt; char const *yyf; static char const yyunexpected[] = "syntax error, unexpected %s"; static char const yyexpecting[] = ", expecting %s"; static char const yyor[] = " or %s"; char yyformat[sizeof yyunexpected + sizeof yyexpecting - 1 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) * (sizeof yyor - 1))]; char const *yyprefix = yyexpecting; /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. */ int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ int yychecklim = YYLAST - yyn + 1; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yycount = 1; yyarg[0] = yytname[yytype]; yyfmt = yystpcpy (yyformat, yyunexpected); for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { yycount = 1; yysize = yysize0; yyformat[sizeof yyunexpected - 1] = '\0'; break; } yyarg[yycount++] = yytname[yyx]; yysize1 = yysize + yytnamerr (0, yytname[yyx]); yysize_overflow |= (yysize1 < yysize); yysize = yysize1; yyfmt = yystpcpy (yyfmt, yyprefix); yyprefix = yyor; } yyf = YY_(yyformat); yysize1 = yysize + yystrlen (yyf); yysize_overflow |= (yysize1 < yysize); yysize = yysize1; if (yysize_overflow) return YYSIZE_MAXIMUM; if (yyresult) { /* Avoid sprintf, as that infringes on the user's name space. Don't have undefined behavior even if the translation produced a string with the wrong number of "%s"s. */ char *yyp = yyresult; int yyi = 0; while ((*yyp = *yyf) != '\0') { if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) { yyp += yytnamerr (yyp, yyarg[yyi++]); yyf += 2; } else { yyp++; yyf++; } } } return yysize; } } #endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ /*ARGSUSED*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) #else static void yydestruct (yymsg, yytype, yyvaluep) const char *yymsg; int yytype; YYSTYPE *yyvaluep; #endif { YYUSE (yyvaluep); if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); switch (yytype) { default: break; } } /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); #else int yyparse (); #endif #else /* ! YYPARSE_PARAM */ #if defined __STDC__ || defined __cplusplus int yyparse (void); #else int yyparse (); #endif #endif /* ! YYPARSE_PARAM */ /* The look-ahead symbol. */ int yychar; /* The semantic value of the look-ahead symbol. */ YYSTYPE yylval; /* Number of syntax errors so far. */ int yynerrs; /*----------. | yyparse. | `----------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) int yyparse (void *YYPARSE_PARAM) #else int yyparse (YYPARSE_PARAM) void *YYPARSE_PARAM; #endif #else /* ! YYPARSE_PARAM */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) int yyparse (void) #else int yyparse () #endif #endif { int yystate; int yyn; int yyresult; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* Look-ahead token as an internal (translated) token number. */ int yytoken = 0; #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; char *yymsg = yymsgbuf; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif /* Three stacks and their tools: `yyss': related to states, `yyvs': related to semantic values, `yyls': related to locations. Refer to the stacks thru separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ yytype_int16 yyssa[YYINITDEPTH]; yytype_int16 *yyss = yyssa; yytype_int16 *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs = yyvsa; YYSTYPE *yyvsp; #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) YYSIZE_T yystacksize = YYINITDEPTH; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss; yyvsp = yyvs; goto yysetstate; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; yysetstate: *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); yyss = yyss1; yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE goto yyexhaustedlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { yytype_int16 *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss); YYSTACK_RELOCATE (yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); goto yybackup; /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. Read a look-ahead token if we need one and don't already have one. */ /* First try to decide what to do without reference to look-ahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; /* Not known => get a look-ahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yytoken = YYTRANSLATE (yychar); YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; if (yyn <= 0) { if (yyn == 0 || yyn == YYTABLE_NINF) goto yyerrlab; yyn = -yyn; goto yyreduce; } if (yyn == YYFINAL) YYACCEPT; /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; /* Shift the look-ahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the shifted token unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; YY_REDUCE_PRINT (yyn); switch (yyn) { case 2: #line 46 "record_parser.y" { ((yyval)).n0 = -1; ((yyval)).n1 = -1; } break; case 3: #line 51 "record_parser.y" { ((yyval)).n0 = -1; ((yyval)).n1 = -1; } break; case 4: #line 56 "record_parser.y" { ((yyval)).n0 = -1; ((yyval)).n1 = -1; } break; case 5: #line 61 "record_parser.y" { ((yyval)).n0 = -1; ((yyval)).n1 = -1; } break; case 6: #line 68 "record_parser.y" { ((yyval)).n0 = -1; ((yyval)).n1 = -1; } break; case 7: #line 73 "record_parser.y" { ((yyval)).n0 = -1; ((yyval)).n1 = -1; } break; case 8: #line 80 "record_parser.y" { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->plan_p == NULL) { record_error("p->plan_p is NULL"); YYABORT; } if ((((yyvsp[(1) - (2)])).n0 < 0) || (((yyvsp[(1) - (2)])).n0 > p->plan_n)) { record_error("invalid plan"); YYABORT; } if (!plan_record_valid(p->plan_p[((yyvsp[(1) - (2)])).n0], 0)) { record_error("incomplete plan record"); YYABORT; } ((yyval)).n0 = -1; ((yyval)).n1 = -1; } break; case 9: #line 107 "record_parser.y" { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->plan_p == NULL) { record_error("p->plan_p is NULL"); YYABORT; } if ((((yyvsp[(1) - (1)])).n0 < 0) || (((yyvsp[(1) - (1)])).n0 > p->plan_n)) { record_error("invalid plan"); YYABORT; } /* plan id */ ((yyval)).n0 = ((yyvsp[(1) - (1)])).n0; ((yyval)).n1 = -1; } break; case 10: #line 129 "record_parser.y" { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->plan_p == NULL) { record_error("p->plan_p is NULL"); YYABORT; } if ((((yyvsp[(1) - (2)])).n0 < 0) || (((yyvsp[(1) - (2)])).n0 > p->plan_n)) { record_error("invalid plan"); YYABORT; } /* plan id */ ((yyval)).n0 = ((yyvsp[(1) - (2)])).n0; ((yyval)).n1 = -1; } break; case 11: #line 151 "record_parser.y" { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->plan_p == NULL) { record_error("p->plan_p is NULL"); YYABORT; } if ((((yyvsp[(1) - (2)])).n0 < 0) || (((yyvsp[(1) - (2)])).n0 > p->plan_n)) { record_error("invalid plan"); YYABORT; } /* plan id */ ((yyval)).n0 = ((yyvsp[(1) - (2)])).n0; ((yyval)).n1 = -1; } break; case 12: #line 173 "record_parser.y" { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->plan_p == NULL) { record_error("p->plan_p is NULL"); YYABORT; } if ((((yyvsp[(1) - (2)])).n0 < 0) || (((yyvsp[(1) - (2)])).n0 > p->plan_n)) { record_error("invalid plan"); YYABORT; } (p->plan_p[((yyvsp[(1) - (2)])).n0])->score_max = ((yyvsp[(2) - (2)])).n0; (p->plan_p[((yyvsp[(1) - (2)])).n0])->score_max_when = ((yyvsp[(2) - (2)])).n1; /* plan id */ ((yyval)).n0 = ((yyvsp[(1) - (2)])).n0; ((yyval)).n1 = -1; } break; case 13: #line 197 "record_parser.y" { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->plan_p == NULL) { record_error("p->plan_p is NULL"); YYABORT; } if ((((yyvsp[(1) - (2)])).n0 < 0) || (((yyvsp[(1) - (2)])).n0 > p->plan_n)) { record_error("invalid plan"); YYABORT; } (p->plan_p[((yyvsp[(1) - (2)])).n0])->number_clear = ((yyvsp[(2) - (2)])).n0; (p->plan_p[((yyvsp[(1) - (2)])).n0])->number_clear_when = ((yyvsp[(2) - (2)])).n1; /* plan id */ ((yyval)).n0 = ((yyvsp[(1) - (2)])).n0; ((yyval)).n1 = -1; } break; case 14: #line 221 "record_parser.y" { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->plan_p == NULL) { record_error("p->plan_p is NULL"); YYABORT; } if ((((yyvsp[(1) - (2)])).n0 < 0) || (((yyvsp[(1) - (2)])).n0 > p->plan_n)) { record_error("invalid plan"); YYABORT; } (p->plan_p[((yyvsp[(1) - (2)])).n0])->score_min_cleared = ((yyvsp[(2) - (2)])).n0; (p->plan_p[((yyvsp[(1) - (2)])).n0])->score_min_cleared_when = ((yyvsp[(2) - (2)])).n1; /* plan id */ ((yyval)).n0 = ((yyvsp[(1) - (2)])).n0; ((yyval)).n1 = -1; } break; case 15: #line 245 "record_parser.y" { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->plan_p == NULL) { record_error("p->plan_p is NULL"); YYABORT; } if ((((yyvsp[(1) - (2)])).n0 < 0) || (((yyvsp[(1) - (2)])).n0 > p->plan_n)) { record_error("invalid plan"); YYABORT; } (p->plan_p[((yyvsp[(1) - (2)])).n0])->number_play = ((yyvsp[(2) - (2)])).n0; (p->plan_p[((yyvsp[(1) - (2)])).n0])->number_play_when = ((yyvsp[(2) - (2)])).n1; /* plan id */ ((yyval)).n0 = ((yyvsp[(1) - (2)])).n0; ((yyval)).n1 = -1; } break; case 16: #line 271 "record_parser.y" { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->plan_p == NULL) { record_error("p->plan_p is NULL"); YYABORT; } if ((((yyvsp[(3) - (4)])).n0 < 0) || (((yyvsp[(3) - (4)])).n0 > p->plan_n)) { record_error("invalid plan"); YYABORT; } /* plan id */ ((yyval)).n0 = ((yyvsp[(3) - (4)])).n0; ((yyval)).n1 = -1; } break; case 17: #line 295 "record_parser.y" { /* value */ ((yyval)).n0 = ((yyvsp[(3) - (6)])).n0; /* when */ ((yyval)).n1 = ((yyvsp[(5) - (6)])).n0; } break; case 18: #line 304 "record_parser.y" { /* value */ ((yyval)).n0 = ((yyvsp[(3) - (6)])).n0; /* last */ ((yyval)).n1 = ((yyvsp[(5) - (6)])).n0; } break; case 19: #line 313 "record_parser.y" { /* value */ ((yyval)).n0 = ((yyvsp[(3) - (6)])).n0; /* when */ ((yyval)).n1 = ((yyvsp[(5) - (6)])).n0; } break; case 20: #line 322 "record_parser.y" { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->total_p == NULL) { record_error("p->total_p is NULL"); YYABORT; } if (!total_record_valid(p->total_p, 0)) { record_error("incomplete total record"); YYABORT; } ((yyval)).n0 = -1; ((yyval)).n1 = -1; } break; case 21: #line 345 "record_parser.y" { ((yyval)).n0 = -1; ((yyval)).n1 = -1; } break; case 22: #line 350 "record_parser.y" { ((yyval)).n0 = -1; ((yyval)).n1 = -1; } break; case 23: #line 355 "record_parser.y" { ((yyval)).n0 = -1; ((yyval)).n1 = -1; } break; case 24: #line 360 "record_parser.y" { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->total_p == NULL) { record_error("p->total_p is NULL"); YYABORT; } p->total_p->total_score = ((yyvsp[(2) - (2)])).n0; p->total_p->total_score_when = ((yyvsp[(2) - (2)])).n1; ((yyval)).n0 = -1; ((yyval)).n1 = -1; } break; case 25: #line 378 "record_parser.y" { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->total_p == NULL) { record_error("p->total_p is NULL"); YYABORT; } if (p->total_p->stage_id == NULL) { record_error("p->total_p->stage_id is NULL"); YYABORT; } if ((((yyvsp[(2) - (2)])).n0 <= 0) || (((yyvsp[(2) - (2)])).n0 > p->total_p->stage_n)) { record_error("invalid stage"); YYABORT; } p->total_p->stage_id[((yyvsp[(2) - (2)])).n0 - 1] = ((yyvsp[(2) - (2)])).n1; ((yyval)).n0 = -1; ((yyval)).n1 = -1; } break; case 26: #line 405 "record_parser.y" { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->total_p == NULL) { record_error("p->total_p is NULL"); YYABORT; } if (p->total_p->stage_score == NULL) { record_error("p->total_p->stage_score is NULL"); YYABORT; } if ((((yyvsp[(2) - (2)])).n0 <= 0) || (((yyvsp[(2) - (2)])).n0 > p->total_p->stage_n)) { record_error("invalid stage"); YYABORT; } p->total_p->stage_score[((yyvsp[(2) - (2)])).n0 - 1] = ((yyvsp[(2) - (2)])).n1; ((yyval)).n0 = -1; ((yyval)).n1 = -1; } break; case 27: #line 432 "record_parser.y" { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->total_p == NULL) { record_error("p->total_p is NULL"); YYABORT; } if (p->total_p->stage_cleared == NULL) { record_error("p->total_p->stage_cleared is NULL"); YYABORT; } if ((((yyvsp[(2) - (2)])).n0 <= 0) || (((yyvsp[(2) - (2)])).n0 > p->total_p->stage_n)) { record_error("invalid stage"); YYABORT; } p->total_p->stage_cleared[((yyvsp[(2) - (2)])).n0 - 1] = ((yyvsp[(2) - (2)])).n1; ((yyval)).n0 = -1; ((yyval)).n1 = -1; } break; case 28: #line 459 "record_parser.y" { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->total_p == NULL) { record_error("p->total_p is NULL"); YYABORT; } p->total_p->number_play = ((yyvsp[(2) - (2)])).n0; p->total_p->number_play_when = ((yyvsp[(2) - (2)])).n1; ((yyval)).n0 = -1; ((yyval)).n1 = -1; } break; case 29: #line 479 "record_parser.y" { ((yyval)).n0 = -1; ((yyval)).n1 = -1; } break; case 30: #line 486 "record_parser.y" { /* value */ ((yyval)).n0 = ((yyvsp[(3) - (6)])).n0; /* when */ ((yyval)).n1 = ((yyvsp[(5) - (6)])).n0; } break; case 31: #line 495 "record_parser.y" { /* stage number */ ((yyval)).n0 = ((yyvsp[(3) - (6)])).n0; /* value */ ((yyval)).n1 = ((yyvsp[(5) - (6)])).n0; } break; case 32: #line 504 "record_parser.y" { /* stage number */ ((yyval)).n0 = ((yyvsp[(3) - (6)])).n0; /* value */ ((yyval)).n1 = ((yyvsp[(5) - (6)])).n0; } break; case 33: #line 513 "record_parser.y" { /* stage number */ ((yyval)).n0 = ((yyvsp[(3) - (6)])).n0; /* value */ ((yyval)).n1 = ((yyvsp[(5) - (6)])).n0; } break; case 34: #line 522 "record_parser.y" { /* value */ ((yyval)).n0 = ((yyvsp[(3) - (6)])).n0; /* last */ ((yyval)).n1 = ((yyvsp[(5) - (6)])).n0; } break; case 35: #line 531 "record_parser.y" { ((yyval)).n0 = -1; ((yyval)).n1 = -1; } break; case 37: #line 539 "record_parser.y" { ((yyval)).n0 = -1; ((yyval)).n1 = -1; } break; case 39: #line 547 "record_parser.y" { ((yyval)).n0 = -1; ((yyval)).n1 = -1; } break; /* Line 1267 of yacc.c. */ #line 1999 "record_parser.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; /*------------------------------------. | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); #else { YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) { YYSIZE_T yyalloc = 2 * yysize; if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) yyalloc = YYSTACK_ALLOC_MAXIMUM; if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); yymsg = (char *) YYSTACK_ALLOC (yyalloc); if (yymsg) yymsg_alloc = yyalloc; else { yymsg = yymsgbuf; yymsg_alloc = sizeof yymsgbuf; } } if (0 < yysize && yysize <= yymsg_alloc) { (void) yysyntax_error (yymsg, yystate, yychar); yyerror (yymsg); } else { yyerror (YY_("syntax error")); if (yysize != 0) goto yyexhaustedlab; } } #endif } if (yyerrstatus == 3) { /* If just tried and failed to reuse look-ahead token after an error, discard it. */ if (yychar <= YYEOF) { /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; } else { yydestruct ("Error: discarding", yytoken, &yylval); yychar = YYEMPTY; } } /* Else will try to reuse look-ahead token after shifting the error token. */ goto yyerrlab1; /*---------------------------------------------------. | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (/*CONSTCOND*/ 0) goto yyerrorlab; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; /*-------------------------------------------------------------. | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (yyn != YYPACT_NINF) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) YYABORT; yydestruct ("Error: popping", yystos[yystate], yyvsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } if (yyn == YYFINAL) YYACCEPT; *++yyvsp = yylval; /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; #ifndef yyoverflow /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: yyerror (YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: if (yychar != YYEOF && yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval); /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", yystos[*yyssp], yyvsp); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif #if YYERROR_VERBOSE if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif /* Make sure YYID is used. */ return YYID (yyresult); } #line 553 "record_parser.y" /* additional C code */ /* this is the yyerror for bison */ static void record_error(const char *s) { fprintf (stderr, "record_parse: %s (line %d)\n", s, record_lineno); } void set_game_record(game_record *q) { p = q; } game_record * get_game_record(void) { return p; } dangen-0.5/record/record_parser.h0000644000175000017500000000524611625222474017713 0ustar00ooharaoohara00000000000000/* A Bison parser, made by GNU Bison 2.3. */ /* Skeleton interface for Bison's Yacc-like parsers in C Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. 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 2, 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ enum yytokentype { SPACE = 258, SEMICOLON = 259, VALUE_INT = 260, NUMBER_PLAY = 261, END = 262, PLAN = 263, SCORE_MAX = 264, NUMBER_CLEAR = 265, SCORE_MIN_CLEARED = 266, TOTAL = 267, TOTAL_SCORE = 268, STAGE_ID = 269, STAGE_SCORE = 270, STAGE_CLEARED = 271, NO_MATCH = 272 }; #endif /* Tokens. */ #define SPACE 258 #define SEMICOLON 259 #define VALUE_INT 260 #define NUMBER_PLAY 261 #define END 262 #define PLAN 263 #define SCORE_MAX 264 #define NUMBER_CLEAR 265 #define SCORE_MIN_CLEARED 266 #define TOTAL 267 #define TOTAL_SCORE 268 #define STAGE_ID 269 #define STAGE_SCORE 270 #define STAGE_CLEARED 271 #define NO_MATCH 272 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 #endif extern YYSTYPE record_lval; dangen-0.5/record/record_data.c0000644000175000017500000004352310276702736017330 0ustar00ooharaoohara00000000000000/* $Id: record_data.c,v 1.67 2005/07/22 00:34:02 oohara Exp $ */ /* FILE */ #include /* malloc */ #include /* time_t, time */ #include /* in $(top_srcdir)/ */ #include "stage.h" #include "score.h" /* in $(top_srcdir)/spqr */ #include "stage-list.h" #include "record_data.h" plan_record * plan_record_new(int valid) { int timestamp; plan_record *new = NULL; new = (plan_record *) malloc(sizeof(plan_record)); if (new == NULL) { fprintf(stderr, "plan_record_new: malloc failed\n"); return NULL; } new->score_max = -1; new->score_max_when = -1; new->number_clear = -1; new->number_clear_when = -1; new->score_min_cleared = -1; new->score_min_cleared_when = -1; new->number_play = -1; new->number_play_when = -1; if (valid) { timestamp = (int) (time(NULL)); if (timestamp < 0) { fprintf(stderr, "plan_record_new: timestamp is negative (%d)\n", timestamp); timestamp = -1; } new->score_max = 0; new->score_max_when = timestamp; new->number_clear = 0; new->number_clear_when = timestamp; new->score_min_cleared = 12345678; new->score_min_cleared_when = timestamp; new->number_play = 0; new->number_play_when = timestamp; } return new; } void plan_record_delete(plan_record *p) { if (p != NULL) free(p); } total_record * total_record_new(int stage_n, int valid) { int i; int timestamp; total_record *new = NULL; /* sanity check */ if (stage_n <= 0) { fprintf(stderr, "total_record_new: stage_n is non-positive (%d)\n", stage_n); return NULL; } new = (total_record *) malloc(sizeof(total_record)); if (new == NULL) { fprintf(stderr, "total_record_new: malloc failed\n"); return NULL; } new->total_score = -1; new->total_score_when = -1; new->stage_n = -1; new->stage_id = NULL; new->stage_score = NULL; new->stage_cleared = NULL; new->number_play = -1; new->number_play_when = -1; new->stage_id = (int *) malloc(sizeof(int) * stage_n); if (new->stage_id == NULL) { fprintf(stderr, "total_record_new: malloc(stage_id) failed\n"); total_record_delete(new); return NULL; } new->stage_score = (int *) malloc(sizeof(int) * stage_n); if (new->stage_score == NULL) { fprintf(stderr, "total_record_new: malloc(stage_score) failed\n"); total_record_delete(new); return NULL; } new->stage_cleared = (int *) malloc(sizeof(int) * stage_n); if (new->stage_cleared == NULL) { fprintf(stderr, "total_record_new: malloc(stage_cleared) failed\n"); total_record_delete(new); return NULL; } new->stage_n = stage_n; for (i = 0; i < stage_n; i++) { new->stage_id[i] = -1; new->stage_score[i] = -1; new->stage_cleared[i] = 0; } if (valid) { timestamp = (int) (time(NULL)); if (timestamp < 0) { fprintf(stderr, "total_record_new: timestamp is negative (%d)\n", timestamp); timestamp = -1; } new->total_score = 0; new->total_score_when = timestamp; new->number_play = 0; new->number_play_when = timestamp; for (i = 0; i < stage_n; i++) { new->stage_id[i] = -1; new->stage_score[i] = 0; new->stage_cleared[i] = 0; } } return new; } void total_record_delete(total_record *p) { if (p != NULL) { if (p->stage_id != NULL) free(p->stage_id); if (p->stage_score != NULL) free(p->stage_score); if (p->stage_cleared != NULL) free(p->stage_cleared); free(p); } } game_record * game_record_new(int stage_n, int plan_n, int valid) { int i; game_record *new = NULL; /* sanity check */ if (stage_n <= 0) { fprintf(stderr, "game_record_new: stage_n is non-positive (%d)\n", stage_n); return NULL; } if (plan_n <= 0) { fprintf(stderr, "game_record_new: plan_n is non-positive (%d)\n", plan_n); return NULL; } new = (game_record *) malloc(sizeof(game_record)); if (new == NULL) { fprintf(stderr, "game_record_new: malloc failed\n"); return NULL; } new->total_p = NULL; new->plan_p = NULL; new->plan_n = -1; new->total_p = total_record_new(stage_n, valid); if (new->total_p == NULL) { fprintf(stderr, "game_record_new: total_record_new failed\n"); game_record_delete(new); return NULL; } new->plan_p = (plan_record **) malloc(sizeof(plan_record *) * (plan_n + 1)); if (new->plan_p == NULL) { fprintf(stderr, "game_record_new: malloc(plan_p) failed\n"); game_record_delete(new); return NULL; } for (i = 0; i <= plan_n; i++) new->plan_p[i] = NULL; for (i = 0; i <= plan_n; i++) { new->plan_p[i] = plan_record_new(valid); if (new->plan_p[i] == NULL) { fprintf(stderr, "game_record_new: plan_record_new(%d) failed\n", i); game_record_delete(new); return NULL; } } new->plan_n = plan_n; return new; } void game_record_delete(game_record *p) { int i; if (p != NULL) { if (p->total_p != NULL) total_record_delete(p->total_p); if (p->plan_p != NULL) { for (i = p->plan_n; i >= 0; i--) { if (p->plan_p[i] != NULL) plan_record_delete(p->plan_p[i]); } free(p->plan_p); } free(p); } } /* return 1 (true) or 0 (false) */ int plan_record_valid(plan_record *p, int quiet) { if (p == NULL) { if (!quiet) fprintf(stderr, "plan_record_valid: p is NULL\n"); return 0; } if (p->number_play < 0) { if (!quiet) fprintf(stderr, "plan_record_valid: p->number_play is negative (%d)\n", p->number_play); return 0; } if (p->number_play > 0) { if (p->score_max < 0) { if (!quiet) fprintf(stderr, "plan_record_valid: p->score_max is negative (%d)\n", p->score_max); return 0; } if (p->score_max_when < 0) { if (!quiet) fprintf(stderr, "plan_record_valid: p->score_max_when is negative " "(%d)\n", p->score_max_when); return 0; } if (p->number_play_when < 0) { if (!quiet) fprintf(stderr, "plan_record_valid: p->number_play_when is negative " "(%d)\n", p->number_play_when); return 0; } } if (p->number_clear < 0) { if (!quiet) fprintf(stderr, "plan_record_valid: p->number_clear is negative (%d)\n", p->number_clear); return 0; } if (p->number_clear > p->number_play) { if (!quiet) fprintf(stderr, "plan_record_valid: p->number_clear > p->number_play " "(%d > %d)\n", p->number_clear, p->number_play); return 0; } if (p->number_clear > 0) { if (p->number_clear_when < 0) { if (!quiet) fprintf(stderr, "plan_record_valid: p->number_clear_when is negative " "(%d)\n", p->number_clear_when); return 0; } if (p->score_min_cleared < 0) { if (!quiet) fprintf(stderr, "plan_record_valid: p->score_min_cleared is negative " "(%d)\n", p->score_min_cleared); return 0; } if (p->score_min_cleared_when < 0) { if (!quiet) fprintf(stderr, "plan_record_valid: p->score_min_cleared_when " "is negative (%d)\n", p->score_min_cleared_when); return 0; } if (p->score_min_cleared > p->score_max) { if (!quiet) fprintf(stderr, "plan_record_valid: p->score_min_cleared > " "p->score_max " "(%d > %d)\n", p->score_min_cleared, p->score_max); return 0; } } return 1; } /* return 1 (true) or 0 (false) */ int total_record_valid(total_record *p, int quiet) { int i; int j; int total; if (p == NULL) { if (!quiet) fprintf(stderr, "total_record_valid: p is NULL\n"); return 0; } if (p->stage_n <= 0) { if (!quiet) fprintf(stderr, "total_record_valid: p->stage_n is non-positive (%d)\n", p->stage_n); return 0; } if (p->stage_id == NULL) { if (!quiet) fprintf(stderr, "total_record_valid: p->stage_id is NULL\n"); return 0; } if (p->stage_score == NULL) { if (!quiet) fprintf(stderr, "total_record_valid: p->stage_score is NULL\n"); return 0; } if (p->stage_cleared == NULL) { if (!quiet) fprintf(stderr, "total_record_valid: p->stage_cleared is NULL\n"); return 0; } if (p->number_play < 0) { if (!quiet) fprintf(stderr, "total_record_valid: p->number_play is negative (%d)\n", p->number_play); return 0; } if (p->number_play == 0) return 1; if (p->total_score < 0) { if (!quiet) fprintf(stderr, "total_record_valid: p->total_score is negative (%d)\n", p->total_score); return 0; } if (p->total_score_when < 0) { if (!quiet) fprintf(stderr, "total_record_valid: p->total_score_when is negative " "(%d)\n", p->total_score_when); return 0; } total = 0; for (i = 0; i < p->stage_n; i++) { if (p->stage_id[i] < 0) { break; } if (p->stage_score[i] < 0) { if (!quiet) fprintf(stderr, "total_record_valid: stage %d score is negative " "(%d)\n", i + 1, p->stage_score[i]); return 0; } total += p->stage_score[i]; } for (j = p->stage_n - 1; j >= i; j--) { if (p->stage_id[j] >= 0) { if (!quiet) fprintf(stderr, "total_record_valid: stage %d record is missing " "while stage %d is recorded\n", i + 1, j + 1); return 0; } } if (p->total_score != total) { if (!quiet) fprintf(stderr, "total_record_valid: p->total_score (%d) does not match " "total (%d)\n", p->total_score, total); return 0; } return 1; } /* return 1 (true) or 0 (false) */ int game_record_valid(game_record *p, int quiet) { int i; if (p == NULL) { if (!quiet) fprintf(stderr, "game_record_valid: p is NULL\n"); return 0; } if (p->total_p == NULL) { if (!quiet) fprintf(stderr, "game_record_valid: p->total_p is NULL\n"); return 0; } if (p->plan_p == NULL) { if (!quiet) fprintf(stderr, "game_record_valid: p->play_p is NULL\n"); return 0; } if (p->plan_n <= 0) { if (!quiet) fprintf(stderr, "game_record_valid: p->play_n is non-positive (%d)\n", p->plan_n); return 0; } if (!total_record_valid(p->total_p, quiet)) { if (!quiet) fprintf(stderr, "game_record_valid: p->total_p is invalid\n"); return 0; } for (i = 0; i <= p->plan_n; i++) { if (!plan_record_valid(p->plan_p[i], quiet)) { if (!quiet) fprintf(stderr, "game_record_valid: plan %d record is invalid\n", i); return 0; } } return 1; } void print_plan_record(FILE *stream, plan_record *p) { /* sanity check */ if (p == NULL) return; if (!plan_record_valid(p, 1)) return; fprintf(stream, "score-max %d %d;\n", p->score_max, p->score_max_when); fprintf(stream, "number-clear %d %d;\n", p->number_clear, p->number_clear_when); fprintf(stream, "score-min-cleared %d %d;\n", p->score_min_cleared, p->score_min_cleared_when); fprintf(stream, "number-play %d %d;\n", p->number_play, p->number_play_when); } void print_total_record(FILE *stream, total_record *p) { int i; /* sanity check */ if (p == NULL) return; if (!total_record_valid(p, 1)) return; fprintf(stream, "total-score %d %d;\n", p->total_score, p->total_score_when); for (i = 0; i < p->stage_n; i++) { fprintf(stream, "stage-id %d %d;\n", i + 1, p->stage_id[i]); fprintf(stream, "stage-score %d %d;\n", i + 1, p->stage_score[i]); fprintf(stream, "stage-cleared %d %d;\n", i + 1, p->stage_cleared[i]); } fprintf(stream, "number-play %d %d;\n", p->number_play, p->number_play_when); } void print_game_record(FILE *stream, game_record *p, stage_list *list) { int i; int j; /* sanity check */ if (p == NULL) return; if (!game_record_valid(p, 1)) return; fprintf(stream, "/* dangen play record */\n"); fprintf(stream, "\n"); fprintf(stream, "total;\n"); print_total_record(stream, p->total_p); fprintf(stream, "end;\n"); for (i = 0; i <= p->plan_n; i++) { if (plan_record_valid(p->plan_p[i], 1)) { fprintf(stream, "\n"); if (list != NULL) { for (j = 0; j < list->n; j++) { if ((list->p[j])->stage_id == i) { fprintf(stream, "/* [%s] %s */\n", stage_difficulty_string((list->p[j])->difficulty), (list->p[j])->name); break; } } } fprintf(stream, "plan %d;\n", i); print_plan_record(stream, p->plan_p[i]); fprintf(stream, "end;\n"); } } } /* return 0 on success, 1 on error */ int game_record_update(game_record *p) { int i; int n; int timestamp; plan_record *q = NULL; /* sanity check */ if (p == NULL) { fprintf(stderr, "game_record_update: p is NULL\n"); return 1; } if (!game_record_valid(p, 0)) { fprintf(stderr, "game_record_update: p is invalid\n"); return 1; } timestamp = (int) (time(NULL)); if (timestamp < 0) { fprintf(stderr, "game_record_update: timestamp is negative (%d)\n", timestamp); return 1; } /* if this is a real game, not the tutorial */ if (get_stage_id(1) > 0) { if (p->total_p->total_score < get_score()) { p->total_p->total_score = get_score(); p->total_p->total_score_when = timestamp; p->total_p->number_play_when = timestamp; for (i = 0; i < p->total_p->stage_n; i++) { p->total_p->stage_id[i] = -1; p->total_p->stage_score[i] = -1; p->total_p->stage_cleared[i] = 0; } for (i = 1; i <= get_stage_number(); i++) { if (get_stage_id(i) < 0) break; if (i > p->total_p->stage_n) { fprintf(stderr, "game_record_update: p->total_p->stage_n is " "too small (%d)\n", p->total_p->stage_n); return 1; } p->total_p->stage_id[i - 1] = get_stage_id(i); p->total_p->stage_score[i - 1] = get_stage_score(i); p->total_p->stage_cleared[i - 1] = get_stage_cleared(i); } } } for (i = 1; (i <= 5) && (i <= get_stage_number()); i++) { n = get_stage_id(i); if (n < 0) break; if (n > p->plan_n) { fprintf(stderr, "game_record_update: p->plan_n is " "too small (%d)\n", p->plan_n); return 1; } q = p->plan_p[n]; if (q->score_max < get_stage_score(i)) { q->score_max = get_stage_score(i); q->score_max_when = timestamp; q->number_play_when = timestamp; p->total_p->number_play_when = timestamp; } if ((get_stage_cleared(i)) && (q->score_min_cleared > get_stage_score(i))) { q->score_min_cleared = get_stage_score(i); q->score_min_cleared_when = timestamp; q->number_play_when = timestamp; p->total_p->number_play_when = timestamp; } } return 0; } /* return 0 on success, 1 on error */ int increment_play_total(game_record *p) { int timestamp; /* sanity check */ if (p == NULL) { fprintf(stderr, "increment_play_total: p is NULL\n"); return 1; } if (!game_record_valid(p, 0)) { fprintf(stderr, "increment_play_total: p is invalid\n"); return 1; } timestamp = (int) (time(NULL)); if (timestamp < 0) { fprintf(stderr, "increment_play_total: timestamp is negative (%d)\n", timestamp); return 1; } (p->total_p->number_play)++; if (p->total_p->number_play >= 10000000) p->total_p->number_play = 10000000; p->total_p->number_play_when = timestamp; return 0; } /* return 0 on success, 1 on error */ int increment_play_plan(game_record *p, int n) { int timestamp; plan_record *q = NULL; /* sanity check */ if (p == NULL) { fprintf(stderr, "increment_play_plan: p is NULL\n"); return 1; } if (!game_record_valid(p, 0)) { fprintf(stderr, "increment_play_plan: p is invalid\n"); return 1; } if (n < 0) { fprintf(stderr, "increment_play_plan: n is negative (%d)\n", n); return 1; } if (n > p->plan_n) { fprintf(stderr, "increment_play_plan: p->plan_n is too small (%d)\n", p->plan_n); return 1; } timestamp = (int) (time(NULL)); if (timestamp < 0) { fprintf(stderr, "increment_play_plan: timestamp is negative (%d)\n", timestamp); return 1; } q = p->plan_p[n]; (q->number_play)++; if (q->number_play >= 10000000) q->number_play = 10000000; q->number_play_when = timestamp; if (n > 0) p->total_p->number_play_when = timestamp; return 0; } /* return 0 on success, 1 on error */ int increment_clear_plan(game_record *p, int n) { int timestamp; plan_record *q = NULL; /* sanity check */ if (p == NULL) { fprintf(stderr, "increment_clear_plan: p is NULL\n"); return 1; } if (!game_record_valid(p, 0)) { fprintf(stderr, "increment_clear_plan: p is invalid\n"); return 1; } if (n < 0) { fprintf(stderr, "increment_clear_plan: n is negative (%d)\n", n); return 1; } if (n > p->plan_n) { fprintf(stderr, "increment_clear_plan: p->plan_n is too small (%d)\n", p->plan_n); return 1; } timestamp = (int) (time(NULL)); if (timestamp < 0) { fprintf(stderr, "increment_clear_plan: timestamp is negative (%d)\n", timestamp); return 1; } q = p->plan_p[n]; (q->number_clear)++; if (q->number_clear >= 10000000) q->number_clear = 10000000; q->number_clear_when = timestamp; q->number_play_when = timestamp; if (n > 0) p->total_p->number_play_when = timestamp; return 0; } dangen-0.5/record/record_data.h0000644000175000017500000000315210276702736017327 0ustar00ooharaoohara00000000000000/* $Id: record_data.h,v 1.26 2005/07/01 03:14:58 oohara Exp $ */ #ifndef __DANGEN_RECORD_DATA_H__ #define __DANGEN_RECORD_DATA_H__ /* FILE */ #include #include "stage-list.h" struct _plan_record { int score_max; int score_max_when; int number_clear; int number_clear_when; int score_min_cleared; int score_min_cleared_when; int number_play; int number_play_when; }; typedef struct _plan_record plan_record; struct _total_record { int total_score; int total_score_when; int stage_n; int *stage_id; int *stage_score; int *stage_cleared; int number_play; int number_play_when; }; typedef struct _total_record total_record; struct _game_record { total_record *total_p; plan_record **plan_p; int plan_n; }; typedef struct _game_record game_record; plan_record *plan_record_new(int valid); void plan_record_delete(plan_record *p); total_record *total_record_new(int stage_n, int valid); void total_record_delete(total_record *p); game_record *game_record_new(int stage_n, int plan_n, int valid); void game_record_delete(game_record *p); int plan_record_valid(plan_record *p, int quiet); int total_record_valid(total_record *p, int quiet); int game_record_valid(game_record *p, int quiet); void print_plan_record(FILE *stream, plan_record *p); void print_total_record(FILE *stream, total_record *p); void print_game_record(FILE *stream, game_record *p, stage_list *list); int game_record_update(game_record *p); int increment_play_total(game_record *p); int increment_play_plan(game_record *p, int n); int increment_clear_plan(game_record *p, int n); #endif /* __DANGEN_RECORD_DATA_H__ */ dangen-0.5/record/record_io.c0000644000175000017500000001360311625222727017016 0ustar00ooharaoohara00000000000000/* $Id: record_io.c,v 1.26 2011/08/24 16:24:55 oohara Exp $ */ /* NOT_HAVE_POSIX */ #include "config.h" /* FILE, fopen, rename */ #include /* free, getenv */ #include /* strdup, strerror */ #include /* errno */ #include #ifndef NOT_HAVE_POSIX /* DIR, opendir, closedir */ #include /* mkdir */ #include #endif /* not NOT_HAVE_POSIX */ #include "record_data.h" #include "record_lexical.h" #include "record_parser_public.h" #include "record_util.h" /* in $(top_srcdir)/spqr */ #include "stage-list.h" #include "record_io.h" #define SAVE_FILE "play-record.txt" #define SAVE_FILE_BACKUP "play-record.txt.bak" static FILE *open_game_record_file(int save); static game_record *game_record_load_fallback(void); static char *game_record_dir_name(void); game_record * game_record_load(void) { game_record *p = NULL; FILE *file = NULL; file = open_game_record_file(0); if (file == NULL) { /* this is not an error */ return game_record_load_fallback(); } p = game_record_new(6, NUMBER_PLAN, 0); if (p == NULL) { fprintf(stderr, "game_record_load: game_record_new failed\n"); fclose(file); return game_record_load_fallback(); } record_lineno = 1; record_read_from_file(file); set_game_record(p); if (record_parse() != 0) { fprintf(stderr, "game_record_load: record_parse failed\n"); fclose(file); game_record_delete(p); return game_record_load_fallback(); } p = get_game_record(); set_game_record(NULL); fclose(file); if (!game_record_valid(p, 0)) { fprintf(stderr, "game_record_load: invalid game record loaded\n"); game_record_delete(p); return game_record_load_fallback(); } return p; } /* return NULL on error */ static FILE * open_game_record_file(int save) { FILE *file = NULL; char *dirname = NULL; char *filename = NULL; char *filename_backup = NULL; #ifndef NOT_HAVE_POSIX DIR *p_dir = NULL; #endif /* not NOT_HAVE_POSIX */ const char *mode = NULL; if (save) mode = "w"; else mode = "r"; dirname = game_record_dir_name(); if (dirname == NULL) { fprintf(stderr, "open_game_record_file: game_record_dir_name failed\n"); return NULL; } filename = concatenate_string(NULL, 2, dirname, SAVE_FILE); if (filename == NULL) { fprintf(stderr, "open_game_record_file: can't set filename\n"); free(dirname); return NULL; } filename_backup = concatenate_string(NULL, 2, dirname, SAVE_FILE_BACKUP); if (filename == NULL) { fprintf(stderr, "open_game_record_file: can't set filename_backup\n"); free(filename); free(dirname); return NULL; } #ifndef NOT_HAVE_POSIX /* create the play record directory unless there is already one */ p_dir = opendir(dirname); if (p_dir != NULL) { errno = 0; if (closedir(p_dir) != 0) { fprintf(stderr, "open_game_record_file: closedir failed\n"); if (errno != 0) fprintf(stderr, " (%s)", strerror(errno)); fprintf(stderr, "\n"); fprintf(stderr, "open_game_record_file: opening anyway\n"); /* open anyway */ } } else { errno = 0; if (mkdir(dirname, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) != 0) { fprintf(stderr, "open_game_record_file: mkdir(%s) failed", dirname); if (errno != 0) fprintf(stderr, " (%s)", strerror(errno)); fprintf(stderr, "\n"); free(filename_backup); free(filename); free(dirname); return NULL; } } #endif /* not NOT_HAVE_POSIX */ /* rotate the play record file if possible */ if (save) { if (rename(filename, filename_backup) == -1) { /* this is not an error */ ; /* open anyway */ } } errno = 0; file = fopen(filename, mode); if (file == NULL) { if ((save) || (errno != ENOENT)) { fprintf(stderr, "open_game_record_file: fopen(%s) failed", filename); if (errno != 0) fprintf(stderr, " (%s)", strerror(errno)); fprintf(stderr, "\n"); } free(filename_backup); free(filename); free(dirname); return NULL; } free(filename_backup); free(filename); free(dirname); return file; } static game_record * game_record_load_fallback(void) { game_record *p = NULL; p = game_record_new(6, NUMBER_PLAN, 1); if (p == NULL) { fprintf(stderr, "game_record_load_fallback: game_record_new failed\n"); return NULL; } if (!game_record_valid(p, 0)) { fprintf(stderr, "game_record_load_fallback: sanity check failed\n"); game_record_delete(p); return NULL; } return p; } /* return 0 on success, 1 on error */ int game_record_save(game_record *p) { FILE *file = NULL; stage_list *list = NULL; /* sanity check */ if (p == NULL) { fprintf(stderr, "game_record_save: p is NULL\n"); return 1; } if (!game_record_valid(p, 0)) { fprintf(stderr, "game_record_save: p is invalid\n"); return 1; } file = open_game_record_file(1); if (file == NULL) { fprintf(stderr, "game_record_save: open_game_record_file failed\n"); return 1; } list = stage_list_new(NULL, NULL); if (list == NULL) { fprintf(stderr, "game_record_save: stage_list_new failed\n"); fprintf(stderr, "game_record_save: saving anyway\n"); /* save anyway */ } print_game_record(file, p, list); if (list != NULL) stage_list_delete(list); errno = 0; if (fclose(file) != 0) { fprintf(stderr, "game_record_save: fclose failed"); if (errno != 0) fprintf(stderr, " (%s)", strerror(errno)); fprintf(stderr, "\n"); return 1; } return 0; } /* return NULL on error */ static char * game_record_dir_name(void) { #ifdef NOT_HAVE_POSIX return strdup("save/"); #else /* not NOT_HAVE_POSIX */ char *s = getenv("HOME"); if (s == NULL) return NULL; return concatenate_string(NULL, 2, s, "/.dangen/"); #endif /* not NOT_HAVE_POSIX */ /* should not reach here */ return NULL; } dangen-0.5/record/record_io.h0000644000175000017500000000041310276702736017022 0ustar00ooharaoohara00000000000000/* $Id: record_io.h,v 1.2 2005/06/30 15:29:15 oohara Exp $ */ #ifndef __DANGEN_RECORD_IO_H__ #define __DANGEN_RECORD_IO_H__ #include "record_data.h" game_record *game_record_load(void); int game_record_save(game_record *p); #endif /*not __DANGEN_RECORD_IO_H__ */ dangen-0.5/record/record_lexical.h0000644000175000017500000000066311625223431020030 0ustar00ooharaoohara00000000000000/* $Id: record_lexical.h,v 1.5 2011/08/24 16:30:17 oohara Exp $ */ #ifndef __DANGEN_RECORD_LEXICAL_H__ #define __DANGEN_RECORD_LEXICAL_H__ /* FILE */ #include /* yylineno */ extern int record_lineno; /* yylex */ int record_lex(void); /* yylex_destroy */ int record_lex_destroy(void); void record_read_from_file(FILE *file); void record_read_from_string(const char *string); #endif /* not __DANGEN_RECORD_LEXICAL_H__ */ dangen-0.5/record/record_lexical.l0000644000175000017500000000436611625225610020041 0ustar00ooharaoohara00000000000000/* hi emacs, this is a part of -*- C -*- source */ /* $Id: record_lexical.l,v 1.30 2011/08/24 16:49:12 oohara Exp $ */ /* process this file with flex -Precord_ */ /* definitions */ %option yylineno %option noyywrap %option noinput %option nounput %option noyyget_leng %option noyyget_text %option noyyget_lineno %option noyyset_lineno %option noyyget_in %option noyyset_in %option noyyget_out %option noyyset_out %option noyyget_debug %option noyyset_debug %{ #include /* strchr */ #include #include "record_util.h" #include "record_parser_private.h" #include "record_lexical.h" static int value_int = 0; %} /* rules */ /* this comment must be before %% */ %% (\/\*([^*]|(\*[^/]))*\*\/)|([[:space:]]+) { record_lval.n0 = -1; record_lval.n1 = -1; return SPACE; } ; { record_lval.n0 = -1; record_lval.n1 = -1; return SEMICOLON; } [+\-]?[0-9]+ { /* you can write 7 as 007 for example, but it is always decimal, * not octal */ convert_to_number(&value_int, yytext); record_lval.n0 = value_int; record_lval.n1 = -1; return VALUE_INT; } number-play { record_lval.n0 = -1; record_lval.n1 = -1; return NUMBER_PLAY; } end { record_lval.n0 = -1; record_lval.n1 = -1; return END; } plan { record_lval.n0 = -1; record_lval.n1 = -1; return PLAN; } score-max { record_lval.n0 = -1; record_lval.n1 = -1; return SCORE_MAX; } number-clear { record_lval.n0 = -1; record_lval.n1 = -1; return NUMBER_CLEAR; } score-min-cleared { record_lval.n0 = -1; record_lval.n1 = -1; return SCORE_MIN_CLEARED; } total { record_lval.n0 = -1; record_lval.n1 = -1; return TOTAL; } total-score { record_lval.n0 = -1; record_lval.n1 = -1; return TOTAL_SCORE; } stage-id { record_lval.n0 = -1; record_lval.n1 = -1; return STAGE_ID; } stage-score { record_lval.n0 = -1; record_lval.n1 = -1; return STAGE_SCORE; } stage-cleared { record_lval.n0 = -1; record_lval.n1 = -1; return STAGE_CLEARED; } .|\n { /* catch-all */ record_lval.n0 = -1; record_lval.n1 = -1; return NO_MATCH; } %% /* user code */ void record_read_from_file(FILE *file) { /* yyrestart */ record_restart(file); } void record_read_from_string(const char *string) { /* yy_scan_string */ record__scan_string(string); } dangen-0.5/record/record_parser.y0000644000175000017500000002353711625222440017730 0ustar00ooharaoohara00000000000000/* $Id: record_parser.y,v 1.38 2011/08/24 16:21:52 oohara Exp $ */ /* process this file with bison -d */ /* C declarations */ %{ #include #include "record_data.h" #include "record_lexical.h" #include "record_parser_private.h" #include "record_parser_public.h" static game_record *p = NULL; /* yyerror */ static void record_error(const char *s); %} /* bison declatations */ %name-prefix="record_" %token SPACE %token SEMICOLON %token VALUE_INT %token NUMBER_PLAY %token END %token PLAN %token SCORE_MAX %token NUMBER_CLEAR %token SCORE_MIN_CLEARED %token TOTAL %token TOTAL_SCORE %token STAGE_ID %token STAGE_SCORE %token STAGE_CLEARED %token NO_MATCH %% /* grammar rules */ play_record: /* empty */ { ($$).n0 = -1; ($$).n1 = -1; } | play_record SPACE { ($$).n0 = -1; ($$).n1 = -1; } | play_record SEMICOLON { ($$).n0 = -1; ($$).n1 = -1; } | play_record block { ($$).n0 = -1; ($$).n1 = -1; } ; block: plan_record_block { ($$).n0 = -1; ($$).n1 = -1; } | total_record_block { ($$).n0 = -1; ($$).n1 = -1; } ; plan_record_block: plan_record_stmt block_end { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->plan_p == NULL) { record_error("p->plan_p is NULL"); YYABORT; } if ((($1).n0 < 0) || (($1).n0 > p->plan_n)) { record_error("invalid plan"); YYABORT; } if (!plan_record_valid(p->plan_p[($1).n0], 0)) { record_error("incomplete plan record"); YYABORT; } ($$).n0 = -1; ($$).n1 = -1; } ; plan_record_stmt: plan_record_begin { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->plan_p == NULL) { record_error("p->plan_p is NULL"); YYABORT; } if ((($1).n0 < 0) || (($1).n0 > p->plan_n)) { record_error("invalid plan"); YYABORT; } /* plan id */ ($$).n0 = ($1).n0; ($$).n1 = -1; } | plan_record_stmt SPACE { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->plan_p == NULL) { record_error("p->plan_p is NULL"); YYABORT; } if ((($1).n0 < 0) || (($1).n0 > p->plan_n)) { record_error("invalid plan"); YYABORT; } /* plan id */ ($$).n0 = ($1).n0; ($$).n1 = -1; } | plan_record_stmt SEMICOLON { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->plan_p == NULL) { record_error("p->plan_p is NULL"); YYABORT; } if ((($1).n0 < 0) || (($1).n0 > p->plan_n)) { record_error("invalid plan"); YYABORT; } /* plan id */ ($$).n0 = ($1).n0; ($$).n1 = -1; } | plan_record_stmt score_max_stmt { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->plan_p == NULL) { record_error("p->plan_p is NULL"); YYABORT; } if ((($1).n0 < 0) || (($1).n0 > p->plan_n)) { record_error("invalid plan"); YYABORT; } (p->plan_p[($1).n0])->score_max = ($2).n0; (p->plan_p[($1).n0])->score_max_when = ($2).n1; /* plan id */ ($$).n0 = ($1).n0; ($$).n1 = -1; } | plan_record_stmt number_clear_stmt { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->plan_p == NULL) { record_error("p->plan_p is NULL"); YYABORT; } if ((($1).n0 < 0) || (($1).n0 > p->plan_n)) { record_error("invalid plan"); YYABORT; } (p->plan_p[($1).n0])->number_clear = ($2).n0; (p->plan_p[($1).n0])->number_clear_when = ($2).n1; /* plan id */ ($$).n0 = ($1).n0; ($$).n1 = -1; } | plan_record_stmt score_min_cleared_stmt { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->plan_p == NULL) { record_error("p->plan_p is NULL"); YYABORT; } if ((($1).n0 < 0) || (($1).n0 > p->plan_n)) { record_error("invalid plan"); YYABORT; } (p->plan_p[($1).n0])->score_min_cleared = ($2).n0; (p->plan_p[($1).n0])->score_min_cleared_when = ($2).n1; /* plan id */ ($$).n0 = ($1).n0; ($$).n1 = -1; } | plan_record_stmt number_play_stmt { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->plan_p == NULL) { record_error("p->plan_p is NULL"); YYABORT; } if ((($1).n0 < 0) || (($1).n0 > p->plan_n)) { record_error("invalid plan"); YYABORT; } (p->plan_p[($1).n0])->number_play = ($2).n0; (p->plan_p[($1).n0])->number_play_when = ($2).n1; /* plan id */ ($$).n0 = ($1).n0; ($$).n1 = -1; } ; plan_record_begin: PLAN spaces VALUE_INT stmt_end { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->plan_p == NULL) { record_error("p->plan_p is NULL"); YYABORT; } if ((($3).n0 < 0) || (($3).n0 > p->plan_n)) { record_error("invalid plan"); YYABORT; } /* plan id */ ($$).n0 = ($3).n0; ($$).n1 = -1; } ; score_max_stmt: SCORE_MAX spaces VALUE_INT spaces VALUE_INT stmt_end { /* value */ ($$).n0 = ($3).n0; /* when */ ($$).n1 = ($5).n0; } ; number_clear_stmt: NUMBER_CLEAR spaces VALUE_INT spaces VALUE_INT stmt_end { /* value */ ($$).n0 = ($3).n0; /* last */ ($$).n1 = ($5).n0; } ; score_min_cleared_stmt: SCORE_MIN_CLEARED spaces VALUE_INT spaces VALUE_INT stmt_end { /* value */ ($$).n0 = ($3).n0; /* when */ ($$).n1 = ($5).n0; } ; total_record_block: total_record_stmt block_end { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->total_p == NULL) { record_error("p->total_p is NULL"); YYABORT; } if (!total_record_valid(p->total_p, 0)) { record_error("incomplete total record"); YYABORT; } ($$).n0 = -1; ($$).n1 = -1; } ; total_record_stmt: total_record_begin { ($$).n0 = -1; ($$).n1 = -1; } | total_record_stmt SPACE { ($$).n0 = -1; ($$).n1 = -1; } | total_record_stmt SEMICOLON { ($$).n0 = -1; ($$).n1 = -1; } | total_record_stmt total_score_stmt { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->total_p == NULL) { record_error("p->total_p is NULL"); YYABORT; } p->total_p->total_score = ($2).n0; p->total_p->total_score_when = ($2).n1; ($$).n0 = -1; ($$).n1 = -1; } | total_record_stmt stage_id_stmt { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->total_p == NULL) { record_error("p->total_p is NULL"); YYABORT; } if (p->total_p->stage_id == NULL) { record_error("p->total_p->stage_id is NULL"); YYABORT; } if ((($2).n0 <= 0) || (($2).n0 > p->total_p->stage_n)) { record_error("invalid stage"); YYABORT; } p->total_p->stage_id[($2).n0 - 1] = ($2).n1; ($$).n0 = -1; ($$).n1 = -1; } | total_record_stmt stage_score_stmt { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->total_p == NULL) { record_error("p->total_p is NULL"); YYABORT; } if (p->total_p->stage_score == NULL) { record_error("p->total_p->stage_score is NULL"); YYABORT; } if ((($2).n0 <= 0) || (($2).n0 > p->total_p->stage_n)) { record_error("invalid stage"); YYABORT; } p->total_p->stage_score[($2).n0 - 1] = ($2).n1; ($$).n0 = -1; ($$).n1 = -1; } | total_record_stmt stage_cleared_stmt { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->total_p == NULL) { record_error("p->total_p is NULL"); YYABORT; } if (p->total_p->stage_cleared == NULL) { record_error("p->total_p->stage_cleared is NULL"); YYABORT; } if ((($2).n0 <= 0) || (($2).n0 > p->total_p->stage_n)) { record_error("invalid stage"); YYABORT; } p->total_p->stage_cleared[($2).n0 - 1] = ($2).n1; ($$).n0 = -1; ($$).n1 = -1; } | total_record_stmt number_play_stmt { if (p == NULL) { record_error("p is NULL"); YYABORT; } if (p->total_p == NULL) { record_error("p->total_p is NULL"); YYABORT; } p->total_p->number_play = ($2).n0; p->total_p->number_play_when = ($2).n1; ($$).n0 = -1; ($$).n1 = -1; } ; total_record_begin: TOTAL stmt_end { ($$).n0 = -1; ($$).n1 = -1; } ; total_score_stmt: TOTAL_SCORE spaces VALUE_INT spaces VALUE_INT stmt_end { /* value */ ($$).n0 = ($3).n0; /* when */ ($$).n1 = ($5).n0; } ; stage_id_stmt: STAGE_ID spaces VALUE_INT spaces VALUE_INT stmt_end { /* stage number */ ($$).n0 = ($3).n0; /* value */ ($$).n1 = ($5).n0; } ; stage_score_stmt: STAGE_SCORE spaces VALUE_INT spaces VALUE_INT stmt_end { /* stage number */ ($$).n0 = ($3).n0; /* value */ ($$).n1 = ($5).n0; } ; stage_cleared_stmt: STAGE_CLEARED spaces VALUE_INT spaces VALUE_INT stmt_end { /* stage number */ ($$).n0 = ($3).n0; /* value */ ($$).n1 = ($5).n0; } ; number_play_stmt: NUMBER_PLAY spaces VALUE_INT spaces VALUE_INT stmt_end { /* value */ ($$).n0 = ($3).n0; /* last */ ($$).n1 = ($5).n0; } ; block_end: END stmt_end { ($$).n0 = -1; ($$).n1 = -1; } ; stmt_end: SEMICOLON | spaces SEMICOLON { ($$).n0 = -1; ($$).n1 = -1; } ; spaces: SPACE | spaces SPACE { ($$).n0 = -1; ($$).n1 = -1; } ; %% /* additional C code */ /* this is the yyerror for bison */ static void record_error(const char *s) { fprintf (stderr, "record_parse: %s (line %d)\n", s, record_lineno); } void set_game_record(game_record *q) { p = q; } game_record * get_game_record(void) { return p; } dangen-0.5/record/record_parser_private.h0000644000175000017500000000067710276702736021455 0ustar00ooharaoohara00000000000000/* $Id: record_parser_private.h,v 1.3 2005/06/29 17:10:46 oohara Exp $ */ #ifndef __DANGEN_RECORD_PARSER_PRIVATE_H__ #define __DANGEN_RECORD_PARSER_PRIVATE_H__ struct _semantic_value { int n0; int n1; }; typedef struct _semantic_value semantic_value; #define YYSTYPE semantic_value /* this is generated by bison -d */ /* this must be after #define YYSTYPE */ #include "record_parser.h" #endif /* not __DANGEN_RECORD_PARSER_PRIVATE_H__ */ dangen-0.5/record/record_parser_public.h0000644000175000017500000000053610276702736021253 0ustar00ooharaoohara00000000000000/* $Id: record_parser_public.h,v 1.8 2005/06/29 17:08:56 oohara Exp $ */ #ifndef __DANGEN_RECORD_PARSER_PUBLIC_H__ #define __DANGEN_RECORD_PARSER_PUBLIC_H__ #include "record_data.h" /* yyparse */ int record_parse(void); void set_game_record(game_record *q); game_record *get_game_record(void); #endif /* not __DANGEN_RECORD_PARSER_PUBLIC_H__ */ dangen-0.5/record/record_util.c0000644000175000017500000000477010276702736017375 0ustar00ooharaoohara00000000000000/* $Id: record_util.c,v 1.10 2005/07/11 20:06:27 oohara Exp $ */ #include /* strtol */ #include /* errno */ #include /* INT_MIN, INT_MAX */ #include /* strlen, strcpy */ #include #include #include "record_util.h" /* convert string (arg 2) to a number and store it to value (arg 1) * return 0 on success, 1 on error */ int convert_to_number(int *value, const char *string) { long int temp; char *tail; /* to detect overflow */ errno = 0; temp = strtol(string, &tail, 10); if (tail[0] != '\0') { fprintf(stderr, "convert_to_number: string is not a number\n"); return 1; } if (errno != 0) { fprintf(stderr, "convert_to_number: number overflowed\n"); return 1; } if ((temp <= INT_MIN) || (temp >= INT_MAX)) { fprintf(stderr, "convert_to_number: too big or small integer\n"); return 1; } *value = (int) temp; return 0; } /* add ... (arg 3--) at the end of result (arg 1) * ... must be exactly n (arg 2) pointers to const char * if result (arg 1) is not NULL, its memory must be allocated * with malloc(); it is resized as necessary * ... (arg 3--) are copied * return NULL on error */ char * concatenate_string(char *result, int n, ...) { va_list ap; int i; int length; int head; const char *s = NULL; char *temp = NULL; /* sanity check */ if (n < 0) { fprintf(stderr, "concatenate_string: n is negative (%d)\n", n); return NULL; } if (n == 0) return result; va_start(ap, n); length = 0; for (i = 0; i < n; i++) { s = va_arg(ap, const char *); if (s == NULL) { fprintf(stderr, "concatenate_string: string %d is NULL\n", i + 1); return NULL; } length += (int) strlen(s); } va_end(ap); if (length < 0) { fprintf(stderr, "concatenate_string: length is negative (%d)\n", length); return NULL; } if (length == 0) return result; /* +1 is for the trailing '\0' */ if (result == NULL) { temp = (char *) malloc(sizeof(char) * (length + 1)); } else { length += (int) strlen(result); temp = (char *) realloc(result, sizeof(char) * (length + 1)); } if (temp == NULL) { fprintf(stderr, "concatenate_string: can't allocate enough memory\n"); return NULL; } result = temp; va_start(ap, n); head = 0; for (i = 0; i < n; i++) { s = va_arg(ap, const char *); strcpy(result + head, s); head += (int) strlen(s); } va_end(ap); result[length] = '\0'; return result; } dangen-0.5/record/record_util.h0000644000175000017500000000043210276702736017371 0ustar00ooharaoohara00000000000000/* $Id: record_util.h,v 1.4 2005/07/11 19:40:52 oohara Exp $ */ #ifndef __DANGEN_RECORD_UTIL_H__ #define __DANGEN_RECORD_UTIL_H__ int convert_to_number(int *value, const char *string); char *concatenate_string(char *result, int n, ...); #endif /* not __DANGEN_RECORD_UTIL_H__ */ dangen-0.5/spqr/0000777000175000017500000000000011625724131014411 5ustar00ooharaoohara00000000000000dangen-0.5/spqr/Makefile.am0000644000175000017500000000606311625011725016444 0ustar00ooharaoohara00000000000000## Makefile.am for dangen/spqr ## process this file with automake --foreign to generate Makefile.in # $Id: Makefile.am,v 1.91 2011/08/23 20:55:49 oohara Exp $ SUBDIRS = image noinst_LIBRARIES = libspqr.a libspqr_a_SOURCES = afterdeath.c \ afterdeath.h \ brilliance.c \ brilliance.h \ cat-tail-grep.c \ cat-tail-grep.h \ cat-tail.c \ cat-tail.h \ empty-wind.c \ empty-wind.h \ explosion.c \ explosion.h \ flatdice.c \ flatdice.h \ fragment.c \ fragment.h \ gosanpachi.c \ gosanpachi.h \ hatsuda.c \ hatsuda.h \ hugin.c \ hugin.h \ insane-hand.c \ insane-hand.h \ laser.c \ laser.h \ last-boss.c \ last-boss.h \ mankanshoku.c \ mankanshoku.h \ negation-engine.c \ negation-engine.h \ net-can-howl.c \ net-can-howl.h \ nexus.c \ nexus.h \ normal-enemy.c \ normal-enemy.h \ normal-shot.c \ normal-shot.h \ p-can.c \ p-can.h \ perpeki.c \ perpeki.h \ plan-0.c \ plan-0.h \ plan-1.c \ plan-1.h \ plan-2.c \ plan-2.h \ plan-3.c \ plan-3.h \ plan-4.c \ plan-4.h \ plan-5.c \ plan-5.h \ plan-6.c \ plan-6.h \ plan-7.c \ plan-7.h \ plan-8.c \ plan-8.h \ plan-9.c \ plan-9.h \ plan-10.c \ plan-10.h \ plan-11.c \ plan-11.h \ plan-12.c \ plan-12.h \ plan-13.c \ plan-13.h \ plan-14.c \ plan-14.h \ plan-15.c \ plan-15.h \ plan-16.c \ plan-16.h \ plan-17.c \ plan-17.h \ plan-18.c \ plan-18.h \ plan-19.c \ plan-19.h \ plan-20.c \ plan-20.h \ player-shot.c \ player-shot.h \ player.c \ player.h \ respiration.c \ respiration.h \ result.c \ result.h \ scheduler.c \ scheduler.h \ seiron-fake.c \ seiron-fake.h \ seiron.c \ seiron.h \ show-record.c \ show-record.h \ silver-chimera.c \ silver-chimera.h \ spellbook.c \ spellbook.h \ stage-clear.c \ stage-clear.h \ stage-list.c \ stage-list.h \ stage-select.c \ stage-select.h \ stage-title.c \ stage-title.h \ strikers.c \ strikers.h \ tadashi.c \ tadashi.h \ tenmado.c \ tenmado.h \ theorem-weapon.c \ theorem-weapon.h \ title.c \ title.h \ tutor.c \ tutor.h \ w-ko.c \ w-ko.h \ wall-0.c \ wall-0.h \ wall-4.c \ wall-4.h \ wall-8.c \ wall-8.h \ wall-11.c \ wall-11.h \ wall-13.c \ wall-13.h \ warning.c \ warning.h \ watcher-below.c \ watcher-below.h #CC_WARNINGS = -Wall # the overkill warnings # I don't use -Wtraditional because I use string concatenation # use -Wno-long-long because -pedantic implies -Wlong-long CC_WARNINGS = -Wall -Wshadow -Wpointer-arith -Wcast-qual \ -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \ -Wmissing-declarations -Wnested-externs -Winline -pedantic -Wno-long-long # let's hardcode SDL flags here SDL_CFLAGS=`sdl-config --cflags` # sdl-config --libs is added to LIBS in configure # -g -O2 are in CFLAGS by default, don't use @CFLAGS@ here AM_CFLAGS = $(SDL_CFLAGS) $(CC_WARNINGS) AM_CPPFLAGS = -DDATADIR=\"$(datadir)\" \ -DLOCALSTATEDIR=\"$(localstatedir)\" \ -I$(top_srcdir) \ -I$(top_srcdir)/libtenm \ -I$(top_srcdir)/record dangen-0.5/spqr/Makefile.in0000644000175000017500000006541011625012016016450 0ustar00ooharaoohara00000000000000# Makefile.in generated by automake 1.11 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # $Id: Makefile.am,v 1.91 2011/08/23 20:55:49 oohara Exp $ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : subdir = spqr DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LIBRARIES = $(noinst_LIBRARIES) AR = ar ARFLAGS = cru libspqr_a_AR = $(AR) $(ARFLAGS) libspqr_a_LIBADD = am_libspqr_a_OBJECTS = afterdeath.$(OBJEXT) brilliance.$(OBJEXT) \ cat-tail-grep.$(OBJEXT) cat-tail.$(OBJEXT) \ empty-wind.$(OBJEXT) explosion.$(OBJEXT) flatdice.$(OBJEXT) \ fragment.$(OBJEXT) gosanpachi.$(OBJEXT) hatsuda.$(OBJEXT) \ hugin.$(OBJEXT) insane-hand.$(OBJEXT) laser.$(OBJEXT) \ last-boss.$(OBJEXT) mankanshoku.$(OBJEXT) \ negation-engine.$(OBJEXT) net-can-howl.$(OBJEXT) \ nexus.$(OBJEXT) normal-enemy.$(OBJEXT) normal-shot.$(OBJEXT) \ p-can.$(OBJEXT) perpeki.$(OBJEXT) plan-0.$(OBJEXT) \ plan-1.$(OBJEXT) plan-2.$(OBJEXT) plan-3.$(OBJEXT) \ plan-4.$(OBJEXT) plan-5.$(OBJEXT) plan-6.$(OBJEXT) \ plan-7.$(OBJEXT) plan-8.$(OBJEXT) plan-9.$(OBJEXT) \ plan-10.$(OBJEXT) plan-11.$(OBJEXT) plan-12.$(OBJEXT) \ plan-13.$(OBJEXT) plan-14.$(OBJEXT) plan-15.$(OBJEXT) \ plan-16.$(OBJEXT) plan-17.$(OBJEXT) plan-18.$(OBJEXT) \ plan-19.$(OBJEXT) plan-20.$(OBJEXT) player-shot.$(OBJEXT) \ player.$(OBJEXT) respiration.$(OBJEXT) result.$(OBJEXT) \ scheduler.$(OBJEXT) seiron-fake.$(OBJEXT) seiron.$(OBJEXT) \ show-record.$(OBJEXT) silver-chimera.$(OBJEXT) \ spellbook.$(OBJEXT) stage-clear.$(OBJEXT) stage-list.$(OBJEXT) \ stage-select.$(OBJEXT) stage-title.$(OBJEXT) \ strikers.$(OBJEXT) tadashi.$(OBJEXT) tenmado.$(OBJEXT) \ theorem-weapon.$(OBJEXT) title.$(OBJEXT) tutor.$(OBJEXT) \ w-ko.$(OBJEXT) wall-0.$(OBJEXT) wall-4.$(OBJEXT) \ wall-8.$(OBJEXT) wall-11.$(OBJEXT) wall-13.$(OBJEXT) \ warning.$(OBJEXT) watcher-below.$(OBJEXT) libspqr_a_OBJECTS = $(am_libspqr_a_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(libspqr_a_SOURCES) DIST_SOURCES = $(libspqr_a_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build_alias = @build_alias@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = image noinst_LIBRARIES = libspqr.a libspqr_a_SOURCES = afterdeath.c \ afterdeath.h \ brilliance.c \ brilliance.h \ cat-tail-grep.c \ cat-tail-grep.h \ cat-tail.c \ cat-tail.h \ empty-wind.c \ empty-wind.h \ explosion.c \ explosion.h \ flatdice.c \ flatdice.h \ fragment.c \ fragment.h \ gosanpachi.c \ gosanpachi.h \ hatsuda.c \ hatsuda.h \ hugin.c \ hugin.h \ insane-hand.c \ insane-hand.h \ laser.c \ laser.h \ last-boss.c \ last-boss.h \ mankanshoku.c \ mankanshoku.h \ negation-engine.c \ negation-engine.h \ net-can-howl.c \ net-can-howl.h \ nexus.c \ nexus.h \ normal-enemy.c \ normal-enemy.h \ normal-shot.c \ normal-shot.h \ p-can.c \ p-can.h \ perpeki.c \ perpeki.h \ plan-0.c \ plan-0.h \ plan-1.c \ plan-1.h \ plan-2.c \ plan-2.h \ plan-3.c \ plan-3.h \ plan-4.c \ plan-4.h \ plan-5.c \ plan-5.h \ plan-6.c \ plan-6.h \ plan-7.c \ plan-7.h \ plan-8.c \ plan-8.h \ plan-9.c \ plan-9.h \ plan-10.c \ plan-10.h \ plan-11.c \ plan-11.h \ plan-12.c \ plan-12.h \ plan-13.c \ plan-13.h \ plan-14.c \ plan-14.h \ plan-15.c \ plan-15.h \ plan-16.c \ plan-16.h \ plan-17.c \ plan-17.h \ plan-18.c \ plan-18.h \ plan-19.c \ plan-19.h \ plan-20.c \ plan-20.h \ player-shot.c \ player-shot.h \ player.c \ player.h \ respiration.c \ respiration.h \ result.c \ result.h \ scheduler.c \ scheduler.h \ seiron-fake.c \ seiron-fake.h \ seiron.c \ seiron.h \ show-record.c \ show-record.h \ silver-chimera.c \ silver-chimera.h \ spellbook.c \ spellbook.h \ stage-clear.c \ stage-clear.h \ stage-list.c \ stage-list.h \ stage-select.c \ stage-select.h \ stage-title.c \ stage-title.h \ strikers.c \ strikers.h \ tadashi.c \ tadashi.h \ tenmado.c \ tenmado.h \ theorem-weapon.c \ theorem-weapon.h \ title.c \ title.h \ tutor.c \ tutor.h \ w-ko.c \ w-ko.h \ wall-0.c \ wall-0.h \ wall-4.c \ wall-4.h \ wall-8.c \ wall-8.h \ wall-11.c \ wall-11.h \ wall-13.c \ wall-13.h \ warning.c \ warning.h \ watcher-below.c \ watcher-below.h #CC_WARNINGS = -Wall # the overkill warnings # I don't use -Wtraditional because I use string concatenation # use -Wno-long-long because -pedantic implies -Wlong-long CC_WARNINGS = -Wall -Wshadow -Wpointer-arith -Wcast-qual \ -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \ -Wmissing-declarations -Wnested-externs -Winline -pedantic -Wno-long-long # let's hardcode SDL flags here SDL_CFLAGS = `sdl-config --cflags` # sdl-config --libs is added to LIBS in configure # -g -O2 are in CFLAGS by default, don't use @CFLAGS@ here AM_CFLAGS = $(SDL_CFLAGS) $(CC_WARNINGS) AM_CPPFLAGS = -DDATADIR=\"$(datadir)\" \ -DLOCALSTATEDIR=\"$(localstatedir)\" \ -I$(top_srcdir) \ -I$(top_srcdir)/libtenm \ -I$(top_srcdir)/record all: all-recursive .SUFFIXES: .SUFFIXES: .c .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign spqr/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign spqr/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) libspqr.a: $(libspqr_a_OBJECTS) $(libspqr_a_DEPENDENCIES) -rm -f libspqr.a $(libspqr_a_AR) libspqr.a $(libspqr_a_OBJECTS) $(libspqr_a_LIBADD) $(RANLIB) libspqr.a mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/afterdeath.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/brilliance.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cat-tail-grep.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cat-tail.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/empty-wind.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/explosion.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flatdice.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fragment.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gosanpachi.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hatsuda.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hugin.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/insane-hand.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/laser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/last-boss.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mankanshoku.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/negation-engine.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net-can-howl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nexus.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/normal-enemy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/normal-shot.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/p-can.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/perpeki.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plan-0.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plan-1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plan-10.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plan-11.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plan-12.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plan-13.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plan-14.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plan-15.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plan-16.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plan-17.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plan-18.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plan-19.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plan-2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plan-20.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plan-3.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plan-4.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plan-5.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plan-6.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plan-7.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plan-8.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plan-9.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/player-shot.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/player.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/respiration.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/result.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scheduler.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/seiron-fake.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/seiron.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/show-record.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/silver-chimera.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spellbook.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stage-clear.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stage-list.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stage-select.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stage-title.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strikers.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tadashi.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tenmado.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/theorem-weapon.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/title.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tutor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/w-ko.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wall-0.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wall-11.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wall-13.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wall-4.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wall-8.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/warning.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/watcher-below.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile $(LIBRARIES) installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am distclean: distclean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am check check-am clean clean-generic \ clean-noinstLIBRARIES ctags ctags-recursive distclean \ distclean-compile distclean-generic distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs installdirs-am \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags tags-recursive uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: dangen-0.5/spqr/afterdeath.c0000644000175000017500000005275211625232526016675 0ustar00ooharaoohara00000000000000/* $Id: afterdeath.c,v 1.69 2011/08/24 17:31:02 oohara Exp $ */ /* [very easy] Afterdeath */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "stage-clear.h" #include "score.h" #include "afterdeath.h" #define NEAR_ZERO 0.0001 static int afterdeath_move(tenm_object *my, double turn_per_frame); static int afterdeath_hit(tenm_object *my, tenm_object *your); static void afterdeath_next(tenm_object *my); static int afterdeath_act(tenm_object *my, const tenm_object *player); static int afterdeath_draw(tenm_object *my, int priority); static int afterdeath_green(const tenm_object *my); static tenm_object *afterdeath_ship_new(double x, double y, int what); static int afterdeath_ship_move(tenm_object *my, double turn_per_frame); static int afterdeath_ship_act(tenm_object *my, const tenm_object *player); static int afterdeath_ship_draw(tenm_object *my, int priority); tenm_object * afterdeath_new(void) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = (double) (WINDOW_WIDTH / 2); double y = -47.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "afterdeath_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 36.0, y - 48.0, x + 36.0, y + 48.0, x - 36.0, y + 48.0, x - 36.0, y - 48.0); if (p[0] == NULL) { fprintf(stderr, "afterdeath_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 6); if (count == NULL) { fprintf(stderr, "afterdeath_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 3); if (count_d == NULL) { fprintf(stderr, "afterdeath_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] life mode * [3] life timer * [4] ship what * [5] "was green when killed" flag */ /* list of count_d * [0] speed x * [1] speed y * [2] ship y */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 0; count[4] = 0; count[5] = 0; count_d[0] = 0.0; count_d[1] = (((double) (WINDOW_HEIGHT / 4)) - y) / 90.0; count_d[2] = 0.0; new = tenm_object_new("Afterdeath", ATTR_BOSS, ATTR_PLAYER_SHOT, 509, x, y, 6, count, 3, count_d, 1, p, (int (*)(tenm_object *, double)) (&afterdeath_move), (int (*)(tenm_object *, tenm_object *)) (&afterdeath_hit), (int (*)(tenm_object *, const tenm_object *)) (&afterdeath_act), (int (*)(tenm_object *, int)) (&afterdeath_draw)); if (new == NULL) { fprintf(stderr, "afterdeath_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int afterdeath_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "afterdeath_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "afterdeath_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int afterdeath_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "afterdeath_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "afterdeath_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if (my->count[2] != 1) return 0; deal_damage(my, your, 0); if (afterdeath_green(my)) add_chain(my, your); my->count[1] = 2; if (my->hit_point <= 0) { add_score(5000); set_background(1); afterdeath_next(my); return 0; } return 0; } static void afterdeath_next(tenm_object *my) { int n; /* sanity check */ if (my == NULL) { fprintf(stderr, "afterdeath_next: my is NULL\n"); return; } if (my->count[2] != 1) return; tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy), 0); /* set "was green" flag before we change the life mode */ if (afterdeath_green(my)) { n = 8; my->count[5] = 1; } else { n = 7; my->count[5] = 0; } tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 5000, n, 10.0, 6)); tenm_table_add(fragment_new(my->x, my->y - 48.0, 0.0, 0.0, 20.0, 10, n, 3.0, 15.0, 24)); tenm_table_add(fragment_new(my->x + 36.0, my->y, 0.0, 0.0, 30.0, 5, n, 3.0, 15.0, 24)); tenm_table_add(fragment_new(my->x - 36.0, my->y + 25.0, 0.0, 0.0, 30.0, 5, n, 3.0, 15.0, 24)); my->count[2] = 2; my->count[3] = 0; my->count[1] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.5; /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ tenm_mass_delete(my->mass); my->mass = NULL; } static int afterdeath_act(tenm_object *my, const tenm_object *player) { int i; int theta; double x; double y; /* sanity check */ if (my == NULL) { fprintf(stderr, "afterdeath_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; (my->count[3])++; /* encounter */ if (my->count[2] == 0) { if (my->count[3] >= 90) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; my->count[2] = 1; my->count[3] = -1; return 0; } return 0; } /* dead */ if (my->count[2] == 2) { if (afterdeath_green(my)) i = 8; else i = 7; if ((my->count[3] >= 30) && (my->count[3] <= 75) && (my->count[3] % 15 == 0)) { theta = rand() % 360; tenm_table_add(explosion_new(my->x + 30.0 * tenm_cos(theta), my->y + 30.0 * tenm_sin(theta), 0.0, 0.0, 2, 300, i, 5.0, 8)); } if (my->count[3] > 120) { tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 3000, i, 10.0, 8)); tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 30.0, 100, i, 4.0, 0.0, 16)); tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 50.0, 30, i, 2.5, 0.0, 12)); tenm_table_add(stage_clear_new(100)); return 1; } return 0; } /* self-destruction */ if ((my->count[2] == 1) && (my->count[3] >= 1930)) { set_background(2); clear_chain(); afterdeath_next(my); return 0; } /* speed change */ if ((my->count[3] > 0) && (my->count[3] < 1800)) { if (my->count[3] % 200 == 0) { x = (double) (40 + (rand() % (WINDOW_WIDTH - 80 + 1))); y = (double) (50 + (rand() % (WINDOW_HEIGHT / 3 - 50 + 1))); my->count_d[0] = (x - my->x) / 60.0; my->count_d[1] = (y - my->y) / 60.0; } if (my->count[3] % 200 == 60) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } } if (my->count[2] != 1) return 0; if (my->count[3] >= 1800) return 0; /* summon ship */ if (my->count[3] % 200 == 50) { my->count[4] = rand() % 4; my->count_d[2] = (double) (50 + (rand() % (WINDOW_HEIGHT / 3 - 50 + 1))); if ((my->count_d[2] - 5.0 < my->y) && (my->count_d[2] + 5.0 > my->y)) { if (my->count_d[2] > my->y) my->count_d[2] = my->y + 5.0; else my->count_d[2] = my->y - 5.0; } } if (my->count[3] % 200 == 80) { x = -35.0; if (my->count[4] % 2 != 0) x = ((double) (WINDOW_WIDTH)) - x; tenm_table_add(afterdeath_ship_new(x, my->count_d[2], my->count[4])); } /* shoot */ if ((my->count[3] % 3 == 0) && (my->count[3] % 200 <= 60)) { theta = -122 + (my->count[3] % 200) * 3; tenm_table_add(laser_angle_new(my->x - 30.0, my->y, 5.0, theta, 25.0, 2)); tenm_table_add(laser_angle_new(my->x + 30.0, my->y, 5.0, 180 - theta, 25.0, 2)); } switch (my->count[3] % 200) { case 110: for (i = 0; i < 3; i++) { tenm_table_add(laser_angle_new(my->x, my->y, 3.5, 10 + 16 * i, 25.0, 3)); tenm_table_add(laser_angle_new(my->x, my->y, 3.5, 170 - 16 * i, 25.0, 3)); } break; case 140: for (i = 0; i < 3; i++) { tenm_table_add(laser_angle_new(my->x, my->y, 3.5, 42 + 16 * i, 25.0, 3)); tenm_table_add(laser_angle_new(my->x, my->y, 3.5, 138 - 16 * i, 25.0, 3)); } break; case 170: for (i = 0; i < 6; i++) tenm_table_add(laser_angle_new(my->x, my->y, 3.5, 50 + 16 * i, 25.0, 3)); break; default: break; } return 0; } static int afterdeath_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; double x; int c; /* sanity check */ if (my == NULL) { fprintf(stderr, "afterdeath_draw: my is NULL\n"); return 0; } /* decoration */ /* ship */ if ((priority == 0) && (my->count[2] == 1) && (my->count[3] < 1800) && (my->count[3] % 200 >= 50) && (my->count[3] % 200 < 112)) { if (my->count[3] % 200 <= 80) { color = tenm_map_color(158, 158, 158); } else { c = my->count[3] % 200 - 80; if (c < 0) c = 0; if (c > 32) c = 32; color = tenm_map_color((158 * (32-c) + DEFAULT_BACKGROUND_RED*c) / 32, (158 * (32-c) + DEFAULT_BACKGROUND_GREEN*c) / 32, (158 * (32-c) + DEFAULT_BACKGROUND_BLUE*c) / 32); } x = -35.0; if (my->count[3] % 200 > 80) x += 6.0 * ((double) ((my->count[3] % 200) - 80)); if (my->count[4] % 2 != 0) x = ((double) (WINDOW_WIDTH)) - x; if (tenm_draw_line((int) (my->x), (int) (my->y - 48.0 - 25.0), (int) (x), (int) (my->count_d[2]), 1, color) != 0) status = 1; } /* body */ /* dead enemy has low priority */ if (((my->count[2] <= 1) && (priority == 0)) || ((my->count[2] > 1) && (priority == -1))) { if (afterdeath_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 1) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (my->count[2] <= 1) { /* antenna */ if (tenm_draw_line((int) (my->x), (int) (my->y - 48.0), (int) (my->x + 25.0 * tenm_cos(-60)), (int) (my->y - 48.0 + 25.0 * tenm_sin(-60)), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x), (int) (my->y - 48.0), (int) (my->x + 25.0 * tenm_cos(-120)), (int) (my->y - 48.0 + 25.0 * tenm_sin(-120)), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x), (int) (my->y - 48.0), (int) (my->x), (int) (my->y - 48.0 - 25.0), 1, color) != 0) status = 1; /* hand */ c = 110; if ((my->count[2] == 1) && (my->count[3] < 1800) && (my->count[4] % 2 == 0)) { if ((my->count[3] % 200 >= 70) && (my->count[3] % 200 < 75)) c = 110 + (my->count[3] % 200 - 70) * 18; else if ((my->count[3] % 200 >= 75) && (my->count[3] % 200 < 80)) c = 200; else if ((my->count[3] % 200 >= 80) && (my->count[3] % 200 < 85)) c = 200 + (my->count[3] % 200 - 80) * 28; else if ((my->count[3] % 200 >= 85) && (my->count[3] % 200 < 120)) c = 340; else if ((my->count[3] % 200 >= 120) && (my->count[3] % 200 < 143)) c = 340 - (my->count[3] % 200 - 120) * 10; else c = 110; } if (tenm_draw_line((int) (my->x - 36.0), (int) (my->y), (int) (my->x - 36.0 + 50.0 * tenm_cos(c)), (int) (my->y + 50.0 * tenm_sin(c)), 1, color) != 0) status = 1; c = 70; if ((my->count[2] == 1) && (my->count[3] < 1800) && (my->count[4] % 2 != 0)) { if ((my->count[3] % 200 >= 70) && (my->count[3] % 200 < 75)) c = 70 - (my->count[3] % 200 - 70) * 18; else if ((my->count[3] % 200 >= 75) && (my->count[3] % 200 < 80)) c = -20; else if ((my->count[3] % 200 >= 80) && (my->count[3] % 200 < 85)) c = -20 - (my->count[3] % 200 - 80) * 28; else if ((my->count[3] % 200 >= 85) && (my->count[3] % 200 < 120)) c = -160; else if ((my->count[3] % 200 >= 120) && (my->count[3] % 200 < 143)) c = -160 + (my->count[3] % 200 - 120) * 10; else c = 70; } if (tenm_draw_line((int) (my->x + 36.0), (int) (my->y), (int) (my->x + 36.0 + 50.0 * tenm_cos(c)), (int) (my->y + 50.0 * tenm_sin(c)), 1, color) != 0) status = 1; } /* core */ if (tenm_draw_line((int) (my->x + 36.0), (int) (my->y - 48.0), (int) (my->x + 36.0), (int) (my->y + 48.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 36.0), (int) (my->y + 48.0), (int) (my->x - 36.0), (int) (my->y + 48.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 36.0), (int) (my->y + 48.0), (int) (my->x - 36.0), (int) (my->y - 48.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 36.0), (int) (my->y - 48.0), (int) (my->x + 36.0), (int) (my->y - 48.0), 3, color) != 0) status = 1; } /* hit point stat */ if ((priority == 0) && (my->count[2] == 1)) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 10, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "afterdeath_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int afterdeath_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if ((my->count[2] == 1) && (my->count[3] >= 200) && (my->count[3] < 1900)) return 1; if ((my->count[2] == 2) && (my->count[5] != 0)) return 1; return 0; } static tenm_object * afterdeath_ship_new(double x, double y, int what) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; /* sanity check */ if ((what < 0) || (what > 3)) { fprintf(stderr, "afterdeath_ship_new: strange what (%d)\n", what); return NULL; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "afterdeath_ship_new: malloc(p) failed\n"); return NULL; } if (what % 2 == 0) p[0] = (tenm_primitive *) tenm_polygon_new(3, x + 36.0, y, x - 18.0, y + 31.1769, x - 18.0, y - 31.1769); else p[0] = (tenm_primitive *) tenm_polygon_new(3, x - 36.0, y, x + 18.0, y - 31.1769, x + 18.0, y + 31.1769); if (p[0] == NULL) { fprintf(stderr, "afterdeath_ship_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 2); if (count == NULL) { fprintf(stderr, "afterdeath_ship_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "afterdeath_ship_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] what * [1] shoot timer */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = what; count[1] = 0; if (what % 2 == 0) count_d[0] = 6.0; else count_d[0] = -6.0; count_d[1] = 0.0; new = tenm_object_new("Afterdeath ship", ATTR_ENEMY, 0, 1, x, y, 2, count, 2, count_d, 1, p, (int (*)(tenm_object *, double)) (&afterdeath_ship_move), (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&afterdeath_ship_act), (int (*)(tenm_object *, int)) (&afterdeath_ship_draw)); if (new == NULL) { fprintf(stderr, "afterdeath_ship_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int afterdeath_ship_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "afterdeath_ship_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "afterdeath_ship_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); if (!in_window_object(my)) return 1; return 0; } static int afterdeath_ship_act(tenm_object *my, const tenm_object *player) { int i; int theta; /* sanity check */ if (my == NULL) { fprintf(stderr, "afterdeath_ship_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[1])++; if (my->count[1] % 25 == 0) { if (my->count[0] < 2) { tenm_table_add(normal_shot_point_new(my->x, my->y + 15.5885, 4.0, player->x, player->y, 1)); tenm_table_add(normal_shot_point_new(my->x, my->y - 15.5885, 4.0, player->x, player->y, 1)); } else { for (i = 0 ; i < 6; i++) { if (my->count[0] % 2 == 0) theta = 105 + 30 * i; else theta = 75 - 30 * i; tenm_table_add(normal_shot_angle_new(my->x, my->y, 4.0, theta, 0)); } } } return 0; } static int afterdeath_ship_draw(tenm_object *my, int priority) { tenm_color color; int status = 0; /* sanity check */ if (my == NULL) { fprintf(stderr, "afterdeath_ship_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; color = tenm_map_color(95, 13, 68); if (my->count[0] % 2 == 0) { if (tenm_draw_line((int) (my->x + 36.0), (int) (my->y), (int) (my->x - 18.0), (int) (my->y + 31.1769), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 18.0), (int) (my->y + 31.1769), (int) (my->x - 18.0), (int) (my->y - 31.1769), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 18.0), (int) (my->y - 31.1769), (int) (my->x + 36.0), (int) (my->y), 3, color) != 0) status = 1; } else { if (tenm_draw_line((int) (my->x - 36.0), (int) (my->y), (int) (my->x + 18.0), (int) (my->y - 31.1769), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 18.0), (int) (my->y - 31.1769), (int) (my->x + 18.0), (int) (my->y + 31.1769), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 18.0), (int) (my->y + 31.1769), (int) (my->x - 36.0), (int) (my->y), 3, color) != 0) status = 1; } return status; } dangen-0.5/spqr/afterdeath.h0000644000175000017500000000035010276702737016674 0ustar00ooharaoohara00000000000000/* $Id: afterdeath.h,v 1.1 2004/07/19 13:23:46 oohara Exp $ */ #ifndef __DANGEN_AFTERDEATH_H__ #define __DANGEN_AFTERDEATH_H__ #include "tenm_object.h" tenm_object *afterdeath_new(void); #endif /* not __DANGEN_AFTERDEATH_H__ */ dangen-0.5/spqr/brilliance.c0000644000175000017500000002461710276702737016700 0ustar00ooharaoohara00000000000000/* $Id: brilliance.c,v 1.31 2005/04/18 23:25:17 oohara Exp $ */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "normal-enemy.h" #include "score.h" #include "brilliance.h" static int brilliance_move(tenm_object *my, double turn_per_frame); static int brilliance_hit(tenm_object *my, tenm_object *your); static int brilliance_signal(tenm_object *my, int n); static int brilliance_act(tenm_object *my, const tenm_object *player); static int brilliance_draw(tenm_object *my, int priority); static int brilliance_green(const tenm_object *my); tenm_object * brilliance_new(double x, double y, int time_stay, int table_index) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; /* sanity check */ if (time_stay <= 0) { fprintf(stderr, "brilliance_new: time_stay is non-positive (%d)\n", time_stay); return NULL; } if (table_index < 0) { fprintf(stderr, "brilliance_new: strange table_index (%d)\n", table_index); return NULL; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "brilliance_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(5, x + 38.0, y - 30.0, x + 62.0, y - 20.0, x, y + 42.0, x - 62.0, y - 20.0, x - 38.0, y - 30.0); if (p[0] == NULL) { fprintf(stderr, "brilliance_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 6); if (count == NULL) { fprintf(stderr, "brilliance_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 3); if (count_d == NULL) { fprintf(stderr, "brilliance_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] life mode * [3] life timer * [4] time_stay * [5] table_index */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 0; count[4] = time_stay; count[5] = table_index; count_d[0] = -1.0 + 1.0; count_d[1] = 5.0 + 0.2; new = tenm_object_new("Brilliance", ATTR_ENEMY, ATTR_PLAYER_SHOT, 270, x, y, 6, count, 3, count_d, 1, p, (int (*)(tenm_object *, double)) (&brilliance_move), (int (*)(tenm_object *, tenm_object *)) (&brilliance_hit), (int (*)(tenm_object *, const tenm_object *)) (&brilliance_act), (int (*)(tenm_object *, int)) (&brilliance_draw)); if (new == NULL) { fprintf(stderr, "brilliance_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int brilliance_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "brilliance_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "brilliance_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); if ((my->count[2] == 2) && (!in_window_object(my))) return 1; return 0; } static int brilliance_hit(tenm_object *my, tenm_object *your) { int n; /* sanity check */ if (my == NULL) { fprintf(stderr, "brilliance_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "brilliance_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; deal_damage(my, your, 0); if (brilliance_green(my)) add_chain(my, your); my->count[1] = 41; if (my->hit_point <= 0) { add_score(75); if (brilliance_green(my)) n = 8; else n = 7; tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 1, 1000, n, 8.0, 6)); tenm_table_add(fragment_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 30.0, 30, n, 5.0, 0.0, 20)); if (my->count[2] <= 1) tenm_table_apply(my->count[5], (int (*)(tenm_object *, int)) (&brilliance_signal), 0); return 1; } return 0; } static int brilliance_signal(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "plan 15 more 1") != 0) return 0; (my->count[2])++; return 0; } static int brilliance_act(tenm_object *my, const tenm_object *player) { int i; double result[2]; double v[2]; /* sanity check */ if (my == NULL) { fprintf(stderr, "brilliance_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; (my->count[3])++; /* shoot */ if ((my->count[2] == 1) && (my->count[3] % 37 == 0)) { if (my->count[3] % 74 == 0) { v[0] = 0.0; v[1] = 26.0; } else { v[0] = -24.0; v[1] = 10.0; } for (i = 1; i <= 3; i++) { result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, -12 - 7 * i); tenm_table_add(laser_point_new(my->x + v[1], my->y - v[0], 2.5 + 1.0 * ((double) i), my->x + v[1] + result[0], my->y - v[0] + result[1], 25.0, 1)); if (i != 2) { result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, -12 + 7 * i); tenm_table_add(laser_point_new(my->x + v[1], my->y - v[0], 2.5 + 1.0 * ((double) i), my->x + v[1] + result[0], my->y - v[0] + result[1], 25.0, 1)); result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, 12 - 7 * i); tenm_table_add(laser_point_new(my->x - v[1], my->y + v[0], 2.5 + 1.0 * ((double) i), my->x - v[1] + result[0], my->y + v[0] + result[1], 25.0, 1)); } result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, 12 + 7 * i); tenm_table_add(laser_point_new(my->x - v[1], my->y + v[0], 2.5 + 1.0 * ((double) i), my->x - v[1] + result[0], my->y + v[0] + result[1], 25.0, 1)); } } /* speed change */ if ((my->count[2] == 0) && (my->count[3] >= 48)) { my->count[2] = 1; my->count[3] = 0; my->count_d[0] = 0.0 + 1.0; my->count_d[1] = 0.0 + 0.2; } else if ((my->count[2] == 1) && (my->count[3] >= my->count[4])) { my->count[2] = 2; my->count[3] = 0; my->count_d[0] = 1.0 + 1.0; my->count_d[1] = -5.0 + 0.2; } return 0; } static int brilliance_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; /* sanity check */ if (my == NULL) { fprintf(stderr, "brilliance_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; /* body */ if (brilliance_green(my)) { if (my->count[1] >= 40) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 40) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (tenm_draw_line((int) (my->x - 62.0), (int) (my->y - 20.0), (int) (my->x + 62.0), (int) (my->y - 20.0), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 38.0), (int) (my->y - 30.0), (int) (my->x + 62.0), (int) (my->y - 20.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 62.0), (int) (my->y - 20.0), (int) (my->x), (int) (my->y + 42.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x), (int) (my->y + 42.0), (int) (my->x - 62.0), (int) (my->y - 20.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 62.0), (int) (my->y - 20.0), (int) (my->x - 38.0), (int) (my->y - 30.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 38.0), (int) (my->y - 30.0), (int) (my->x + 38.0), (int) (my->y - 30.0), 2, color) != 0) status = 1; /* hit point stat */ if ((priority == 0) && (my->count[1] >= 1)) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 10, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "brilliance_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int brilliance_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if (my->count[2] <= 1) return 1; return 0; } dangen-0.5/spqr/brilliance.h0000644000175000017500000000046210276702737016675 0ustar00ooharaoohara00000000000000/* $Id: brilliance.h,v 1.4 2005/04/18 23:20:29 oohara Exp $ */ #ifndef __DANGEN_BRILLIANCE_H__ #define __DANGEN_BRILLIANCE_H__ #include "tenm_object.h" tenm_object *brilliance_new(double x, double y, int time_stay, int table_index); #endif /* not __DANGEN_BRILLIANCE_H__ */ dangen-0.5/spqr/cat-tail-grep.c0000644000175000017500000023034111625232553017207 0ustar00ooharaoohara00000000000000/* $Id: cat-tail-grep.c,v 1.403 2011/08/24 17:31:23 oohara Exp $ */ /* [hard] cat tail (grep mix) */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "stage-clear.h" #include "score.h" #include "ship.h" /* tenm_same_side, tenm_line_nearer */ #include "tenm_collision.h" #include "cat-tail-grep.h" #define NEAR_ZERO 0.0001 static int cat_tail_grep_move(tenm_object *my, double turn_per_frame); static int cat_tail_grep_hit(tenm_object *my, tenm_object *your); static void cat_tail_grep_second_form(tenm_object *my); static void cat_tail_grep_explode(tenm_object *my); static int cat_tail_grep_signal_turret(tenm_object *my, int n); static int cat_tail_grep_act(tenm_object *my, const tenm_object *player); static int cat_tail_grep_draw(tenm_object *my, int priority); static int cat_tail_grep_green(const tenm_object *my); static tenm_object *cat_tail_grep_turret_new(int what, int index_body, int index_turret); static int cat_tail_grep_turret_move(tenm_object *my, double turn_per_frame); static int cat_tail_grep_turret_hit(tenm_object *my, tenm_object *your); static int cat_tail_grep_turret_signal_turret(tenm_object *my, int n); static int cat_tail_grep_turret_signal_body(tenm_object *my, int n); static void cat_tail_grep_turret_explode(tenm_object *my); static int cat_tail_grep_turret_act(tenm_object *my, const tenm_object *player); static int cat_tail_grep_turret_draw(tenm_object *my, int priority); static int cat_tail_grep_turret_green(const tenm_object *my); static int cat_tail_grep_position(double *result, int mode, int t); static tenm_object *cat_tail_grep_shot_s_new(double x, double y, double speed_x, double speed_y, double target_x, double target_y); static int cat_tail_grep_shot_s_move(tenm_object *my, double turn_per_frame); static int cat_tail_grep_shot_s_hit(tenm_object *my, tenm_object *your); static int cat_tail_grep_shot_s_act(tenm_object *my, const tenm_object *player); static int cat_tail_grep_shot_s_draw(tenm_object *my, int priority); static tenm_object *cat_tail_grep_shot_i_new(double x, double y, double speed, double rotate_direction, double target_x, double target_y, double center_x, double center_y, int t_fixed); static int cat_tail_grep_shot_i_move(tenm_object *my, double turn_per_frame); static int cat_tail_grep_shot_i_hit(tenm_object *my, tenm_object *your); static int cat_tail_grep_shot_i_act(tenm_object *my, const tenm_object *player); static int cat_tail_grep_shot_i_draw(tenm_object *my, int priority); static tenm_object *cat_tail_grep_shot_v_new(double x, double y, double speed_x, double speed_y, int theta_turn, double target_x, double target_y); static int cat_tail_grep_shot_v_move(tenm_object *my, double turn_per_frame); static int cat_tail_grep_shot_v_hit(tenm_object *my, tenm_object *your); static int cat_tail_grep_shot_v_act(tenm_object *my, const tenm_object *player); static int cat_tail_grep_shot_v_draw(tenm_object *my, int priority); tenm_object * cat_tail_grep_new(void) { int i; tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double result[2]; double x; double y; result[0] = 0.0; result[1] = 0.0; cat_tail_grep_position(result, 0, 0); x = result[0]; y = result[1]; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 3); if (p == NULL) { fprintf(stderr, "cat_tail_grep_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(6, x + 48.0, y, x + 24.0, y + 41.5692, x - 24.0, y + 41.5692, x - 48.0, y, x - 24.0, y - 41.5692, x + 24.0, y - 41.5692); if (p[0] == NULL) { fprintf(stderr, "cat_tail_grep_new: cannot set p[0]\n"); free(p); return NULL; } p[1] = (tenm_primitive *) tenm_polygon_new(3, x - 24.0, y - 41.5692, x - 44.7846, y - 53.5692, x - 36.0, y - 20.7846); if (p[1] == NULL) { fprintf(stderr, "cat_tail_grep_new: cannot set p[1]\n"); (p[0])->delete(p[0]); free(p); return NULL; } p[2] = (tenm_primitive *) tenm_polygon_new(3, x + 24.0, y - 41.5692, x + 44.7846, y - 53.5692, x + 36.0, y - 20.7846); if (p[2] == NULL) { fprintf(stderr, "cat_tail_grep_new: cannot set p[2]\n"); for (i = 0; i < 2; i++) (p[i])->delete(p[i]); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 10); if (count == NULL) { fprintf(stderr, "cat_tail_grep_new: malloc(count) failed\n"); for (i = 0; i < 3; i++) (p[i])->delete(p[i]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "cat_tail_grep_new: malloc(count_d) failed\n"); free(count); for (i = 0; i < 3; i++) (p[i])->delete(p[i]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] move mode * [3] move timer * [4 -- 6] turret index * [7] hand direction * [8] hand theta * [9] "was green when killed" flag */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 0; count[4] = -1; count[5] = -1; count[6] = -1; count[7] = -30; count[8] = 0; count[9] = 0; count_d[0] = 0.0; count_d[1] = 0.0; new = tenm_object_new("cat tail (grep mix)", ATTR_BOSS, ATTR_PLAYER_SHOT, 750, x, y, 10, count, 2, count_d, 3, p, (int (*)(tenm_object *, double)) (&cat_tail_grep_move), (int (*)(tenm_object *, tenm_object *)) (&cat_tail_grep_hit), (int (*)(tenm_object *, const tenm_object *)) (&cat_tail_grep_act), (int (*)(tenm_object *, int)) (&cat_tail_grep_draw)); if (new == NULL) { fprintf(stderr, "cat_tail_grep_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); for (i = 0; i < 3; i++) (p[i])->delete(p[i]); free(p); return NULL; } return new; } static int cat_tail_grep_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_grep_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "cat_tail_grep_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } if ((my->count[2] == 2) && (my->count[3] < 0)) return 0; dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int cat_tail_grep_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_grep_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "cat_tail_grep_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if ((my->count[2] != 1) && (my->count[2] != 3)) return 0; deal_damage(my, your, 0); if (cat_tail_grep_green(my)) add_chain(my, your); my->count[1] = 2; if (my->hit_point <= 0) { set_background(1); if (my->count[2] == 1) { add_score(7500); cat_tail_grep_second_form(my); return 0; } else { add_score(22500); cat_tail_grep_explode(my); return 0; } } return 0; } static void cat_tail_grep_second_form(tenm_object *my) { int i; int n; /* sanity check */ if (my == NULL) return; tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); for (i = 0; i < 3; i++) if (my->count[4 + i] >= 0) tenm_table_apply(my->count[4 + i], (int (*)(tenm_object *, int)) (&cat_tail_grep_signal_turret), 0); /* set "was green" flag before we change the life mode */ if (cat_tail_grep_green(my)) { n = 8; my->count[9] = 1; } else { n = 7; my->count[9] = 0; } tenm_table_add(explosion_new(my->x, my->y - 31.1769, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 1, 1000, n, 3.0, 9)); tenm_table_add(fragment_new(my->x, my->y - 31.1769, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 50.0, 20, n, 5.0, 0.0, 20)); my->hit_point = 750; my->count[2] = 2; my->count[3] = -30; my->count[1] = 0; my->count_d[0] = (((double) (WINDOW_WIDTH / 2)) - my->x) / 240.0; my->count_d[1] = (((double) (WINDOW_HEIGHT / 2)) - my->y) / 240.0; } static void cat_tail_grep_explode(tenm_object *my) { int n; double x; double y; double dx; double dy; int i; /* sanity check */ if (my == NULL) return; tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); /* set "was green" flag before we change the life mode */ if (cat_tail_grep_green(my)) { n = 8; my->count[9] = 1; } else { n = 7; my->count[9] = 0; } x = my->x; y = my->y; for (i = 1; i <= 4; i++) { dx = 120.0 * tenm_cos(my->count[7] + my->count[8] * i); dy = 120.0 * tenm_sin(my->count[7] + my->count[8] * i); tenm_table_add(fragment_new(x, y, 0.0, 0.0, 50.0, 10, n, 4.0, 15.0, 12)); tenm_table_add(explosion_new(x + dx / 2.0, y + dy / 2.0, 0.0, 0.0, 1, 1000, n, 10.0, 9)); x += dx; y += dy; } tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 5000, n, 10.0, 6)); my->count[2] = 4; my->count[3] = 0; my->count[1] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.5; /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ tenm_mass_delete(my->mass); my->mass = NULL; } static int cat_tail_grep_signal_turret(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "cat tail (grep mix) turret") != 0) return 0; my->count[2] = 3; /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ if (my->mass != NULL) { tenm_mass_delete(my->mass); my->mass = NULL; } return 0; } static int cat_tail_grep_act(tenm_object *my, const tenm_object *player) { int i; double result[2]; double x; double y; double dx; double dy; double length; int theta; /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_grep_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; /* speed change */ (my->count[3])++; result[0] = 0.0; result[1] = 0.0; if (my->count[2] <= 1) { cat_tail_grep_position(result, my->count[2], my->count[3]); my->count_d[0] = result[0] - my->x; my->count_d[1] = result[1] - my->y; } else if (my->count[2] == 2) { if (my->count[3] >= 240) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } } else if (my->count[2] == 3) { dx = player->x - my->x; dy = player->y - my->y; length = tenm_sqrt((int) (dx * dx + dy * dy)); if (length < NEAR_ZERO) length = 1.0; my->count_d[0] = 1.5 * dx / length; my->count_d[1] = 1.5 * dy / length; if (length < 10.0) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if ((length > 300.0) || (length < 100.0)) { my->count_d[0] *= 2.0; my->count_d[1] *= 2.0; } if (my->count[3] < 260) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } /* don't move if the player is immutable */ if ((get_ship() < 0) || (player->count[1] > 0)) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } } else if (my->count[2] == 4) { my->count_d[0] = 0.0; my->count_d[1] = 0.5; } else { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } /* encounter */ if (my->count[2] == 0) { if (my->count[3] == 1) { my->count[4] = tenm_table_add(cat_tail_grep_turret_new(0, my->table_index, -1)); for (i = 1; i < 3; i++) my->count[4+i]=tenm_table_add(cat_tail_grep_turret_new(i, my->table_index, my->count[4])); } if (my->count[3] >= 120) { my->count[2] = 1; my->count[3] = 0; } return 0; } /* self-destruction */ if ((my->count[2] == 1) && (my->count[3] >= 3190)) { set_background(2); clear_chain(); cat_tail_grep_second_form(my); return 0; } if ((my->count[2] == 3) && (my->count[3] >= 2290)) { set_background(2); clear_chain(); cat_tail_grep_explode(my); return 0; } /* second form */ if (my->count[2] == 2) { if (my->count[3] >= 250) { my->count[2] = 3; my->count[3] = 0; } return 0; } /* dead */ if (my->count[2] == 4) { if (cat_tail_grep_green(my)) i = 8; else i = 7; if ((my->count[3] >= 30) && (my->count[3] <= 75) && (my->count[3] % 15 == 0)) { theta = rand() % 360; tenm_table_add(explosion_new(my->x + 30.0 * tenm_cos(theta), my->y + 30.0 * tenm_sin(theta), 0.0, 0.0, 2, 300, i, 5.0, 8)); } if (my->count[3] > 120) { tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 3000, i, 10.0, 8)); tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 30.0, 100, i, 4.0, 0.0, 16)); tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 50.0, 30, i, 2.5, 0.0, 12)); tenm_table_add(stage_clear_new(100)); return 1; } return 0; } /* move hand */ if (my->count[2] == 3) { if (my->count[3] < 120) { my->count[7] += 2; my->count[8] -= 2; } else if (my->count[3] < 150) { ; } else if (my->count[3] < 230) { my->count[7] -= 3; my->count[8] += 3; } else if (my->count[3] < 260) { ; } else { if ((my->count[3] - 260) % 195 < 95) { my->count[7] += 7; my->count[8] -= 7; } else if (((my->count[3] - 260) % 195 >= 100) && ((my->count[3] - 260) % 195 < 190)) { my->count[7] -= 7; my->count[8] += 7; } } if (my->count[8] > 0) my->count[8] -= (my->count[8] + 5) / 6; else if (my->count[8] < 0) my->count[8] -= (my->count[8] - 5) / 6; } /* shoot */ if (my->count[2] == 1) { if ((my->count[3] >= 600) && (my->count[3] < 1150)) { if (my->count[3] % 17 == 0) { tenm_table_add(laser_angle_new(my->x + 40.0 * tenm_sin(my->count[3]), my->y, 4.0, 90, 25.0, 3)); } if (my->count[3] % 7 == 0) { tenm_table_add(laser_angle_new(my->x + 40.0 * tenm_sin(my->count[3]), my->y, 5.0, 150 - (my->count[3]%50), 25.0, 3)); tenm_table_add(laser_angle_new(my->x + 40.0 * tenm_sin(my->count[3]), my->y, 5.0, 30 + (my->count[3]%50), 25.0, 3)); } if ((my->count[5] < 0) && (my->count[3] >= 616) && (my->count[3] <= 1141) && (my->count[3] % 7 == 0)) { if (my->count[3] % 56 < 28) tenm_table_add(cat_tail_grep_shot_i_new(my->x, my->y, 7.0, 1.0, player->x, player->y, my->x + 30.0, my->y + 90.0, 25)); else tenm_table_add(cat_tail_grep_shot_i_new(my->x, my->y, 7.0, -1.0, player->x, player->y, my->x - 30.0, my->y + 90.0, 25)); } } if ((my->count[3] >= 1350) && (my->count[3] <= 1841)) { if (my->count[3] % 7 == 0) { tenm_table_add(laser_point_new(my->x + 40.0 * tenm_sin(my->count[3]), my->y, 9.0, 160.0 + 120.0*tenm_sin(my->count[3]*2), 360.0, 25.0, 3)); tenm_table_add(laser_point_new(my->x + 40.0 * tenm_sin(my->count[3]), my->y, 9.0, 480.0 - 120.0*tenm_sin(my->count[3]*2), 360.0, 25.0, 3)); } if ((my->count[6] < 0) && (my->count[3] % 37 == 0)) { tenm_table_add(cat_tail_grep_shot_i_new(my->x, my->y, 7.0, 1.0, player->x, player->y, my->x + 15.0, my->y + 45.0, 12)); tenm_table_add(cat_tail_grep_shot_i_new(my->x, my->y, 7.0, -1.0, player->x, player->y, my->x - 15.0, my->y + 45.0, 12)); tenm_table_add(cat_tail_grep_shot_i_new(my->x, my->y, 8.0, 1.0, player->x, player->y, my->x + 30.0, my->y + 90.0, 21)); tenm_table_add(cat_tail_grep_shot_i_new(my->x, my->y, 8.0, -1.0, player->x, player->y, my->x - 30.0, my->y + 90.0, 21)); tenm_table_add(cat_tail_grep_shot_i_new(my->x, my->y, 9.0, 1.0, player->x, player->y, my->x + 45.0, my->y + 135.0, 28)); tenm_table_add(cat_tail_grep_shot_i_new(my->x, my->y, 9.0, -1.0, player->x, player->y, my->x - 45.0, my->y + 135.0, 28)); } } if ((my->count[3] >= 1900) && (my->count[3] < 2420)) { if (my->count[3] % 29 == 0) { tenm_table_add(laser_angle_new(my->x - 20.0, my->y + 20.0, 4.0, 55, 25.0, 3)); tenm_table_add(laser_angle_new(my->x + 20.0, my->y + 20.0, 4.0, 125, 25.0, 3)); tenm_table_add(laser_angle_new(my->x - 20.0, my->y - 20.0, 5.5, 60, 25.0, 3)); tenm_table_add(laser_angle_new(my->x + 20.0, my->y - 20.0, 5.5, 120, 25.0, 3)); tenm_table_add(laser_angle_new(my->x - 20.0, my->y + 20.0, 4.0, 25, 25.0, 3)); tenm_table_add(laser_angle_new(my->x + 20.0, my->y + 20.0, 4.0, 155, 25.0, 3)); tenm_table_add(laser_angle_new(my->x - 20.0, my->y - 20.0, 5.5, 35, 25.0, 3)); tenm_table_add(laser_angle_new(my->x + 20.0, my->y - 20.0, 5.5, 145, 25.0, 3)); } if ((my->count[5] < 0) && (my->count[3] % 7 == 0)) { tenm_table_add(cat_tail_grep_shot_i_new(my->x, my->y, 7.0, 1.0, player->x, player->y, my->x + 30.0, my->y + 90.0, 25)); tenm_table_add(cat_tail_grep_shot_i_new(my->x, my->y, 7.0, -1.0, player->x, player->y, my->x - 30.0, my->y + 90.0, 25)); } } if ((my->count[3] >= 2520) && (my->count[3] < 3060)) { if (my->count[3] % 17 == 0) { tenm_table_add(laser_angle_new(my->x + 40.0 * tenm_sin(my->count[3]), my->y, 4.0, 90, 25.0, 3)); } if (my->count[3] % 7 == 0) { if ((my->count[3] + 270) % 360 < 180) { tenm_table_add(laser_angle_new(my->x - 40.0 * tenm_sin(my->count[3]), my->y, 9.0, 75 + ((my->count[3] + 270) % 360) / 2, 25.0, 3)); tenm_table_add(laser_angle_new(my->x - 40.0 * tenm_sin(my->count[3]), my->y, 9.0, 15 + ((my->count[3] + 270) % 360) / 2, 25.0, 3)); } else { tenm_table_add(laser_angle_new(my->x - 40.0 * tenm_sin(my->count[3]), my->y, 9.0, 255 - ((my->count[3]+270) % 360) / 2, 25.0, 3)); tenm_table_add(laser_angle_new(my->x - 40.0 * tenm_sin(my->count[3]), my->y, 9.0, 195 - ((my->count[3]+270) % 360) / 2, 25.0, 3)); } } if ((my->count[6] < 0) && (my->count[3] % 5 == 0) && (my->count[3] % 20 != 0)) { if (my->count[3] % 60 < 20) { tenm_table_add(cat_tail_grep_shot_i_new(my->x, my->y, 7.0, 1.0, player->x, player->y, my->x + 15.0, my->y + 45.0, 12)); tenm_table_add(cat_tail_grep_shot_i_new(my->x, my->y, 7.0, -1.0, player->x, player->y, my->x - 15.0, my->y + 45.0, 12)); } else if (my->count[3] % 60 < 40) { tenm_table_add(cat_tail_grep_shot_i_new(my->x, my->y, 8.0, 1.0, player->x, player->y, my->x + 30.0, my->y + 90.0, 21)); tenm_table_add(cat_tail_grep_shot_i_new(my->x, my->y, 8.0, -1.0, player->x, player->y, my->x - 30.0, my->y + 90.0, 21)); } else { tenm_table_add(cat_tail_grep_shot_i_new(my->x, my->y, 9.0, 1.0, player->x, player->y, my->x + 45.0, my->y + 135.0, 28)); tenm_table_add(cat_tail_grep_shot_i_new(my->x, my->y, 9.0, -1.0, player->x, player->y, my->x - 45.0, my->y + 135.0, 28)); } } } } if ((my->count[2] == 3) && (my->count[3] % 11 == 0)) { x = my->x; y = my->y; for (i = 1; i <= 4; i++) { dx = 120.0 * tenm_cos(my->count[7] + my->count[8] * i); dy = 120.0 * tenm_sin(my->count[7] + my->count[8] * i); x += dx; y += dy; tenm_table_add(laser_point_new(x, y, 3.5, x - dy, y + dx, 25.0, 3)); tenm_table_add(laser_point_new(x, y, 3.5, x + dy, y - dx, 25.0, 3)); } } return 0; } static int cat_tail_grep_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; double x; double y; double dx; double dy; int i; int theta; double length; /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_grep_draw: my is NULL\n"); return 0; } /* body */ /* dead enemy has low priority */ if (((my->count[2] <= 3) && (priority == 0)) || ((my->count[2] > 3) && (priority == -1))) { if (cat_tail_grep_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 1) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (my->count[2] <= 1) { if (tenm_draw_line((int) (my->x + 36.0), (int) (my->y - 20.7846), (int) (my->x + 48.0), (int) (my->y), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - 36.0), (int) (my->y - 20.7846), (int) (my->x + 36.0), (int) (my->y - 20.7846), 2, color)) status = 1; if (tenm_draw_line((int) (my->x - 48.0), (int) (my->y), (int) (my->x - 36.0), (int) (my->y - 20.7846), 3, color)) status = 1; } else { if (tenm_draw_line((int) (my->x + 24.0), (int) (my->y - 41.5692), (int) (my->x + 48.0), (int) (my->y), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - 48.0), (int) (my->y), (int) (my->x - 24.0), (int) (my->y - 41.5692), 3, color)) status = 1; } if (tenm_draw_line((int) (my->x + 48.0), (int) (my->y), (int) (my->x + 24.0), (int) (my->y + 41.5692), 3, color)) status = 1; if (tenm_draw_line((int) (my->x + 24.0), (int) (my->y + 41.5692), (int) (my->x - 24.0), (int) (my->y + 41.5692), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - 24.0), (int) (my->y + 41.5692), (int) (my->x - 48.0), (int) (my->y), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - 24.0), (int) (my->y - 41.5692), (int) (my->x + 24.0), (int) (my->y - 41.5692), 2, color)) status = 1; if (tenm_draw_line((int) (my->x - 24.0), (int) (my->y - 41.5692), (int) (my->x - 44.7846), (int) (my->y - 53.5692), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - 44.7846), (int) (my->y - 53.5692), (int) (my->x - 36.0), (int) (my->y - 20.7846), 3, color)) status = 1; if (tenm_draw_line((int) (my->x + 24.0), (int) (my->y - 41.5692), (int) (my->x + 44.7846), (int) (my->y - 53.5692), 3, color)) status = 1; if (tenm_draw_line((int) (my->x + 44.7846), (int) (my->y - 53.5692), (int) (my->x + 36.0), (int) (my->y - 20.7846), 3, color)) status = 1; /* hand */ if ((my->count[2] == 2) && (my->count[3] > 0)) { x = my->x; y = my->y; if (my->count[3] < 0) length = 0.5; else if (my->count[3] < 240) length = ((double) (my->count[3])) * 0.5; else length = 120.0; for (i = 1; i <= 4; i++) { if (my->count[3] < 120) theta = 360; else if (my->count[3] < 240) theta = (120 - my->count[3]) * 3; else theta = 0; dx = length * tenm_cos(my->count[7] + theta * i); dy = length * tenm_sin(my->count[7] + theta * i); if (tenm_draw_line((int) (x), (int) (y), (int) (x + dx), (int) (y + dy), 1, color)) status = 1; if (tenm_draw_circle((int) (x + dx), (int) (y + dy), 5, 1, tenm_map_color(0, 111, 223)) != 0) status = 1; x += dx; y += dy; } } else if (my->count[2] == 3) { x = my->x; y = my->y; for (i = 1; i <= 4; i++) { dx = 120.0 * tenm_cos(my->count[7] + my->count[8] * i); dy = 120.0 * tenm_sin(my->count[7] + my->count[8] * i); if (tenm_draw_line((int) (x), (int) (y), (int) (x + dx), (int) (y + dy), 1, color)) status = 1; if (tenm_draw_circle((int) (x + dx), (int) (y + dy), 5, 1, tenm_map_color(0, 111, 223)) != 0) status = 1; x += dx; y += dy; } } } /* hit point stat */ if ((priority == 0) && ((my->count[2] == 1) || (my->count[2] == 3))) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 5, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "cat_tail_grep_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int cat_tail_grep_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if ((my->count[2] == 1) && (my->count[3] >= 600) && (my->count[3] < 3160)) return 1; if ((my->count[2] == 2) && (my->count[3] < 0) && (my->count[9] != 0)) return 1; if ((my->count[2] == 3) && (my->count[3] >= 260) && (my->count[3] <= 2260)) return 1; if ((my->count[2] == 4) && (my->count[9] != 0)) return 1; return 0; } static tenm_object * cat_tail_grep_turret_new(int what, int index_body, int index_turret) { int i; tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double result[2]; double x; double y; result[0] = 0.0; result[1] = 0.0; cat_tail_grep_position(result, 0, 1); x = result[0]; y = result[1]; /* sanity check */ if ((what < 0) || (what > 2)) { fprintf(stderr, "cat_tail_grep_turret_new: strange what (%d)\n", what); return NULL; } switch (what) { case 0: x += 180.0; y += 75.0; break; case 1: x += 180.0; y += 75.0 + 42.0; break; case 2: x += 180.0; y += 75.0 - 42.0; break; default: fprintf(stderr, "cat_tail_grep_turret_new: undefined what (%d)\n", what); break; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "cat_tail_grep_turret_new: malloc(p) failed\n"); return NULL; } switch (what) { case 0: p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 18.0, y + 24.0, x - 18.0, y + 24.0, x - 18.0, y - 24.0, x + 18.0, y - 24.0); break; case 1: p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 24.0, y + 18.0, x - 24.0, y + 18.0, x - 24.0, y - 18.0, x + 24.0, y - 18.0); break; case 2: p[0] = (tenm_primitive *) tenm_polygon_new(4, x - 24.0, y - 18.0, x + 24.0, y - 18.0, x + 24.0, y + 18.0, x - 24.0, y + 18.0); break; default: fprintf(stderr, "cat_tail_grep_turret_new: undefined what (%d)\n", what); break; } if (p[0] == NULL) { fprintf(stderr, "cat_tail_grep_turret_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 9); if (count == NULL) { fprintf(stderr, "cat_tail_grep_turret_new: malloc(count) failed\n"); for (i = 0; i < 3; i++) (p[i])->delete(p[i]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 4); if (count_d == NULL) { fprintf(stderr, "cat_tail_grep_turret_new: malloc(count_d) failed\n"); free(count); for (i = 0; i < 3; i++) (p[i])->delete(p[i]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] move mode * [3] move timer * [4] what * [5] index body * [6] index turret center * [7] number of turret heads dead * [8] shoot timer */ /* list of count_d * [0] speed x * [1] speed y * [2] front x * [3] front y */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 1; count[4] = what; count[5] = index_body; count[6] = index_turret; count[7] = 0; count[8] = 0; count_d[0] = 0.0; count_d[1] = 0.0; switch (what) { case 0: count_d[2] = 0.0; count_d[3] = 24.0; break; case 1: count_d[2] = 0.0; count_d[3] = 18.0; break; case 2: count_d[2] = 0.0; count_d[3] = -18.0; break; default: fprintf(stderr, "cat_tail_grep_turret_new: undefined what (%d)\n", what); break; } new = tenm_object_new("cat tail (grep mix) turret", ATTR_BOSS, ATTR_PLAYER_SHOT, 750, x, y, 9, count, 4, count_d, 1, p, (int (*)(tenm_object *, double)) (&cat_tail_grep_turret_move), (int (*)(tenm_object *, tenm_object *)) (&cat_tail_grep_turret_hit), (int (*)(tenm_object *, const tenm_object *)) (&cat_tail_grep_turret_act), (int (*)(tenm_object *, int)) (&cat_tail_grep_turret_draw)); if (new == NULL) { fprintf(stderr, "cat_tail_grep_turret_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); for (i = 0; i < 3; i++) (p[i])->delete(p[i]); free(p); return NULL; } return new; } static int cat_tail_grep_turret_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_grep_turret_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "cat_tail_grep_turret_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int cat_tail_grep_turret_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_grep_turret_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "cat_tail_grep_turret_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if (my->count[2] != 1) return 0; if (my->count[4] == 0) return 0; deal_damage(my, your, 0); if (cat_tail_grep_turret_green(my)) add_chain(my, your); my->count[1] = 41; if (my->hit_point <= 0) { add_score(20000); cat_tail_grep_turret_explode(my); tenm_table_apply(my->count[6], (int (*)(tenm_object *, int)) (&cat_tail_grep_turret_signal_turret), 0); tenm_table_apply(my->count[5], (int (*)(tenm_object *, int)) (&cat_tail_grep_turret_signal_body), my->count[4]); return 1; } return 0; } static int cat_tail_grep_turret_signal_turret(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "cat tail (grep mix) turret") != 0) return 0; (my->count[7])++; if (my->count[7] >= 2) { my->count[2] = 2; /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ if (my->mass != NULL) { tenm_mass_delete(my->mass); my->mass = NULL; } } return 0; } static int cat_tail_grep_turret_signal_body(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "cat tail (grep mix)") != 0) return 0; my->count[4 + n] = -1; return 0; } static void cat_tail_grep_turret_explode(tenm_object *my) { int n; /* sanity check */ if (my == NULL) return; if (my->count[4] == 0) n = 9; else if (cat_tail_grep_turret_green(my)) n = 8; else n = 7; tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 1, 1000, n, 8.0, 6)); tenm_table_add(fragment_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 30.0, 30, n, 5.0, 0.0, 20)); } static int cat_tail_grep_turret_act(tenm_object *my, const tenm_object *player) { double result[2]; double temp[2]; double v[2]; double a[2]; double x; double y; double temp_x; double temp_y; double result_length; int n; double length; int dtheta; /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_grep_turret_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; /* self-destruction */ if (my->count[2] == 3) { cat_tail_grep_turret_explode(my); return 1; } /* aim at the player */ (my->count[3])++; temp[0] = 0.0; temp[1] = 0.0; cat_tail_grep_position(temp, my->count[2], my->count[3]); if ((my->count[2] == 0) || (my->count[2] == 2)) { result[0] = my->count_d[2]; result[1] = my->count_d[3]; } else { v[0] = my->count_d[2]; v[1] = my->count_d[3]; a[0] = player->x - (temp[0] + 180.0); a[1] = player->y - (temp[1] + 75.0); if ((my->count[3] < 250) || ((my->count[3] >= 530) && (my->count[3] < 1200)) || ((my->count[3] >= 1840) && (my->count[3] < 2440))) { if (my->count[4] == 2) { a[0] *= -1.0; a[1] *= -1.0; } } else { if (my->count[4] != 2) { a[0] *= -1.0; a[1] *= -1.0; } } if (((my->count[3] >= 250) && (my->count[3] < 310)) || ((my->count[3] >= 530) && (my->count[3] < 590)) || ((my->count[3] >= 1200) && (my->count[3] < 1260)) || ((my->count[3] >= 1840) && (my->count[3] < 1900)) || ((my->count[3] >= 2440) && (my->count[3] < 2500))) dtheta = 3; else dtheta = 1; result[0] = 0.0; result[1] = 0.0; vector_rotate_bounded(result, v, a, dtheta); } /* speed change */ result_length = result[0] * result[0] + result[1] * result[1]; result_length = tenm_sqrt((int) result_length); if ((my->count[4] == 0) || (result_length < NEAR_ZERO)) { my->count_d[0] = (temp[0] + 180.0) - my->x; my->count_d[1] = (temp[1] + 75.0) - my->y; } else { x = result[0] * 42.0 / result_length; y = result[1] * 42.0 / result_length; x += temp[0] + 180.0; y += temp[1] + 75.0; my->count_d[0] = x - my->x; my->count_d[1] = y - my->y; } /* encounter */ if (my->count[2] == 0) { if (my->count[3] >= 120) { my->count[2] = 1; my->count[3] = 0; } return 0; } /* dead */ if (my->count[2] == 2) { my->count_d[0] = 0.0; my->count_d[1] = 0.5; (my->count[8])++; if ((my->count[8] >= 10) && (my->count[8] <= 55) && (my->count[8] % 15 == 10)) { if (my->count[4] == 0) n = 9; else if (cat_tail_grep_turret_green(my)) n = 8; else n = 7; tenm_table_add(explosion_new(my->x + ((double) (-30 + (rand() % 61))), my->y + ((double) (-30 + (rand() % 61))), 0.0, 0.0, 2, 300, n, 5.0, 8)); } if (my->count[8] >= 100) my->count[2] = 3; return 0; } /* shape change */ my->count_d[2] = result[0]; my->count_d[3] = result[1]; x = my->count_d[2]; y = my->count_d[3]; temp_x = y; temp_y = -x; if (my->count[4] == 0) { temp_x *= 3.0 / 4.0; temp_y *= 3.0 / 4.0; } else { temp_x *= 4.0 / 3.0; temp_y *= 4.0 / 3.0; } if (my->mass != NULL) { (((tenm_polygon *)(my->mass->p[0]))->v[0])->x = my->x + x + temp_x; (((tenm_polygon *)(my->mass->p[0]))->v[0])->y = my->y + y + temp_y; (((tenm_polygon *)(my->mass->p[0]))->v[1])->x = my->x + x - temp_x; (((tenm_polygon *)(my->mass->p[0]))->v[1])->y = my->y + y - temp_y; (((tenm_polygon *)(my->mass->p[0]))->v[2])->x = my->x - x - temp_x; (((tenm_polygon *)(my->mass->p[0]))->v[2])->y = my->y - y - temp_y; (((tenm_polygon *)(my->mass->p[0]))->v[3])->x = my->x - x + temp_x; (((tenm_polygon *)(my->mass->p[0]))->v[3])->y = my->y - y + temp_y; } if (my->count[2] != 1) return 0; /* shoot */ length = tenm_sqrt((int) (my->count_d[2] * my->count_d[2] + my->count_d[3] * my->count_d[3])); if (length < NEAR_ZERO) length = 1.0; if ((my->count[3] >= 70) && (my->count[3] < 200) && (my->count[4] == 1) && (my->count[3] % 10 == 0)) { tenm_table_add(cat_tail_grep_shot_v_new(my->x, my->y, 7.0 * my->count_d[3] / length, 7.0 * (-my->count_d[2]) / length, 60 + (((my->count[3]+60) % 130)/2), player->x, player->y)); tenm_table_add(cat_tail_grep_shot_v_new(my->x, my->y, 7.0 * (-my->count_d[3]) / length, 7.0 * my->count_d[2] / length, 60 + (((my->count[3]+60) % 130)/2), player->x, player->y)); } if ((((my->count[3] >= 350) && (my->count[3] < 480)) || ((my->count[3] >= 1300) && (my->count[3] < 1820)) || ((my->count[3] >= 2520) && (my->count[3] < 3040))) && (my->count[4] == 2) && (my->count[3] % 10 == 0)) { tenm_table_add(cat_tail_grep_shot_s_new(my->x, my->y, 7.0 * my->count_d[3] / length, 7.0 * (-my->count_d[2]) / length, player->x, player->y)); tenm_table_add(cat_tail_grep_shot_s_new(my->x, my->y, 7.0 * (-my->count_d[3]) / length, 7.0 * my->count_d[2] / length, player->x, player->y)); } if ((((my->count[3] >= 600) && (my->count[3] < 1120)) || ((my->count[3] >= 1900) && (my->count[3] < 2420))) && (my->count[4] == 1) && (my->count[3] % 10 == 0)) { tenm_table_add(cat_tail_grep_shot_v_new(my->x, my->y, 7.0 * my->count_d[2] / length, 7.0 * my->count_d[3] / length, 60 + (((my->count[3]+50) % 130)/2), player->x, player->y)); tenm_table_add(cat_tail_grep_shot_v_new(my->x, my->y, 7.0 * my->count_d[3] / length, 7.0 * (-my->count_d[2]) / length, 60 + (((my->count[3]+110)%130)/2), player->x, player->y)); tenm_table_add(cat_tail_grep_shot_v_new(my->x, my->y, 7.0 * (-my->count_d[3]) / length, 7.0 * my->count_d[2] / length, 60 + (((my->count[3]+110)%130)/2), player->x, player->y)); } return 0; } static int cat_tail_grep_turret_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; double x; double y; double temp_x; double temp_y; /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_grep_turret_draw: my is NULL\n"); return 0; } /* dead enemy has low priority */ if (((my->count[2] <= 1) && (priority == 0)) || ((my->count[2] > 1) && (priority == -1))) { /* decoration */ if ((my->count[4] == 0) && (my->count[2] <= 1)) { color = tenm_map_color(182, 123, 162); if (tenm_draw_line((int) (my->x), (int) (my->y), (int) (my->x - 180.0), (int) (my->y - 75.0), 1, color)) status = 1; } /* body */ if (my->count[4] == 0) { if (my->count[2] > 1) color = tenm_map_color(182, 123, 162); else color = tenm_map_color(95, 13, 68); } else if (cat_tail_grep_turret_green(my)) { if (my->count[1] >= 40) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 40) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } x = my->count_d[2]; y = my->count_d[3]; temp_x = y; temp_y = -x; if (my->count[4] == 0) { temp_x *= 3.0 / 4.0; temp_y *= 3.0 / 4.0; } else { temp_x *= 4.0 / 3.0; temp_y *= 4.0 / 3.0; } if (tenm_draw_line((int) (my->x + x + temp_x), (int) (my->y + y + temp_y), (int) (my->x + x - temp_x), (int) (my->y + y - temp_y), 3, color)) status = 1; if (tenm_draw_line((int) (my->x + x - temp_x), (int) (my->y + y - temp_y), (int) (my->x - x - temp_x), (int) (my->y - y - temp_y), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - x - temp_x), (int) (my->y - y - temp_y), (int) (my->x - x + temp_x), (int) (my->y - y + temp_y), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - x + temp_x), (int) (my->y - y + temp_y), (int) (my->x + x + temp_x), (int) (my->y + y + temp_y), 3, color)) status = 1; } /* hit point stat */ if ((priority == 0) && (my->count[4] != 0) && (my->count[1] > 0)) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 10, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "cat_tail_grep_turret_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int cat_tail_grep_turret_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if (my->count[4] == 0) return 0; if (my->count[2] == 1) { if (my->count[3] >= 3160) return 0; if ((my->count[3] < 250) || ((my->count[3] >= 530) && (my->count[3] < 1200)) || ((my->count[3] >= 1840) && (my->count[3] < 2440))) { if (my->count[4] == 1) return 1; } else { if (my->count[4] == 2) return 1; } } return 0; } /* set result (arg 1) to the position of the boss at time t (arg 3) * result (arg 1) must be double[2] (you must allocate enough memory * before calling this function) * return 0 on success, 1 on error */ static int cat_tail_grep_position(double *result, int mode, int t) { /* sanity check */ if (result == NULL) { fprintf(stderr, "cat_tail_grep_position: result is NULL\n"); return 1; } if (t < 0) { fprintf(stderr, "cat_tail_grep_position: t is negative (%d)\n", t); return 1; } if (mode == 0) { result[0] = (double) (WINDOW_WIDTH / 2); result[1] = -150.0 + ((double) (WINDOW_HEIGHT / 4) - (-150.0)) * ((double) t) / 120.0; } else { result[0] = (double) (WINDOW_WIDTH / 2) + 100.0 * tenm_sin(t); result[1] = (double) (WINDOW_HEIGHT / 4); } return 0; } static tenm_object * cat_tail_grep_shot_s_new(double x, double y, double speed_x, double speed_y, double target_x, double target_y) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double temp; double t; double temp_x; double temp_y; double next_x; double next_y; double next_length; /* sanity check */ if (speed_x * speed_x + speed_y * speed_y < NEAR_ZERO) { fprintf(stderr, "cat_tail_grep_shot_s_new: speed is too small " "(%f, %f)\n", speed_x, speed_y); return NULL; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "cat_tail_grep_shot_s_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_circle_new(x, y, 5.0); if (p[0] == NULL) { fprintf(stderr, "cat_tail_grep_shot_s_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 3); if (count == NULL) { fprintf(stderr, "cat_tail_grep_shot_s_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 7); if (count_d == NULL) { fprintf(stderr, "cat_tail_grep_shot_s_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } temp = speed_x * (y - target_y) - speed_y * (x - target_x); if ((temp > -NEAR_ZERO) && (temp < NEAR_ZERO)) { /* the target is exactly in front of me or behind me */ count[1] = 0; count[2] = -1; count_d[2] = 0.0; count_d[3] = 0.0; count_d[4] = 0.0; count_d[5] = 0.0; count_d[6] = 0.0; } else { count[1] = 1; t = (x - target_x) * (x - target_x) + (y - target_y) * (y - target_y); t /= 2.0 * temp; count_d[2] = x + t * speed_y; count_d[3] = y - t * speed_x; temp_x = x - count_d[2]; temp_y = y - count_d[3]; count_d[4] = tenm_sqrt((int) (temp_x * temp_x + temp_y * temp_y)); if (count_d[4] < NEAR_ZERO) { /* something is wrong, fall back to straight move */ count[1] = 0; count[2] = -1; count_d[2] = 0.0; count_d[3] = 0.0; count_d[4] = 0.0; count_d[5] = 0.0; count_d[6] = 0.0; } else { if (-temp_y * (temp_x + speed_x) + temp_x * (temp_y + speed_y) > 0.0) count_d[5] = 1.0; else count_d[5] = -1.0; count_d[6] = tenm_sqrt((int) (speed_x * speed_x + speed_y * speed_y)); if (count_d[6] < NEAR_ZERO) count_d[6] = 1.0; count[2] = 1 + (int) (count_d[4] * 2.0 * 3.1415 / count_d[6]); if (count[2] <= 0) count[2] = 1; next_x = x + speed_x - count_d[2]; next_y = y + speed_y - count_d[3]; next_length = tenm_sqrt((int) (next_x * next_x + next_y * next_y)); if (next_length < NEAR_ZERO) next_length = 1.0; next_x *= count_d[4] / next_length; next_y *= count_d[4] / next_length; speed_x = count_d[2] + next_x - x; speed_y = count_d[3] + next_y - y; } } /* list of count * [0] color (for delete_enemy_shot) * [1] homing flag * [2] rotate timer */ /* list of count_d * [0] speed x * [1] speed y * [2] center x * [3] center y * [4] rotate radius * [5] rotate direction * [6] rotate speed */ count[0] = 0; count_d[0] = speed_x; count_d[1] = speed_y; new = tenm_object_new("cat tail shot s", ATTR_ENEMY_SHOT, ATTR_OPAQUE, 1, x, y, 3, count, 7, count_d, 1, p, (int (*)(tenm_object *, double)) (&cat_tail_grep_shot_s_move), (int (*)(tenm_object *, tenm_object *)) (&cat_tail_grep_shot_s_hit), (int (*)(tenm_object *, const tenm_object *)) (&cat_tail_grep_shot_s_act), (int (*)(tenm_object *, int)) (&cat_tail_grep_shot_s_draw)); if (new == NULL) { fprintf(stderr, "cat_tail_grep_shot_s_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int cat_tail_grep_shot_s_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_grep_shot_s_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "cat_tail_grep_shot_s_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; tenm_move_mass(my->mass, dx_temp, dy_temp); if (!in_window_object(my)) return 1; return 0; } static int cat_tail_grep_shot_s_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_grep_shot_s_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "cat_tail_grep_shot_s_hit: your is NULL\n"); return 0; } if (your->attr & ATTR_OPAQUE) return 1; return 0; } static int cat_tail_grep_shot_s_act(tenm_object *my, const tenm_object *player) { double r_x; double r_y; double r_length; double dr_x; double dr_y; double next_x; double next_y; double next_length; /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_grep_shot_s_act: my is NULL\n"); return 0; } if (player == NULL) return 0; if (my->count[1] == 0) return 0; (my->count[2])--; if (my->count[2] < 0) return 0; r_x = my->x - my->count_d[2]; r_y = my->y - my->count_d[3]; r_length = tenm_sqrt((int) (r_x * r_x + r_y * r_y)); if (r_length < NEAR_ZERO) r_length = 1.0; r_x /= r_length; r_y /= r_length; dr_x = -r_y * my->count_d[5]; dr_y = r_x * my->count_d[5]; next_x = my->x + my->count_d[6] * dr_x - my->count_d[2]; next_y = my->y + my->count_d[6] * dr_y - my->count_d[3]; next_length = tenm_sqrt((int) (next_x * next_x + next_y * next_y)); if (next_length < NEAR_ZERO) next_length = 1.0; next_x *= my->count_d[4] / next_length; next_y *= my->count_d[4] / next_length; my->count_d[0] = my->count_d[2] + next_x - my->x; my->count_d[1] = my->count_d[3] + next_y - my->y; return 0; } static int cat_tail_grep_shot_s_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_grep_shot_s_draw: my is NULL\n"); return 0; } /* return if it is not my turn */ if (priority != 1) return 0; color = tenm_map_color(0, 191, 47); if (tenm_draw_circle((int) (my->x), (int) (my->y), 5, 2, color) != 0) status = 1; return status; } static tenm_object * cat_tail_grep_shot_i_new(double x, double y, double speed, double rotate_direction, double target_x, double target_y, double center_x, double center_y, int t_fixed) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double speed_x; double speed_y; double temp; double temp_x; double temp_y; /* sanity check */ if (speed < NEAR_ZERO) { fprintf(stderr, "cat_tail_grep_shot_i_new: speed is non-positive (%f)\n", speed); return NULL; } if (t_fixed <= 0) { fprintf(stderr, "cat_tail_grep_shot_i_new: t_fixed is non-positive (%d)\n", t_fixed); return NULL; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "cat_tail_grep_shot_i_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_circle_new(x, y, 5.0); if (p[0] == NULL) { fprintf(stderr, "cat_tail_grep_shot_i_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 3); if (count == NULL) { fprintf(stderr, "cat_tail_grep_shot_i_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 11); if (count_d == NULL) { fprintf(stderr, "cat_tail_grep_shot_i_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } temp_x = x - center_x; temp_y = y - center_y; temp = temp_x * temp_x + temp_y * temp_y; temp = tenm_sqrt((int) temp); if (temp < NEAR_ZERO) temp = 1.0; speed_x = speed * (-temp_y / temp); speed_y = speed * (temp_x / temp); /* list of count * [0] color (for delete_enemy_shot) * [1] homing mode * [2] homing timer */ /* list of count_d * [0] speed x * [1] speed y * [2] center x * [3] center y * [4] rotate radius * [5] rotate direction * [6] rotate speed * [7] target x * [8] target y * [9] rotate end x * [10] rotate end y */ count[0] = 4; count[1] = 1; count[2] = t_fixed; count_d[0] = speed_x; count_d[1] = speed_y; count_d[2] = center_x; count_d[3] = center_y; count_d[4] = temp; if (rotate_direction > 0.0) count_d[5] = 1.0; else count_d[5] = -1.0; count_d[0] *= count_d[5]; count_d[1] *= count_d[5]; count_d[6] = speed; count_d[7] = target_x; count_d[8] = target_y; new = tenm_object_new("cat tail shot i", ATTR_ENEMY_SHOT, ATTR_OPAQUE, 1, x, y, 3, count, 11, count_d, 1, p, (int (*)(tenm_object *, double)) (&cat_tail_grep_shot_i_move), (int (*)(tenm_object *, tenm_object *)) (&cat_tail_grep_shot_i_hit), (int (*)(tenm_object *, const tenm_object *)) (&cat_tail_grep_shot_i_act), (int (*)(tenm_object *, int)) (&cat_tail_grep_shot_i_draw)); if (new == NULL) { fprintf(stderr, "cat_tail_grep_shot_i_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int cat_tail_grep_shot_i_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_grep_shot_i_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "cat_tail_grep_shot_i_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; tenm_move_mass(my->mass, dx_temp, dy_temp); if (!in_window_object(my)) return 1; return 0; } static int cat_tail_grep_shot_i_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_grep_shot_i_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "cat_tail_grep_shot_i_hit: your is NULL\n"); return 0; } if (your->attr & ATTR_OPAQUE) return 1; return 0; } static int cat_tail_grep_shot_i_act(tenm_object *my, const tenm_object *player) { double r_x; double r_y; double r_length; double dr_x; double dr_y; double next_x; double next_y; double next_length; double temp; double speed_x; double speed_y; double t; double temp_x; double temp_y; double p_x[2]; double p_y[2]; double h_x; double h_y; int first; /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_grep_shot_i_act: my is NULL\n"); return 0; } if (player == NULL) return 0; if (my->count[1] == 0) return 0; /* mode change */ if (my->count[1] == 1) { (my->count[2])--; if (my->count[2] < 0) { speed_x = my->count_d[0]; speed_y = my->count_d[1]; temp = speed_x * (my->y - my->count_d[8]) - speed_y * (my->x - my->count_d[7]); if ((temp > -NEAR_ZERO) && (temp < NEAR_ZERO)) { /* the target is exactly in front of me or behind me */ my->count[1] = 0; my->count[2] = -1; my->count_d[2] = 0.0; my->count_d[3] = 0.0; my->count_d[4] = 0.0; my->count_d[5] = 0.0; my->count_d[6] = 0.0; my->count_d[7] = 0.0; my->count_d[8] = 0.0; return 0; } else { my->count[1] = 2; t = (my->x - my->count_d[7]) * (my->x - my->count_d[7]) + (my->y - my->count_d[8]) * (my->y - my->count_d[8]); t /= 2.0 * temp; my->count_d[2] = my->x + t * speed_y; my->count_d[3] = my->y - t * speed_x; temp_x = my->x - my->count_d[2]; temp_y = my->y - my->count_d[3]; my->count_d[4] = tenm_sqrt((int) (temp_x * temp_x + temp_y * temp_y)); if (my->count_d[4] < NEAR_ZERO) { /* something is wrong, fall back to straight move */ my->count[1] = 0; my->count[2] = -1; my->count_d[2] = 0.0; my->count_d[3] = 0.0; my->count_d[4] = 0.0; my->count_d[5] = 0.0; my->count_d[6] = 0.0; my->count_d[7] = 0.0; my->count_d[8] = 0.0; return 0; } t = (my->x - my->count_d[7]) * (my->x - my->count_d[7]) + (my->y - my->count_d[8]) * (my->y - my->count_d[8]); t = tenm_sqrt((int) t); if (t < NEAR_ZERO) t = 1.0; speed_x = my->count_d[0]; speed_y = my->count_d[1]; temp_x = my->x - my->count_d[2]; temp_y = my->y - my->count_d[3]; my->count_d[4] = tenm_sqrt((int) (temp_x * temp_x + temp_y * temp_y)); if (my->count_d[4] < NEAR_ZERO) my->count_d[4] = 1.0; if (-temp_y * (temp_x + speed_x) + temp_x * (temp_y + speed_y) > 0.0) my->count_d[5] = 1.0; else my->count_d[5] = -1.0; if ((speed_x * (my->count_d[7] - my->x) + speed_y * (my->count_d[8] - my->y) < tenm_cos(45) * my->count_d[6] * t) && (my->count_d[4] > 160.0)) { r_length = 50.0; my->count[1] = 3; my->count_d[2] = -r_length * speed_y / my->count_d[6]; my->count_d[3] = r_length * speed_x / my->count_d[6]; my->count_d[2] *= my->count_d[5]; my->count_d[3] *= my->count_d[5]; my->count_d[2] += my->x; my->count_d[3] += my->y; my->count_d[4] = r_length; temp_x = my->count_d[7] - my->count_d[2]; temp_y = my->count_d[8] - my->count_d[3]; temp = temp_x * temp_x + temp_y * temp_y; temp = tenm_sqrt((int) temp); if (temp < NEAR_ZERO) temp = 1.0; t = r_length * r_length / temp; h_x = my->count_d[2] + t * temp_x / temp; h_y = my->count_d[3] + t * temp_y / temp; t = temp_x * temp_x + temp_y * temp_y - r_length * r_length; t = tenm_sqrt((int) t); if (t < NEAR_ZERO) t = 1.0; t *= r_length / temp; p_x[0] = h_x - t * temp_y / temp; p_y[0] = h_y + t * temp_x / temp; p_x[1] = h_x + t * temp_y / temp; p_y[1] = h_y - t * temp_x / temp; if (tenm_same_side(p_x[0], p_y[0], p_x[1], p_y[1], my->count_d[2], my->count_d[3], my->x, my->y)) { if (tenm_same_side(p_x[0], p_y[0], my->x, my->y, my->count_d[2], my->count_d[3], my->count_d[7], my->count_d[8])) first = 0; else first = 1; if (tenm_same_side(my->count_d[7], my->count_d[8], my->x + my->count_d[0], my->y + my->count_d[1], my->count_d[2], my->count_d[3], my->x, my->y)) first = first; else first = 1 - first; } else { if (tenm_same_side(p_x[0], p_y[0], my->x + my->count_d[0], my->y + my->count_d[1], my->count_d[2], my->count_d[3], my->x, my->y)) first = 0; else first = 1; } if (tenm_same_side(my->x, my->y, my->count_d[7], my->count_d[8], p_x[0], p_y[0], p_x[1], p_y[1])) { my->count_d[9] = p_x[1 - first]; my->count_d[10] = p_y[1 - first]; } else { my->count_d[9] = p_x[first]; my->count_d[10] = p_y[first]; } my->count_d[6] *= 0.8; my->count[2] = (int)(2.0 * 3.1415 * my->count_d[4] / my->count_d[6]); my->count[2] += 1; if (my->count[2] <= 0) my->count[2] = 1; } } } } if (my->count[1] == 2) { temp_x = my->x - my->count_d[7]; temp_y = my->y - my->count_d[8]; if (temp_x * temp_x + temp_y * temp_y <= my->count_d[6] * my->count_d[6]) { my->count[1] = 0; /* sqrt(1.5) = 1.22474... */ my->count_d[0] *= 1.2247; my->count_d[1] *= 1.2247; return 0; } } if (my->count[1] == 3) { temp_x = my->x - my->count_d[9]; temp_y = my->y - my->count_d[10]; (my->count[2])--; if ((temp_x * temp_x + temp_y * temp_y <= my->count_d[6] * my->count_d[6]) || (my->count[2] < 0)) { my->count[1] = 0; my->count_d[6] *= 1.25 * 1.5; temp_x = my->count_d[7] - my->x; temp_y = my->count_d[8] - my->y; temp = temp_x * temp_x + temp_y * temp_y; temp = tenm_sqrt((int) temp); if (temp < NEAR_ZERO) temp = 1.0; my->count_d[0] = my->count_d[6] * temp_x / temp; my->count_d[1] = my->count_d[6] * temp_y / temp; return 0; } } /* rotate */ r_x = my->x - my->count_d[2]; r_y = my->y - my->count_d[3]; r_length = tenm_sqrt((int) (r_x * r_x + r_y * r_y)); if (r_length < NEAR_ZERO) r_length = 1.0; r_x /= r_length; r_y /= r_length; dr_x = -r_y * my->count_d[5]; dr_y = r_x * my->count_d[5]; next_x = my->x + my->count_d[6] * dr_x - my->count_d[2]; next_y = my->y + my->count_d[6] * dr_y - my->count_d[3]; next_length = tenm_sqrt((int) (next_x * next_x + next_y * next_y)); if (next_length < NEAR_ZERO) next_length = 1.0; next_x *= my->count_d[4] / next_length; next_y *= my->count_d[4] / next_length; my->count_d[0] = my->count_d[2] + next_x - my->x; my->count_d[1] = my->count_d[3] + next_y - my->y; return 0; } static int cat_tail_grep_shot_i_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_grep_shot_i_draw: my is NULL\n"); return 0; } /* return if it is not my turn */ if (priority != 1) return 0; color = tenm_map_color(75, 0, 239); if (tenm_draw_circle((int) (my->x), (int) (my->y), 5, 2, color) != 0) status = 1; return status; } static tenm_object * cat_tail_grep_shot_v_new(double x, double y, double speed_x, double speed_y, int theta_turn, double target_x, double target_y) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double temp[2]; double v[2]; double t; /* sanity check */ if (speed_x * speed_x + speed_y * speed_y < NEAR_ZERO) { fprintf(stderr, "cat_tail_grep_shot_v_new: speed is non-positive " "(%f, %f)\n", speed_x, speed_y); return NULL; } if ((theta_turn <= 0) || (theta_turn >= 180)) { fprintf(stderr, "cat_tail_grep_shot_v_new: strange theta_turn (%d)\n", theta_turn); return NULL; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "cat_tail_grep_shot_v_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_circle_new(x, y, 5.0); if (p[0] == NULL) { fprintf(stderr, "cat_tail_grep_shot_v_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 4); if (count == NULL) { fprintf(stderr, "cat_tail_grep_shot_v_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 6); if (count_d == NULL) { fprintf(stderr, "cat_tail_grep_shot_v_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } if (-speed_y * (target_x - x) + speed_x * (target_y - y) > 0.0) count[3] = theta_turn; else count[3] = -theta_turn; temp[0] = 0.0; temp[1] = 0.0; v[0] = speed_x; v[1] = speed_y; vector_rotate(temp, v, count[3]); t = (x * speed_y - y * speed_x) - (target_x * speed_y - target_y * speed_x); t /= temp[0] * speed_y - temp[1] * speed_x; /* list of count * [0] color (for delete_enemy_shot) * [1] homing flag * [2] homing timer * [3] theta turn */ /* list of count_d * [0] speed x * [1] speed y * [2] turn point x * [3] turn point y * [4] next speed x * [5] next speed y */ count[0] = 2; if (tenm_line_nearer(target_x, target_y, x, y, x + speed_x, y + speed_y, 5.0)) count[1] = 2; else count[1] = 0; count[2] = 0; /* count[3] is set above */ count_d[0] = speed_x; count_d[1] = speed_y; count_d[2] = target_x + t * temp[0]; count_d[3] = target_y + t * temp[1]; count_d[4] = temp[0]; count_d[5] = temp[1]; new = tenm_object_new("cat tail shot v", ATTR_ENEMY_SHOT, ATTR_OPAQUE, 1, x, y, 4, count, 6, count_d, 1, p, (int (*)(tenm_object *, double)) (&cat_tail_grep_shot_v_move), (int (*)(tenm_object *, tenm_object *)) (&cat_tail_grep_shot_v_hit), (int (*)(tenm_object *, const tenm_object *)) (&cat_tail_grep_shot_v_act), (int (*)(tenm_object *, int)) (&cat_tail_grep_shot_v_draw)); if (new == NULL) { fprintf(stderr, "cat_tail_grep_shot_v_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int cat_tail_grep_shot_v_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_grep_shot_v_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "cat_tail_grep_shot_v_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; tenm_move_mass(my->mass, dx_temp, dy_temp); if (!in_window_object(my)) return 1; return 0; } static int cat_tail_grep_shot_v_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_grep_shot_v_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "cat_tail_grep_shot_v_hit: your is NULL\n"); return 0; } if (your->attr & ATTR_OPAQUE) return 1; return 0; } static int cat_tail_grep_shot_v_act(tenm_object *my, const tenm_object *player) { double dx; double dy; /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_grep_shot_v_act: my is NULL\n"); return 0; } if (player == NULL) return 0; switch (my->count[1]) { case 0: dx = my->count_d[2] - my->x; dy = my->count_d[3] - my->y; if (dx * dx + dy * dy <= my->count_d[4] * my->count_d[4]) { my->count[1] = 1; my->count_d[0] = dx; my->count_d[1] = dy; } break; case 1: my->count_d[0] = 0.0; my->count_d[1] = 0.0; (my->count[2])++; if (my->count[2] >= 15) { my->count[0] = 3; my->count[1] = 2; my->count_d[0] = my->count_d[4]; my->count_d[1] = my->count_d[5]; } break; case 2: break; default: fprintf(stderr, "cat_tail_grep_shot_v_act: undefined mode (%d)\n", my->count[1]); break; } return 0; } static int cat_tail_grep_shot_v_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_grep_shot_v_draw: my is NULL\n"); return 0; } /* return if it is not my turn */ if (priority != 1) return 0; if (my->count[1] < 2) color = tenm_map_color(0, 167, 223); else color = tenm_map_color(0, 111, 223); if (tenm_draw_circle((int) (my->x), (int) (my->y), 5, 2, color) != 0) status = 1; return status; } dangen-0.5/spqr/cat-tail-grep.h0000644000175000017500000000036710276702737017226 0ustar00ooharaoohara00000000000000/* $Id: cat-tail-grep.h,v 1.3 2004/02/26 11:31:11 oohara Exp $ */ #ifndef __DANGEN_CAT_TAIL_GREP_H__ #define __DANGEN_CAT_TAIL_GREP_H__ #include "tenm_object.h" tenm_object *cat_tail_grep_new(void); #endif /* not __DANGEN_CAT_TAIL_GREP_H__ */ dangen-0.5/spqr/cat-tail.c0000644000175000017500000013145011625001410016237 0ustar00ooharaoohara00000000000000/* $Id: cat-tail.c,v 1.48 2011/08/23 19:44:08 oohara Exp $ */ /* [easy] cat tail */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "stage-clear.h" #include "score.h" #include "cat-tail.h" #define NEAR_ZERO 0.0001 static int cat_tail_move(tenm_object *my, double turn_per_frame); static int cat_tail_hit(tenm_object *my, tenm_object *your); static void cat_tail_second_form(tenm_object *my); static void cat_tail_explode(tenm_object *my); static int cat_tail_signal_turret(tenm_object *my, int n); static int cat_tail_act(tenm_object *my, const tenm_object *player); static int cat_tail_draw(tenm_object *my, int priority); static int cat_tail_green(const tenm_object *my); static tenm_object *cat_tail_turret_new(int what, int index_body, int index_turret); static int cat_tail_turret_move(tenm_object *my, double turn_per_frame); static int cat_tail_turret_hit(tenm_object *my, tenm_object *your); static int cat_tail_turret_signal_turret(tenm_object *my, int n); static int cat_tail_turret_signal_body(tenm_object *my, int n); static void cat_tail_turret_explode(tenm_object *my); static int cat_tail_turret_act(tenm_object *my, const tenm_object *player); static int cat_tail_turret_draw(tenm_object *my, int priority); static int cat_tail_turret_green(const tenm_object *my); static int cat_tail_position(double *result, int mode, int t); tenm_object * cat_tail_new(void) { int i; tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double result[2]; double x; double y; result[0] = 0.0; result[1] = 0.0; cat_tail_position(result, 0, 0); x = result[0]; y = result[1]; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 3); if (p == NULL) { fprintf(stderr, "cat_tail_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(6, x + 48.0, y, x + 24.0, y + 41.5692, x - 24.0, y + 41.5692, x - 48.0, y, x - 24.0, y - 41.5692, x + 24.0, y - 41.5692); if (p[0] == NULL) { fprintf(stderr, "cat_tail_new: cannot set p[0]\n"); free(p); return NULL; } p[1] = (tenm_primitive *) tenm_polygon_new(3, x - 24.0, y - 41.5692, x - 44.7846, y - 53.5692, x - 36.0, y - 20.7846); if (p[1] == NULL) { fprintf(stderr, "cat_tail_new: cannot set p[1]\n"); (p[0])->delete(p[0]); free(p); return NULL; } p[2] = (tenm_primitive *) tenm_polygon_new(3, x + 24.0, y - 41.5692, x + 44.7846, y - 53.5692, x + 36.0, y - 20.7846); if (p[2] == NULL) { fprintf(stderr, "cat_tail_new: cannot set p[2]\n"); for (i = 0; i < 2; i++) (p[i])->delete(p[i]); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 10); if (count == NULL) { fprintf(stderr, "cat_tail_new: malloc(count) failed\n"); for (i = 0; i < 3; i++) (p[i])->delete(p[i]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "cat_tail_new: malloc(count_d) failed\n"); free(count); for (i = 0; i < 3; i++) (p[i])->delete(p[i]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] move mode * [3] move timer * [4 -- 6] turret index * [7] hand direction * [8] hand theta * [9] "was green when killed" flag */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 0; count[4] = -1; count[5] = -1; count[6] = -1; count[7] = -30; count[8] = 0; count[9] = 0; count_d[0] = 0.0; count_d[1] = 0.0; new = tenm_object_new("cat tail", ATTR_BOSS, ATTR_PLAYER_SHOT, 750, x, y, 10, count, 2, count_d, 3, p, (int (*)(tenm_object *, double)) (&cat_tail_move), (int (*)(tenm_object *, tenm_object *)) (&cat_tail_hit), (int (*)(tenm_object *, const tenm_object *)) (&cat_tail_act), (int (*)(tenm_object *, int)) (&cat_tail_draw)); if (new == NULL) { fprintf(stderr, "cat_tail_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); for (i = 0; i < 3; i++) (p[i])->delete(p[i]); free(p); return NULL; } return new; } static int cat_tail_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "cat_tail_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } if ((my->count[2] == 2) && (my->count[3] < 0)) return 0; dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int cat_tail_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "cat_tail_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if ((my->count[2] != 1) && (my->count[2] != 3)) return 0; deal_damage(my, your, 0); if (cat_tail_green(my)) add_chain(my, your); my->count[1] = 2; if (my->hit_point <= 0) { set_background(1); if (my->count[2] == 1) { add_score(2250); cat_tail_second_form(my); return 0; } else { add_score(6750); cat_tail_explode(my); return 0; } } return 0; } static void cat_tail_second_form(tenm_object *my) { int i; int n; /* sanity check */ if (my == NULL) return; tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); for (i = 0; i < 3; i++) if (my->count[4 + i] >= 0) tenm_table_apply(my->count[4 + i], (int (*)(tenm_object *, int)) (&cat_tail_signal_turret), 0); /* set "was green" flag before we change the life mode */ if (cat_tail_green(my)) { n = 8; my->count[9] = 1; } else { n = 7; my->count[9] = 0; } tenm_table_add(explosion_new(my->x, my->y - 31.1769, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 1, 1000, n, 3.0, 9)); tenm_table_add(fragment_new(my->x, my->y - 31.1769, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 50.0, 20, n, 5.0, 0.0, 20)); my->hit_point = 750; my->count[2] = 2; my->count[3] = -30; my->count[1] = 0; my->count_d[0] = (((double) (WINDOW_WIDTH / 2)) - my->x) / 240.0; my->count_d[1] = (((double) (WINDOW_HEIGHT / 4)) - my->y) / 240.0; } static void cat_tail_explode(tenm_object *my) { int n; double x; double y; double dx; double dy; int i; /* sanity check */ if (my == NULL) return; tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); /* set "was green" flag before we change the life mode */ if (cat_tail_green(my)) { n = 8; my->count[9] = 1; } else { n = 7; my->count[9] = 0; } x = my->x; y = my->y; for (i = 1; i <= 4; i++) { dx = 60.0 * tenm_cos(my->count[7] + my->count[8] * i); dy = 60.0 * tenm_sin(my->count[7] + my->count[8] * i); tenm_table_add(fragment_new(x, y, 0.0, 0.0, 30.0, 10, n, 4.0, 15.0, 12)); tenm_table_add(explosion_new(x + dx / 2.0, y + dy / 2.0, 0.0, 0.0, 1, 1000, n, 10.0, 9)); x += dx; y += dy; } tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 5000, n, 10.0, 6)); my->count[2] = 4; my->count[3] = 0; my->count[1] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.5; /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ tenm_mass_delete(my->mass); my->mass = NULL; } static int cat_tail_signal_turret(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "cat tail turret") != 0) return 0; my->count[2] = 3; /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ if (my->mass != NULL) { tenm_mass_delete(my->mass); my->mass = NULL; } return 0; } static int cat_tail_act(tenm_object *my, const tenm_object *player) { int i; double result[2]; double x; double y; double dx; double dy; double length; int theta; double speed; /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; /* speed change */ (my->count[3])++; result[0] = 0.0; result[1] = 0.0; if (my->count[2] <= 1) { cat_tail_position(result, my->count[2], my->count[3]); my->count_d[0] = result[0] - my->x; my->count_d[1] = result[1] - my->y; } else if (my->count[2] == 2) { if (my->count[3] >= 240) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } } else if (my->count[2] == 3) { if (my->count[3] < 260) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } else { my->count_d[0] = ((double) (WINDOW_WIDTH / 2)) - 100.0 * tenm_sin(my->count[3] - 260); my->count_d[1] = (double) (WINDOW_HEIGHT / 4); my->count_d[0] -= my->x; my->count_d[1] -= my->y; } } else if (my->count[2] == 4) { my->count_d[0] = 0.0; my->count_d[1] = 0.5; } else { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } /* encounter */ if (my->count[2] == 0) { if (my->count[3] == 1) { my->count[4] = tenm_table_add(cat_tail_turret_new(0, my->table_index, -1)); for (i = 1; i < 3; i++) my->count[4+i]=tenm_table_add(cat_tail_turret_new(i, my->table_index, my->count[4])); } if (my->count[3] >= 120) { my->count[2] = 1; my->count[3] = 0; } return 0; } /* self-destruction */ if ((my->count[2] == 1) && (my->count[3] >= 3190)) { set_background(2); clear_chain(); cat_tail_second_form(my); return 0; } if ((my->count[2] == 3) && (my->count[3] >= 2290)) { set_background(2); clear_chain(); cat_tail_explode(my); return 0; } /* second form */ if (my->count[2] == 2) { if (my->count[3] >= 250) { my->count[2] = 3; my->count[3] = 0; } return 0; } /* dead */ if (my->count[2] == 4) { if (cat_tail_green(my)) i = 8; else i = 7; if ((my->count[3] >= 30) && (my->count[3] <= 75) && (my->count[3] % 15 == 0)) { theta = rand() % 360; tenm_table_add(explosion_new(my->x + 30.0 * tenm_cos(theta), my->y + 30.0 * tenm_sin(theta), 0.0, 0.0, 2, 300, i, 5.0, 8)); } if (my->count[3] > 120) { tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 3000, i, 10.0, 8)); tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 30.0, 100, i, 4.0, 0.0, 16)); tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 50.0, 30, i, 2.5, 0.0, 12)); tenm_table_add(stage_clear_new(100)); return 1; } return 0; } /* move hand */ if (my->count[2] == 3) { if (my->count[3] < 120) { my->count[7] += 2; my->count[8] -= 2; } else if (my->count[3] < 150) { ; } else if (my->count[3] < 230) { my->count[7] -= 3; my->count[8] += 3; } else if (my->count[3] < 260) { ; } else { if ((my->count[3] - 260) % 195 < 95) { my->count[7] += 7; my->count[8] -= 7; } else if (((my->count[3] - 260) % 195 >= 100) && ((my->count[3] - 260) % 195 < 190)) { my->count[7] -= 7; my->count[8] += 7; } } if (my->count[8] > 0) my->count[8] -= (my->count[8] + 5) / 6; else if (my->count[8] < 0) my->count[8] -= (my->count[8] - 5) / 6; } /* shoot */ if (my->count[2] == 1) { if ((my->count[3] >= 600) && (my->count[3] < 1150)) { if (my->count[3] % 13 == 0) { tenm_table_add(laser_angle_new(my->x + 40.0 * tenm_sin(my->count[3]), my->y, 5.0, 150 - (my->count[3]%50), 25.0, 3)); tenm_table_add(laser_angle_new(my->x + 40.0 * tenm_sin(my->count[3]), my->y, 5.0, 30 + (my->count[3]%50), 25.0, 3)); } if ((my->count[5] < 0) && (my->count[3] >= 616) && (my->count[3] <= 1141) && (my->count[3] % 21 == 7)) { theta = -30 + 120 * ((my->count[3] % 63) - 7) / 21; dx = player->x - (my->x + 40.0 * tenm_cos(theta)); dy = player->y - (my->y + 40.0 * tenm_sin(theta)); for (i = 0; i < 360; i += 120) tenm_table_add(normal_shot_point_new(my->x + 40.0 * tenm_cos(-30+i), my->y + 40.0 * tenm_sin(-30+i), 4.0, my->x + 40.0 * tenm_cos(-30+i) + dx, my->y + 40.0 * tenm_sin(-30+i) + dy, 4)); } } if ((my->count[3] >= 1350) && (my->count[3] <= 1841)) { if ((my->count[3] % 7 == 0)) { tenm_table_add(laser_point_new(my->x + 40.0 * tenm_sin(my->count[3]), my->y, 9.0, 160.0, 360.0 + 120.0*tenm_sin(my->count[3]*2), 25.0, 3)); tenm_table_add(laser_point_new(my->x + 40.0 * tenm_sin(my->count[3]), my->y, 9.0, 480.0, 360.0 + 120.0*tenm_sin(my->count[3]*2), 25.0, 3)); } if ((my->count[6] < 0) && (my->count[3] >= 1365) && (my->count[3] < 1820) && (my->count[3] % 7 == 0)) { speed = 4.0 + 0.1 * ((double) (my->count[3] % 35)); tenm_table_add(normal_shot_point_new(my->x, my->y, speed, player->x, player->y, 4)); } } if ((my->count[3] >= 1900) && (my->count[3] < 2420)) { if (my->count[3] % 29 == 0) { if (my->count[3] % 58 == 0) { tenm_table_add(laser_angle_new(my->x - 20.0, my->y + 20.0, 4.0, 55, 25.0, 3)); tenm_table_add(laser_angle_new(my->x + 20.0, my->y + 20.0, 4.0, 125, 25.0, 3)); tenm_table_add(laser_angle_new(my->x - 20.0, my->y - 20.0, 5.5, 35, 25.0, 3)); tenm_table_add(laser_angle_new(my->x + 20.0, my->y - 20.0, 5.5, 145, 25.0, 3)); } else { tenm_table_add(laser_angle_new(my->x - 20.0, my->y + 20.0, 4.0, 25, 25.0, 3)); tenm_table_add(laser_angle_new(my->x + 20.0, my->y + 20.0, 4.0, 155, 25.0, 3)); tenm_table_add(laser_angle_new(my->x - 20.0, my->y - 20.0, 5.5, 60, 25.0, 3)); tenm_table_add(laser_angle_new(my->x + 20.0, my->y - 20.0, 5.5, 120, 25.0, 3)); } } if ((my->count[5] < 0) && (my->count[3] % 20 == 0)) { if (my->count[3] % 40 == 0) theta = 30; else theta = 150; dx = player->x - (my->x + 40.0 * tenm_cos(180 - theta)); dy = player->y - (my->y + 40.0 * tenm_sin(180 - theta)); length = tenm_sqrt((int) (dx * dx + dy * dy)); if (length < NEAR_ZERO) length = 1.0; tenm_table_add(normal_shot_point_new(my->x + 40.0 * tenm_cos(30), my->y + 40.0 * tenm_sin(30), 4.0, my->x + 40.0 * tenm_cos(30) + dx, my->y + 40.0 * tenm_sin(30) + dy, 4)); tenm_table_add(normal_shot_point_new(my->x + 40.0 * tenm_cos(150), my->y + 40.0 * tenm_sin(150), 4.0, my->x + 40.0 * tenm_cos(150) + dx, my->y + 40.0 * tenm_sin(150) + dy, 4)); tenm_table_add(normal_shot_new(my->x + 40.0 * tenm_cos(-90), my->y + 40.0 * tenm_sin(-90), 4.0 * dx / length + 2.0 * (tenm_cos(theta)-tenm_cos(-90)), 4.0 * dy / length + 2.0 * (tenm_sin(theta)-tenm_sin(-90)), 4, -2, 0)); } } if ((my->count[3] >= 2520) && (my->count[3] < 3060)) { if (my->count[3] % 7 == 0) { if ((my->count[3] + 270) % 360 < 180) { tenm_table_add(laser_angle_new(my->x - 40.0 * tenm_sin(my->count[3]), my->y, 9.0, 105 + ((my->count[3]+270) % 360) / 3, 25.0, 3)); tenm_table_add(laser_angle_new(my->x - 40.0 * tenm_sin(my->count[3]), my->y, 9.0, 15 + ((my->count[3] + 270) % 360) / 3, 25.0, 3)); } else { tenm_table_add(laser_angle_new(my->x - 40.0 * tenm_sin(my->count[3]), my->y, 9.0, 225 - ((my->count[3]+270) % 360) / 3, 25.0, 3)); tenm_table_add(laser_angle_new(my->x - 40.0 * tenm_sin(my->count[3]), my->y, 9.0, 135 - ((my->count[3]+270) % 360) / 3, 25.0, 3)); } } if ((my->count[6] < 0) && (my->count[3] % 20 == 0)) { for (i = 0; i < 5; i ++) tenm_table_add(normal_shot_point_new(my->x, my->y, 4.0 + 1.0 * ((double) i), player->x, player->y, 4)); } } } if ((my->count[2] == 3) && (my->count[3] % 17 == 0)) { x = my->x; y = my->y; for (i = 1; i <= 4; i++) { dx = 60.0 * tenm_cos(my->count[7] + my->count[8] * i); dy = 60.0 * tenm_sin(my->count[7] + my->count[8] * i); x += dx; y += dy; tenm_table_add(laser_point_new(x, y, 6.5 - 0.5 * ((double) i), player->x, player->y, 25.0, 3)); } } return 0; } static int cat_tail_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; double x; double y; double dx; double dy; int i; int theta; double length; /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_draw: my is NULL\n"); return 0; } /* body */ /* dead enemy has low priority */ if (((my->count[2] <= 3) && (priority == 0)) || ((my->count[2] > 3) && (priority == -1))) { if (cat_tail_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 1) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (my->count[2] <= 1) { if (tenm_draw_line((int) (my->x + 36.0), (int) (my->y - 20.7846), (int) (my->x + 48.0), (int) (my->y), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - 36.0), (int) (my->y - 20.7846), (int) (my->x + 36.0), (int) (my->y - 20.7846), 2, color)) status = 1; if (tenm_draw_line((int) (my->x - 48.0), (int) (my->y), (int) (my->x - 36.0), (int) (my->y - 20.7846), 3, color)) status = 1; } else { if (tenm_draw_line((int) (my->x + 24.0), (int) (my->y - 41.5692), (int) (my->x + 48.0), (int) (my->y), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - 48.0), (int) (my->y), (int) (my->x - 24.0), (int) (my->y - 41.5692), 3, color)) status = 1; } if (tenm_draw_line((int) (my->x + 48.0), (int) (my->y), (int) (my->x + 24.0), (int) (my->y + 41.5692), 3, color)) status = 1; if (tenm_draw_line((int) (my->x + 24.0), (int) (my->y + 41.5692), (int) (my->x - 24.0), (int) (my->y + 41.5692), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - 24.0), (int) (my->y + 41.5692), (int) (my->x - 48.0), (int) (my->y), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - 24.0), (int) (my->y - 41.5692), (int) (my->x + 24.0), (int) (my->y - 41.5692), 2, color)) status = 1; if (tenm_draw_line((int) (my->x - 24.0), (int) (my->y - 41.5692), (int) (my->x - 44.7846), (int) (my->y - 53.5692), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - 44.7846), (int) (my->y - 53.5692), (int) (my->x - 36.0), (int) (my->y - 20.7846), 3, color)) status = 1; if (tenm_draw_line((int) (my->x + 24.0), (int) (my->y - 41.5692), (int) (my->x + 44.7846), (int) (my->y - 53.5692), 3, color)) status = 1; if (tenm_draw_line((int) (my->x + 44.7846), (int) (my->y - 53.5692), (int) (my->x + 36.0), (int) (my->y - 20.7846), 3, color)) status = 1; /* hand */ if ((my->count[2] == 2) && (my->count[3] > 0)) { x = my->x; y = my->y; if (my->count[3] < 0) length = 0.5; else if (my->count[3] < 240) length = ((double) (my->count[3])) * 0.25; else length = 60.0; for (i = 1; i <= 4; i++) { if (my->count[3] < 120) theta = 360; else if (my->count[3] < 240) theta = (120 - my->count[3]) * 3; else theta = 0; dx = length * tenm_cos(my->count[7] + theta * i); dy = length * tenm_sin(my->count[7] + theta * i); if (tenm_draw_line((int) (x), (int) (y), (int) (x + dx), (int) (y + dy), 1, color)) status = 1; if (tenm_draw_circle((int) (x + dx), (int) (y + dy), 5, 1, tenm_map_color(0, 111, 223)) != 0) status = 1; x += dx; y += dy; } } else if (my->count[2] == 3) { x = my->x; y = my->y; for (i = 1; i <= 4; i++) { dx = 60.0 * tenm_cos(my->count[7] + my->count[8] * i); dy = 60.0 * tenm_sin(my->count[7] + my->count[8] * i); if (tenm_draw_line((int) (x), (int) (y), (int) (x + dx), (int) (y + dy), 1, color)) status = 1; if (tenm_draw_circle((int) (x + dx), (int) (y + dy), 5, 1, tenm_map_color(0, 111, 223)) != 0) status = 1; x += dx; y += dy; } } } /* hit point stat */ if ((priority == 0) && ((my->count[2] == 1) || (my->count[2] == 3))) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 5, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "cat_tail_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int cat_tail_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if ((my->count[2] == 1) && (my->count[3] >= 600) && (my->count[3] < 3160)) return 1; if ((my->count[2] == 2) && (my->count[3] < 0) && (my->count[9] != 0)) return 1; if ((my->count[2] == 3) && (my->count[3] >= 260) && (my->count[3] <= 2260)) return 1; if ((my->count[2] == 4) && (my->count[9] != 0)) return 1; return 0; } static tenm_object * cat_tail_turret_new(int what, int index_body, int index_turret) { int i; tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double result[2]; double x; double y; result[0] = 0.0; result[1] = 0.0; cat_tail_position(result, 0, 1); x = result[0]; y = result[1]; /* sanity check */ if ((what < 0) || (what > 2)) { fprintf(stderr, "cat_tail_turret_new: strange what (%d)\n", what); return NULL; } switch (what) { case 0: x += 180.0; y += 75.0; break; case 1: x += 180.0; y += 75.0 + 42.0; break; case 2: x += 180.0; y += 75.0 - 42.0; break; default: fprintf(stderr, "cat_tail_turret_new: undefined what (%d)\n", what); break; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "cat_tail_turret_new: malloc(p) failed\n"); return NULL; } switch (what) { case 0: p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 18.0, y + 24.0, x - 18.0, y + 24.0, x - 18.0, y - 24.0, x + 18.0, y - 24.0); break; case 1: p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 24.0, y + 18.0, x - 24.0, y + 18.0, x - 24.0, y - 18.0, x + 24.0, y - 18.0); break; case 2: p[0] = (tenm_primitive *) tenm_polygon_new(4, x - 24.0, y - 18.0, x + 24.0, y - 18.0, x + 24.0, y + 18.0, x - 24.0, y + 18.0); break; default: fprintf(stderr, "cat_tail_turret_new: undefined what (%d)\n", what); break; } if (p[0] == NULL) { fprintf(stderr, "cat_tail_turret_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 9); if (count == NULL) { fprintf(stderr, "cat_tail_turret_new: malloc(count) failed\n"); for (i = 0; i < 3; i++) (p[i])->delete(p[i]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 4); if (count_d == NULL) { fprintf(stderr, "cat_tail_turret_new: malloc(count_d) failed\n"); free(count); for (i = 0; i < 3; i++) (p[i])->delete(p[i]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] move mode * [3] move timer * [4] what * [5] index body * [6] index turret center * [7] number of turret heads dead * [8] shoot timer */ /* list of count_d * [0] speed x * [1] speed y * [2] front x * [3] front y */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 1; count[4] = what; count[5] = index_body; count[6] = index_turret; count[7] = 0; count[8] = 0; count_d[0] = 0.0; count_d[1] = 0.0; switch (what) { case 0: count_d[2] = 0.0; count_d[3] = 24.0; break; case 1: count_d[2] = 0.0; count_d[3] = 18.0; break; case 2: count_d[2] = 0.0; count_d[3] = -18.0; break; default: fprintf(stderr, "cat_tail_turret_new: undefined what (%d)\n", what); break; } new = tenm_object_new("cat tail turret", ATTR_BOSS, ATTR_PLAYER_SHOT, 750, x, y, 9, count, 4, count_d, 1, p, (int (*)(tenm_object *, double)) (&cat_tail_turret_move), (int (*)(tenm_object *, tenm_object *)) (&cat_tail_turret_hit), (int (*)(tenm_object *, const tenm_object *)) (&cat_tail_turret_act), (int (*)(tenm_object *, int)) (&cat_tail_turret_draw)); if (new == NULL) { fprintf(stderr, "cat_tail_turret_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); for (i = 0; i < 3; i++) (p[i])->delete(p[i]); free(p); return NULL; } return new; } static int cat_tail_turret_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_turret_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "cat_tail_turret_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int cat_tail_turret_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_turret_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "cat_tail_turret_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if (my->count[2] != 1) return 0; if (my->count[4] == 0) return 0; deal_damage(my, your, 0); if (cat_tail_turret_green(my)) add_chain(my, your); my->count[1] = 41; if (my->hit_point <= 0) { add_score(6000); cat_tail_turret_explode(my); tenm_table_apply(my->count[6], (int (*)(tenm_object *, int)) (&cat_tail_turret_signal_turret), 0); tenm_table_apply(my->count[5], (int (*)(tenm_object *, int)) (&cat_tail_turret_signal_body), my->count[4]); return 1; } return 0; } static int cat_tail_turret_signal_turret(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "cat tail turret") != 0) return 0; (my->count[7])++; if (my->count[7] >= 2) { my->count[2] = 2; /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ if (my->mass != NULL) { tenm_mass_delete(my->mass); my->mass = NULL; } } return 0; } static int cat_tail_turret_signal_body(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "cat tail") != 0) return 0; my->count[4 + n] = -1; return 0; } static void cat_tail_turret_explode(tenm_object *my) { int n; /* sanity check */ if (my == NULL) return; if (my->count[4] == 0) n = 9; else if (cat_tail_turret_green(my)) n = 8; else n = 7; tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 1, 1000, n, 8.0, 6)); tenm_table_add(fragment_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 30.0, 30, n, 5.0, 0.0, 20)); } static int cat_tail_turret_act(tenm_object *my, const tenm_object *player) { double result[2]; double temp[2]; double v[2]; double a[2]; double x; double y; double temp_x; double temp_y; double result_length; int n; double length; int dtheta; int i; /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_turret_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; /* self-destruction */ if (my->count[2] == 3) { cat_tail_turret_explode(my); return 1; } /* aim at the player */ (my->count[3])++; temp[0] = 0.0; temp[1] = 0.0; cat_tail_position(temp, my->count[2], my->count[3]); if ((my->count[2] == 0) || (my->count[2] == 2)) { result[0] = my->count_d[2]; result[1] = my->count_d[3]; } else { v[0] = my->count_d[2]; v[1] = my->count_d[3]; a[0] = player->x - (temp[0] + 180.0); a[1] = player->y - (temp[1] + 75.0); if ((my->count[3] < 250) || ((my->count[3] >= 530) && (my->count[3] < 1200)) || ((my->count[3] >= 1840) && (my->count[3] < 2440))) { if (my->count[4] == 2) { a[0] *= -1.0; a[1] *= -1.0; } } else { if (my->count[4] != 2) { a[0] *= -1.0; a[1] *= -1.0; } } if (((my->count[3] >= 250) && (my->count[3] < 310)) || ((my->count[3] >= 530) && (my->count[3] < 590)) || ((my->count[3] >= 1200) && (my->count[3] < 1260)) || ((my->count[3] >= 1840) && (my->count[3] < 1900)) || ((my->count[3] >= 2440) && (my->count[3] < 2500))) dtheta = 3; else dtheta = 1; result[0] = 0.0; result[1] = 0.0; vector_rotate_bounded(result, v, a, dtheta); } /* speed change */ result_length = result[0] * result[0] + result[1] * result[1]; result_length = tenm_sqrt((int) result_length); if ((my->count[4] == 0) || (result_length < NEAR_ZERO)) { my->count_d[0] = (temp[0] + 180.0) - my->x; my->count_d[1] = (temp[1] + 75.0) - my->y; } else { x = result[0] * 42.0 / result_length; y = result[1] * 42.0 / result_length; x += temp[0] + 180.0; y += temp[1] + 75.0; my->count_d[0] = x - my->x; my->count_d[1] = y - my->y; } /* encounter */ if (my->count[2] == 0) { if (my->count[3] >= 120) { my->count[2] = 1; my->count[3] = 0; } return 0; } /* dead */ if (my->count[2] == 2) { my->count_d[0] = 0.0; my->count_d[1] = 0.5; (my->count[8])++; if ((my->count[8] >= 10) && (my->count[8] <= 55) && (my->count[8] % 15 == 10)) { if (my->count[4] == 0) n = 9; else if (cat_tail_turret_green(my)) n = 8; else n = 7; tenm_table_add(explosion_new(my->x + ((double) (-30 + (rand() % 61))), my->y + ((double) (-30 + (rand() % 61))), 0.0, 0.0, 2, 300, n, 5.0, 8)); } if (my->count[8] >= 100) my->count[2] = 3; return 0; } /* shape change */ my->count_d[2] = result[0]; my->count_d[3] = result[1]; x = my->count_d[2]; y = my->count_d[3]; temp_x = y; temp_y = -x; if (my->count[4] == 0) { temp_x *= 3.0 / 4.0; temp_y *= 3.0 / 4.0; } else { temp_x *= 4.0 / 3.0; temp_y *= 4.0 / 3.0; } if (my->mass != NULL) { (((tenm_polygon *)(my->mass->p[0]))->v[0])->x = my->x + x + temp_x; (((tenm_polygon *)(my->mass->p[0]))->v[0])->y = my->y + y + temp_y; (((tenm_polygon *)(my->mass->p[0]))->v[1])->x = my->x + x - temp_x; (((tenm_polygon *)(my->mass->p[0]))->v[1])->y = my->y + y - temp_y; (((tenm_polygon *)(my->mass->p[0]))->v[2])->x = my->x - x - temp_x; (((tenm_polygon *)(my->mass->p[0]))->v[2])->y = my->y - y - temp_y; (((tenm_polygon *)(my->mass->p[0]))->v[3])->x = my->x - x + temp_x; (((tenm_polygon *)(my->mass->p[0]))->v[3])->y = my->y - y + temp_y; } if (my->count[2] != 1) return 0; /* shoot */ length = tenm_sqrt((int) (my->count_d[2] * my->count_d[2] + my->count_d[3] * my->count_d[3])); if (length < NEAR_ZERO) length = 1.0; if ((((my->count[3] >= 70) && (my->count[3] < 200)) || ((my->count[3] >= 600) && (my->count[3] < 1120)) || ((my->count[3] >= 1900) && (my->count[3] < 2420))) && (my->count[4] == 1) && (my->count[3] % 30 == 10)) { for (i = 0; i <= 180; i += 30) { v[0] = my->count_d[2] / length; v[1] = my->count_d[3] / length; result[0] = v[0]; result[1] = v[1]; if (my->count[3] % 60 < 30) dtheta = 1; else dtheta = -1; vector_rotate(result, v, i * dtheta); tenm_table_add(normal_shot_new(my->x, my->y, 4.0 * my->count_d[2] / length + 2.0 * result[0], 4.0 * my->count_d[3] / length + 2.0 * result[1], 2, -2, 0)); } } if ((((my->count[3] >= 350) && (my->count[3] < 480)) || ((my->count[3] >= 1300) && (my->count[3] < 1820)) || ((my->count[3] >= 2520) && (my->count[3] < 3040))) && (my->count[4] == 2) && (my->count[3] % 30 == 20)) { for (i = -2; i <= 2; i++) { tenm_table_add(normal_shot_new(my->x, my->y, 4.0 * my->count_d[2] / length + 0.7 * ((double) i), 4.0 * my->count_d[3] / length + 0.7 * ((double) i), 0, -2, 0)); } for (i = -2; i <= 2; i++) { if (i == 0) continue; tenm_table_add(normal_shot_new(my->x, my->y, 4.0 * my->count_d[2] / length + 0.7 * ((double) i), 4.0 * my->count_d[3] / length + 0.7 * ((double) -i), 0, -2, 0)); } } return 0; } static int cat_tail_turret_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; double x; double y; double temp_x; double temp_y; /* sanity check */ if (my == NULL) { fprintf(stderr, "cat_tail_turret_draw: my is NULL\n"); return 0; } /* dead enemy has low priority */ if (((my->count[2] <= 1) && (priority == 0)) || ((my->count[2] > 1) && (priority == -1))) { /* decoration */ if ((my->count[4] == 0) && (my->count[2] <= 1)) { color = tenm_map_color(182, 123, 162); if (tenm_draw_line((int) (my->x), (int) (my->y), (int) (my->x - 180.0), (int) (my->y - 75.0), 1, color)) status = 1; } /* body */ if (my->count[4] == 0) { if (my->count[2] > 1) color = tenm_map_color(182, 123, 162); else color = tenm_map_color(95, 13, 68); } else if (cat_tail_turret_green(my)) { if (my->count[1] >= 40) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 40) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } x = my->count_d[2]; y = my->count_d[3]; temp_x = y; temp_y = -x; if (my->count[4] == 0) { temp_x *= 3.0 / 4.0; temp_y *= 3.0 / 4.0; } else { temp_x *= 4.0 / 3.0; temp_y *= 4.0 / 3.0; } if (tenm_draw_line((int) (my->x + x + temp_x), (int) (my->y + y + temp_y), (int) (my->x + x - temp_x), (int) (my->y + y - temp_y), 3, color)) status = 1; if (tenm_draw_line((int) (my->x + x - temp_x), (int) (my->y + y - temp_y), (int) (my->x - x - temp_x), (int) (my->y - y - temp_y), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - x - temp_x), (int) (my->y - y - temp_y), (int) (my->x - x + temp_x), (int) (my->y - y + temp_y), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - x + temp_x), (int) (my->y - y + temp_y), (int) (my->x + x + temp_x), (int) (my->y + y + temp_y), 3, color)) status = 1; } /* hit point stat */ if ((priority == 0) && (my->count[4] != 0) && (my->count[1] > 0)) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 10, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "cat_tail_turret_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int cat_tail_turret_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if (my->count[4] == 0) return 0; if (my->count[2] == 1) { if (my->count[3] >= 3160) return 0; if ((my->count[3] < 250) || ((my->count[3] >= 530) && (my->count[3] < 1200)) || ((my->count[3] >= 1840) && (my->count[3] < 2440))) { if (my->count[4] == 1) return 1; } else { if (my->count[4] == 2) return 1; } } return 0; } /* set result (arg 1) to the position of the boss at time t (arg 3) * result (arg 1) must be double[2] (you must allocate enough memory * before calling this function) * return 0 on success, 1 on error */ static int cat_tail_position(double *result, int mode, int t) { /* sanity check */ if (result == NULL) { fprintf(stderr, "cat_tail_position: result is NULL\n"); return 1; } if (t < 0) { fprintf(stderr, "cat_tail_position: t is negative (%d)\n", t); return 1; } if (mode == 0) { result[0] = (double) (WINDOW_WIDTH / 2); result[1] = -150.0 + ((double) (WINDOW_HEIGHT / 4) - (-150.0)) * ((double) t) / 120.0; } else { result[0] = (double) (WINDOW_WIDTH / 2) + 100.0 * tenm_sin(t); result[1] = (double) (WINDOW_HEIGHT / 4); } return 0; } dangen-0.5/spqr/cat-tail.h0000644000175000017500000000033610276702737016267 0ustar00ooharaoohara00000000000000/* $Id: cat-tail.h,v 1.1 2004/07/17 01:50:11 oohara Exp $ */ #ifndef __DANGEN_CAT_TAIL_H__ #define __DANGEN_CAT_TAIL_H__ #include "tenm_object.h" tenm_object *cat_tail_new(void); #endif /* not __DANGEN_CAT_TAIL_H__ */ dangen-0.5/spqr/empty-wind.c0000644000175000017500000007550611625001616016657 0ustar00ooharaoohara00000000000000/* $Id: empty-wind.c,v 1.214 2011/08/23 19:46:22 oohara Exp $ */ /* [very hard] Empty Wind */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "normal-enemy.h" #include "stage-clear.h" #include "score.h" #include "empty-wind.h" #define NEAR_ZERO 0.0001 static int empty_wind_move(tenm_object *my, double turn_per_frame); static int empty_wind_hit(tenm_object *my, tenm_object *your); static int empty_wind_green(const tenm_object *my); static void empty_wind_explode(tenm_object *my); static int empty_wind_act(tenm_object *my, const tenm_object *player); static void empty_wind_set_move_mode(tenm_object *my, const tenm_object *player, int mode); static int empty_wind_draw(tenm_object *my, int priority); static tenm_object *empty_wind_spiral_new(double x); static int empty_wind_spiral_act(tenm_object *my, const tenm_object *player); static int empty_wind_spiral_draw(tenm_object *my, int priority); tenm_object * empty_wind_new(void) { int i; tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = 0.0; double y = 0.0; x = (double) (WINDOW_WIDTH / 2); y = -24.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "empty_wind_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_circle_new(x, y, 25.0); if (p[0] == NULL) { fprintf(stderr, "empty_wind_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 18); if (count == NULL) { fprintf(stderr, "empty_wind_new: malloc(count) failed\n"); for (i = 0; i < 2; i++) (p[i])->delete(p[i]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 7); if (count_d == NULL) { fprintf(stderr, "empty_wind_new: malloc(count_d) failed\n"); if (count != NULL) free(count); for (i = 0; i < 2; i++) (p[i])->delete(p[i]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] move mode * [3] move timer * [4 -- 5] move direction * [6] sub attack timer * [7] main attack timer * [8 -- 9] main attack direction * [10] life mode * [11] life timer * [12] decoration timer * [13] "was green when killed" flag */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 0; count[4] = 0; count[5] = 0; count[6] = 0; count[7] = 0; count[8] = 0; count[9] = 0; count[10] = 0; count[11] = 0; count[12] = 0; count[13] = 0; /* list of count_d * [0] speed x * [1] speed y * [2] move center x * [3] move center y * [4] decoration dy * [5] normal enemy dx * [6] normal enemy dy */ count_d[0] = 0.0; count_d[1] = 0.0; count_d[2] = 0.0; count_d[3] = 0.0; count_d[4] = 0.0; count_d[5] = 0.0; count_d[6] = 0.0; new = tenm_object_new("Empty Wind", ATTR_BOSS, ATTR_PLAYER_SHOT, 500, x, y, 18, count, 7, count_d, 1, p, (int (*)(tenm_object *, double)) (&empty_wind_move), (int (*)(tenm_object *, tenm_object *)) (&empty_wind_hit), (int (*)(tenm_object *, const tenm_object *)) (&empty_wind_act), (int (*)(tenm_object *, int)) (&empty_wind_draw)); if (new == NULL) { fprintf(stderr, "empty_wind_new: tenm_object_new failed\n"); free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int empty_wind_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) return 0; if (turn_per_frame <= 0.5) return 0; dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int empty_wind_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) return 0; if (your == NULL) return 0; if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if (my->count[10] != 1) return 0; deal_damage(my, your, 0); if (empty_wind_green(my)) add_chain(my, your); my->count[1] = 2; if (my->hit_point <= 0) { set_background(1); add_score(100000); empty_wind_explode(my); return 0; } return 0; } /* return 1 (true) or 0 (false) */ static int empty_wind_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if ((my->count[10] == 1) && (my->count[11] <= 8630)) return 1; if (my->count[10] == 2) { if (my->count[13] == 1) return 1; else return 0; } return 0; } static void empty_wind_explode(tenm_object *my) { int n; /* sanity check */ if (my == NULL) return; /* set "was green" flag before we change the life mode */ if (empty_wind_green(my)) { my->count[13] = 1; n = 8; } else { my->count[13] = 0; n = 7; } my->count[10] = 2; my->count[11] = 0; my->count[1] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy), 0); tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 5000, n, 10.0, 6)); tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 2, 1000, n, 6.0, 6)); /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ tenm_mass_delete(my->mass); my->mass = NULL; } static int empty_wind_act(tenm_object *my, const tenm_object *player) { int i; int n; int theta; double dx; double dy; double length; int what; int time_shoot; /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; /* decoration */ my->count[12] += 5; if (my->count[12] >= 360) my->count[12] = 0; my->count_d[4] -= my->count_d[1] * 0.5; if (my->count_d[4] < NEAR_ZERO) my->count_d[4] = 0.0; else if (my->count_d[4] > 50.0) my->count_d[4] = 50.0; /* encounter */ if (my->count[10] == 0) { my->count_d[0] = 0.0; my->count_d[1] = 4.5; (my->count[11])++; if (my->count[11] > 40) { my->count[10] = 1; my->count[11] = 0; empty_wind_set_move_mode(my, player, 3); return 0; } return 0; } /* dead */ if (my->count[10] == 2) { my->count_d[0] = 0.0; my->count_d[1] += 0.3; (my->count[11])++; if (my->count[11] > 60) { if (empty_wind_green(my)) n = 8; else n = 7; tenm_table_add(explosion_new(my->x, ((double) (WINDOW_HEIGHT)) + 25.0, 0.0, -6.0, 1, 5000, n, 10.0, 6)); tenm_table_add(explosion_new(my->x, ((double) (WINDOW_HEIGHT)) + 25.0, 0.0, -4.5, 2, 1000, n, 6.0, 6)); tenm_table_add(stage_clear_new(100)); return 1; } return 0; } /* self-destruction */ if ((my->count[10] == 1) && (my->count[11] > 8660)) { set_background(2); clear_chain(); empty_wind_explode(my); return 0; } /* jump */ if (my->y > player->y + 24.0) { my->count_d[1] = -4.5; } else { my->count_d[1] += 0.3; } /* horizontal move */ my->count_d[0] = 0.0; switch (my->count[2]) { case 0: if (my->count[3] < 0) { (my->count[3])++; } else if (0 != 0) { empty_wind_set_move_mode(my, player, 3); } else if ((my->x > player->x - 120.0) && (my->x < player->x + 120.0)) { if (rand() % 2 == 0) { empty_wind_set_move_mode(my, player, 1); } else { empty_wind_set_move_mode(my, player, 2); } } else if ((my->x < player->x - 300) || (my->x > player->x + 300.0) || ((my->x > 200.0) && (player->x < 100.0)) || ((my->x < ((double) WINDOW_WIDTH) - 200.0) && (player->x > ((double) WINDOW_WIDTH) - 100.0)) ) { empty_wind_set_move_mode(my, player, 1); /* chase the player */ if (my->x > player->x) my->count[4] = -1; else my->count[4] = 1; } break; case 1: my->count_d[0] = 3.0 * ((double) (my->count[4])); (my->count[3])++; if (my->count[3] < 20) { my->count_d[0] = 0.3 * ((double) (my->count[4] * (my->count[3] - 10))); my->count_d[1] = 0.0; } else if (my->count[3] >= 80) { empty_wind_set_move_mode(my, player, 0); my->count[3] = -(rand() % 10); } break; case 2: theta = my->count[5] + my->count[3] * my->count[4]; my->count_d[0] = 80.0 * tenm_cos(theta); my->count_d[1] = 80.0 * tenm_sin(theta); my->count_d[0] += my->count_d[2]; my->count_d[1] += my->count_d[3]; my->count_d[0] -= my->x; my->count_d[1] -= my->y; my->count[3] += 5; if (my->count[3] >= 180) { empty_wind_set_move_mode(my, player, 0); my->count[3] = -(rand() % 10); } break; case 3: if (my->count[3] < 0) { dx = my->count_d[2] - my->x; dy = my->count_d[3] - my->y; length = tenm_sqrt((int) (dx * dx + dy * dy)); if (length < NEAR_ZERO) length = 1.0; if (length < 4.5) { my->count_d[0] = dx; my->count_d[1] = dy; my->count[3] = 0; } else { my->count_d[0] = 4.5 * dx / length; my->count_d[1] = 4.5 * dy / length; } } else { if ((my->count[3] < 25) || (my->count[3] >= 65)) { my->count[5] += 3 * my->count[4]; length = 300.0; dy = -30; } else { my->count[5] += 9 * my->count[4]; length = 100.0; dy = 170; } my->count_d[0] = ((double) (WINDOW_WIDTH / 2)) + length * tenm_cos(my->count[5]); my->count_d[1] = dy + length * tenm_sin(my->count[5]); my->count_d[0] -= my->x; my->count_d[1] -= my->y; (my->count[3])++; if (my->count[3] >= 90) { empty_wind_set_move_mode(my, player, 0); my->count[3] = -(rand() % 10); } } break; default: break; } /* horizontal move override */ if ((my->count[11] == 1950) || (my->count[11] == 4000) || (my->count[11] == 6000)) empty_wind_set_move_mode(my, player, 3); /* boundary check */ if (my->x < NEAR_ZERO) { if (my->count_d[0] < 0.0) my->count_d[0] = 0.0; } if (my->x > ((double) WINDOW_WIDTH) - NEAR_ZERO) { if (my->count_d[0] > 0.0) my->count_d[0] = 0.0; } if (my->count[10] != 1) return 0; /* add normal enemy */ (my->count[11])++; if ((my->count[11] > 272) && (my->count[11] <= 1904) && (my->count[11] % 136 >= 96) && (my->count[11] % 8 == 0)) { if (my->count[11] % 136 == 96) { if (player->x < (double) (WINDOW_WIDTH / 2)) my->count_d[5] = -1.0; else my->count_d[5] = 1.0; if (player->y < (double) (WINDOW_HEIGHT / 2)) my->count_d[6] = -1.0; else my->count_d[6] = 1.0; } dx = my->count_d[5]; dy = my->count_d[6]; if (my->count[11] % 136 == 96) { what = BALL_CAPTAIN; time_shoot = 40; } else { what = BALL_SOLDIER; time_shoot = 1000; } tenm_table_add(normal_enemy_new(((double) (WINDOW_WIDTH / 2)) - dx * (((double) (WINDOW_WIDTH/2)) +14.0), ((double) (WINDOW_HEIGHT / 2)) - dy * (((double) (WINDOW_HEIGHT/2))+14.0), what, 0, 0, -1, 0, -1, 0, 3, 3, /* move 0 */ 80, 5.6569 * dx, 5.6569 * dy, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ /* ./rotate.py 200 201.4480 41.4480 121.4480 121.4480 0 -0.4 */ 108, 0.0, 0.0, 0.0, 0.0, 320.0 + dx * 198.5520, 240.0 + dy * 118.5520, 0.0, -0.4 * dx * dy, 2, /* move 2 */ 1000, 0.0, -8.0 * dy, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 80, time_shoot, 0, 0, 0, 1, /* shoot 1 */ 108, time_shoot, 0, 0, 1, 2, /* shoot 2 */ 1000, time_shoot, 8, 0, 0, 2)); } if ((my->count[11] > 2312) && (my->count[11] <= 3944) && (my->count[11] % 136 >= 96) && (my->count[11] % 8 == 0)) { if (my->count[11] % 136 == 96) { if (player->x < (double) (WINDOW_WIDTH / 2)) my->count_d[5] = -1.0; else my->count_d[5] = 1.0; if (player->y < (double) (WINDOW_HEIGHT / 2)) my->count_d[6] = -1.0; else my->count_d[6] = 1.0; } dx = my->count_d[5]; dy = my->count_d[6]; if (my->count[11] % 136 == 96) { what = BALL_CAPTAIN; time_shoot = 40; } else { what = BALL_SOLDIER; time_shoot = 1000; } tenm_table_add(normal_enemy_new(((double) (WINDOW_WIDTH / 2)) - dx * (((double) (WINDOW_WIDTH/2)) +14.0), ((double) (WINDOW_HEIGHT / 2)) - dy * (((double) (WINDOW_HEIGHT/2))+14.0), what, 0, 0, -1, 0, -1, 0, 3, 4, /* move 0 */ 130, 3.0 * dx, 12.0 * dy, 0.0, -0.15 * dy, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 30, 7.5 * dx, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 1000, -3.0 * dx, -6.0 * dy, 0.0, 0.15 * dy, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 40 + 136 - (my->count[11] % 136), time_shoot, 0, 0, 0, 1, /* shoot 1 */ 50, time_shoot, 0, 0, 1, 2, /* shoot 2 */ 70, time_shoot, 10, 0, 0, 3, /* shoot 3 */ 1000, time_shoot, 0, 0, 1, 3)); } if ((my->count[11] > 4352) && (my->count[11] <= 5984) && (my->count[11] % 136 >= 96) && (my->count[11] % 8 == 0)) { if (my->count[11] % 136 == 96) { if (player->x < (double) (WINDOW_WIDTH / 2)) my->count_d[5] = -1.0; else my->count_d[5] = 1.0; if (player->y < (double) (WINDOW_HEIGHT / 2)) my->count_d[6] = -1.0; else my->count_d[6] = 1.0; } dx = my->count_d[5]; dy = my->count_d[6]; if (my->count[11] % 136 == 96) { what = BALL_CAPTAIN; time_shoot = 40; } else { what = BALL_SOLDIER; time_shoot = 1000; } tenm_table_add(normal_enemy_new(((double) (WINDOW_WIDTH / 2)) - dx * (((double) (WINDOW_WIDTH/2)) +19.0), ((double) (WINDOW_HEIGHT / 2)) - dy * 157.0, what, 0, 0, -1, 0, -1, 0, 4, 3, /* move 0 */ 62, 8.0 * dx, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ /* ./rotate.py 200 163 83 163 240 0 -0.25 */ 94, 0.0, 0.0, 0.0, 0.0, ((double) (WINDOW_WIDTH / 2)) + 157.0 * dx, ((double) (WINDOW_HEIGHT / 2)), 0.0, 0.25 * dx * dy, 2, /* move 2 */ /* ./rotate.py 200 320 240 399 240 0 0.5 */ 57, 0.0, 0.0, 0.0, 0.0, ((double) (WINDOW_WIDTH / 2)) - 79.0 * dx, ((double) (WINDOW_HEIGHT / 2)), 0.0, -0.5 * dx * dy, 3, /* move 3 */ 1000, 4.0 * dx, -6.9282 * dy, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3, /* shoot 0 */ 156, time_shoot, 0, 0, 0, 1, /* shoot 1 */ 57, time_shoot, 36, 0, 1, 2, /* shoot 2 */ 1000, time_shoot, 13, 0, 0, 2)); } if ((my->count[11] >= 6392) && (my->count[11] < 7832) && (my->count[11] % 8 == 0)) { if (player->x < (double) (WINDOW_WIDTH / 2)) dx = -1.0; else dx = 1.0; if (player->y < (double) (WINDOW_HEIGHT / 2)) dy = -1.0; else dy = 1.0; tenm_table_add(normal_enemy_new(((double) (WINDOW_WIDTH / 2)) - dx * (((double) (WINDOW_WIDTH/2))+19.0), ((double) (WINDOW_HEIGHT / 2)) - dy * (((double) (WINDOW_HEIGHT/2))-20.0), BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 1000, 7.0 * dx, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 1000, 1000, 0, 0, 1, 0)); } /* sub attack */ if ((my->count[11] > 200) && (my->count[11] <= 8630)) { (my->count[6])++; if ((my->count[6] >= 45) && (my->count[6] % 5 == 0)) { if (my->count[6] % 10 >= 5) { dx = 0.0; dy = 0.0; n = 4; } else { dx = player->count_d[0] * 15.0; dy = player->count_d[1] * 15.0; n = 5; } tenm_table_add(laser_point_new(my->x, my->y, 12.0, player->x + dx, player->y + dy, 30.0, n)); } if (my->count[6] >= 70) { if ((my->count[11] >= 2050) && (my->count[11] < 2370)) my->count[6] = my->count[11] - 2370; else if ((my->count[11] >= 2370) && (my->count[11] < 4000)) my->count[6] = -170; else if ((my->count[11] >= 4000) && (my->count[11] < 4450)) my->count[6] = my->count[11] - 4450; else if ((my->count[11] >= 4450) && (my->count[11] < 5950)) my->count[6] = -170; else if ((my->count[11] >= 5950) && (my->count[11] < 6250)) my->count[6] = my->count[11] - 6250; else my->count[6] = 0; } } /* main attack */ if ((my->count[11] > 2200) && (my->count[11] <= 8630)) { (my->count[7])++; if (my->count[11] >= 4300) { if (my->count[7] == 36) { tenm_table_add(empty_wind_spiral_new(player->x)); } } if ((my->count[11] < 4300) || (my->count[11] >= 6250)) { if (my->count[7] == 36) { if (rand() % 2 == 0) my->count[8] = 1; else my->count[8] = -1; my->count[9] = rand() % 360; } if ((my->count[7] >= 90) && (my->count[7] % 10 == 0)) { theta = my->count[9] + 10 * my->count[8] * (my->count[7] - 90); length = 50.0 + ((double) (my->count[7] - 90)); for (i = 0; i < 360; i += 30) { dx = length * tenm_cos(theta + i); dy = 0.5 * length * tenm_sin(theta + i); dy += 50.0; dy -= (double) ((my->count[7] - 90) * 5); tenm_table_add(laser_angle_new(my->x + dx, my->y + dy, 9.0, theta + i + 150 * my->count[8], 25.0, 0)); } } } if (my->count[7] >= 170) { if (my->count[11] < 4000) my->count[7] = -70; else if ((my->count[11] >= 4000) && (my->count[11] < 4300)) my->count[7] = my->count[11] - 4300; else if ((my->count[11] >= 4300) && (my->count[11] < 5950)) my->count[7] = -70; else if ((my->count[11] >= 5950) && (my->count[11] < 6250)) my->count[7] = my->count[11] - 6250; else my->count[7] = 0; } } return 0; } static void empty_wind_set_move_mode(tenm_object *my, const tenm_object *player, int mode) { int theta; /* sanity check */ if (my == NULL) return; if (player == NULL) return; if ((mode < 0) || (mode > 3)) { fprintf(stderr, "empty_wind_set_move_mode: strange mode (%d)\n", mode); return; } my->count[2] = mode; switch (mode) { case 0: my->count[3] = 0; my->count_d[1] = 0.0; break; case 1: my->count[3] = 0; if (my->x > (double) (WINDOW_WIDTH / 2)) my->count[4] = -1; else my->count[4] = 1; break; case 2: my->count[3] = 0; if (my->x < 200.0) my->count[4] = -1; else if (my->x > ((double) WINDOW_WIDTH) - 200.0) my->count[4] = 1; else if (my->x > player->x) my->count[4] = 1; else my->count[4] = -1; if (my->count[4] > 0) my->count[5] = 0; else my->count[5] = 180; my->count_d[2] = my->x - 80.0 * ((double) (my->count[4])); my->count_d[3] = my->y; /* default: lower half circle * upper half circle if one of the following happens: * 1) we are near the lower side of the window * 2) we are far from the upper side of the window * and the player is below us */ if ((my->y > ((double) WINDOW_HEIGHT) - 100.0) || ((my->y > 100.0) && (my->y < player->y))) { my->count[4] *= -1; } break; case 3: my->count[3] = -1; /* if (my->x < (double) (WINDOW_WIDTH / 2)) */ if (my->x < player->x) { theta = 165; my->count[4] = -1; } else { theta = 15; my->count[4] = 1; } my->count[5] = theta; my->count_d[2] = ((double) (WINDOW_WIDTH / 2)) + 300.0 * tenm_cos(theta); my->count_d[3] = -30.0 + 300.0 * tenm_sin(theta); break; default: fprintf(stderr, "empty_wind_set_move_mode: undefined mode (%d)\n", mode); break; } } static int empty_wind_draw(tenm_object *my, int priority) { tenm_color color; char temp[32]; int status = 0; int i; int theta; double length; double dx; double dy; /* sanity check */ if (my == NULL) return 0; /* decoration */ if ((priority == -1) && (my->count[10] != 2)) { /* vortex */ if (empty_wind_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(181, 190, 92); else color = tenm_map_color(157, 182, 123); } else { if (my->count[1] >= 1) color = tenm_map_color(200, 164, 92); else color = tenm_map_color(182, 147, 123); } for (i = 0; i < 4; i++) { theta = my->count[12] + i * 90; if (i % 2 == 1) theta = 210 - theta; dy = my->count_d[4]; length = 80.0 - dy * 0.75; if (i % 2 == 1) dy += 15.0; if (tenm_draw_line((int) (my->x + length * tenm_cos(theta)), (int) (my->y + length * 0.5 * tenm_sin(theta) + dy), (int) (my->x + length * tenm_cos(theta- 30)), (int) (my->y + length * 0.5*tenm_sin(theta-30) + dy), 1, color) != 0) status = 1; } /* main attack */ if ((my->count[7] >= 36) && ((my->count[11] < 4300) || (my->count[11] >= 6250))) { color = tenm_map_color(158, 158, 158); for (i = 0; i < 360; i += 180) { if (my->count[7] < 90) theta = 10 * my->count[8] * (my->count[7] - 36) + i; else theta = i; if (tenm_draw_line((int) (my->x + 50.0 * tenm_cos(theta)), (int) (my->y + 25.0 * tenm_sin(theta) + 50.0), (int) (my->x + 130.0 * tenm_cos(theta)), (int) (my->y + 65.0 * tenm_sin(theta) - 350.0), 1, color) != 0) status = 1; } if (my->count[7] >= 90) { color = tenm_map_color(99, 158, 114); for (i = 0; i < 2; i++) { theta = my->count[9] + 10 * my->count[8] * (my->count[7] - 90) + 90 * i; length = 50.0 + ((double) (my->count[7] - 90)); dx = length * tenm_cos(theta); dy = 0.5 * length * tenm_sin(theta); if (tenm_draw_line((int) (my->x + dx), (int) (my->y + 50.0 - (double) ((my->count[7] - 90) * 5) + dy), (int) (my->x - dx), (int) (my->y + 50.0 - (double) ((my->count[7] - 90) * 5) - dy), 1, color) != 0) status = 1; } } } } if (((my->count[10] != 2) && (priority == 0)) || (priority == -1)) { /* body */ if (empty_wind_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 1) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (tenm_draw_circle((int) (my->x), (int) (my->y), 25, 3, color) != 0) status = 1; } /* hit point stat */ if (my->count[10] == 1) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) (my->x)) - 5, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "empty_wind_draw: draw_string failed\n"); status = 1; } } return status; } static tenm_object * empty_wind_spiral_new(double x) { tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; count = (int *) malloc(sizeof(int) * 18); if (count == NULL) { fprintf(stderr, "empty_wind_spiral_new: malloc(count) failed\n"); return NULL; } count_d = (double *) malloc(sizeof(double) * 6); if (count_d == NULL) { fprintf(stderr, "empty_wind_spiral_new: malloc(count_d) failed\n"); if (count != NULL) free(count); return NULL; } /* list of count * [0] color (for delete_enemy_shot) * [1] shoot timer * [2] theta base * [3] theta direction */ count[0] = 1; count[1] = 0; count[2] = rand() % 360; if (rand() % 2 == 0) count[3] = 1; else count[3] = -1; count[4] = 0; count[5] = 0; count[6] = 0; count[7] = 0; count[8] = 0; count[9] = 0; /* list of count_d */ count_d[0] = 0.0; count_d[1] = 0.0; count_d[2] = 0.0; count_d[3] = 0.0; /* ATTR_ENEMY_SHOT is only to clear it when the player is killed */ new = tenm_object_new("Empty Wind spiral", ATTR_ENEMY_SHOT, 0, 0, x, (double) (WINDOW_HEIGHT / 2), 18, count, 6, count_d, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&empty_wind_spiral_act), (int (*)(tenm_object *, int)) (&empty_wind_spiral_draw)); if (new == NULL) { fprintf(stderr, "empty_wind_spiral_new: tenm_object_new failed\n"); free(count_d); if (count != NULL) free(count); return NULL; } return new; } static int empty_wind_spiral_act(tenm_object *my, const tenm_object *player) { int i; int theta; double x; double y; /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; (my->count[1])++; if (my->count[1] > 72) { for (i = 0; i < 72; i++) { theta = my->count[2] + my->count[3] * 30 * i; x = my->x + 50.0 * tenm_cos(theta); y = ((double) WINDOW_HEIGHT) + 10.0 - (double) (i * 9) + 50.0 * tenm_sin(theta); tenm_table_add(laser_angle_new(x, y, 9.0, theta + my->count[3] * 150, 25.0, 1)); } return 1; } return 0; } static int empty_wind_spiral_draw(tenm_object *my, int priority) { int i; int theta; tenm_color color; int status = 0; double x; double y; double dx; double dy; /* sanity check */ if (my == NULL) return 0; if (my->count[1] < 0) return 0; if (priority != 0) return 0; color = tenm_map_color(99, 158, 138); for (i = 0; i < my->count[1]; i++) { theta = my->count[2] + my->count[3] * 30 * i; x = my->x + 50.0 * tenm_cos(theta); y = ((double) WINDOW_HEIGHT) + 10.0 - (double) (i * 9) + 50.0 * tenm_sin(theta); dx = 25.0 * tenm_cos(theta + my->count[3] * 150); dy = 25.0 * tenm_sin(theta + my->count[3] * 150); if (tenm_draw_line((int) (x), (int) (y), (int) (x + dx), (int) (y + dy), 1, color) != 0) status = 1; } theta = my->count[2] + my->count[3] * 30 * my->count[1]; x = my->x + 50.0 * tenm_cos(theta); y = ((double) WINDOW_HEIGHT) + 10.0 - (double) (my->count[1] * 9) + 50.0 * tenm_sin(theta); if (tenm_draw_circle((int) (x), (int) (y), 5, 1, color) != 0) status = 1; return status; } dangen-0.5/spqr/empty-wind.h0000644000175000017500000000035010276702737016662 0ustar00ooharaoohara00000000000000/* $Id: empty-wind.h,v 1.1 2003/10/25 08:52:14 oohara Exp $ */ #ifndef __DANGEN_EMPTY_WIND_H__ #define __DANGEN_EMPTY_WIND_H__ #include "tenm_object.h" tenm_object *empty_wind_new(void); #endif /* not __DANGEN_EMPTY_WIND_H__ */ dangen-0.5/spqr/explosion.c0000644000175000017500000001243410276702737016606 0ustar00ooharaoohara00000000000000/* $Id: explosion.c,v 1.44 2004/08/13 15:25:51 oohara Exp $ */ #include /* malloc, rand */ #include #include "tenm_graphic.h" #include "tenm_math.h" #include "tenm_object.h" #include "const.h" #include "explosion.h" static int explosion_act(tenm_object *my, const tenm_object *player); static int explosion_draw(tenm_object *my, int priority); tenm_object * explosion_new(double x, double y, double dx, double dy, int size_debris, int number_debris, int color, double speed_debris, int life) { int i; int suffix; int theta; double temp_speed; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; /* sanity check */ if (size_debris <= 0) return NULL; if (number_debris <= 0) return NULL; if (speed_debris <= 0.0) return NULL; if (life <= 0) return NULL; count = (int *) malloc(sizeof(int) * 5); if (count == NULL) { fprintf(stderr, "explosion_new: malloc(count) failed\n"); return NULL; } count_d = (double *) malloc(sizeof(double) * (4 + 4 * number_debris)); if (count_d == NULL) { fprintf(stderr, "explosion_new: malloc(count_d) failed\n"); free(count); return NULL; } /* list of count * [0] size of debris * [1] number of debris * [2] color * [3] life * [4] time passed */ count[0] = size_debris; count[1] = number_debris; count[2] = color; count[3] = life; count[4] = 0; /* list of count_d * [0] source x * [1] source y * [2] source dx * [3] source dy * [4--] debris (x, y, dx, dy) (relative to source) */ count_d[0] = x; count_d[1] = y; count_d[2] = dx; count_d[3] = dy; for (i = 0; i < number_debris; i++) { suffix = i * 4 + 4; theta = rand() % 360; temp_speed = (double) (6 + rand() % 95) / 100.0; count_d[suffix + 0] = 0.0; count_d[suffix + 1] = 0.0; count_d[suffix + 2] = speed_debris * temp_speed * tenm_cos(theta); count_d[suffix + 3] = speed_debris * temp_speed * tenm_sin(theta); } new = tenm_object_new("explosion", 0, 0, 0, x, y, 5, count, 4 + 4 * number_debris, count_d, 0, NULL, (int (*)(tenm_object *, double)) NULL, NULL, (int (*)(tenm_object *, const tenm_object *)) (&explosion_act), (int (*)(tenm_object *, int)) (&explosion_draw)); if (new == NULL) { fprintf(stderr, "explosion_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); return NULL; } return new; } static int explosion_act(tenm_object *my, const tenm_object *player) { int i; int suffix; /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; (my->count[4])++; if (my->count[4] >= my->count[3]) { (my->count[1]) /= 2; my->count[4] = 0; } if (my->count[1] <= 0) return 1; /* explosion does not collide with anything, so let't move it here, * not in a separate move function */ my->count_d[0] += my->count_d[2]; my->count_d[1] += my->count_d[3]; for (i = 0; i < my->count[1]; i++) { suffix = i * 4 + 4; my->count_d[suffix + 0] += my->count_d[suffix + 2]; my->count_d[suffix + 1] += my->count_d[suffix + 3]; } return 0; } static int explosion_draw(tenm_object *my, int priority) { int i; int suffix; int status = 0; tenm_color color; int temp; /* sanity check */ if (my == NULL) return 0; if (priority != 0) return 0; if (my->count[0] <= 0) return 0; switch (my->count[2]) { /* enemy shot */ /* saturation 95 value 158 */ /* hue 135 */ case 0: color = tenm_map_color(99, 158, 79); color = tenm_map_color(99, 158, 114); break; /* hue 160 */ case 1: color = tenm_map_color(99, 158, 114); color = tenm_map_color(99, 158, 138); break; /* hue 195 */ case 2: color = tenm_map_color(79, 138, 158); color = tenm_map_color(99, 143, 158); break; /* hue 210 */ case 3: color = tenm_map_color(79, 118, 158); color = tenm_map_color(99, 128, 158); break; /* hue 259 */ case 4: color = tenm_map_color(118, 99, 158); break; /* hue 284 */ case 5: color = tenm_map_color(142, 99, 158); break; /* dummy enemy shot */ /* saturation 0 value 158 */ case 6: color = tenm_map_color(158, 158, 158); break; /* enemy */ /* brown (normal) */ case 7: color = tenm_map_color(95, 47, 13); break; /* green (attacking) */ case 8: color = tenm_map_color(61, 95, 13); break; /* red (immutable) */ case 9: color = tenm_map_color(95, 13, 68); break; /* player */ case 10: color = tenm_map_color(10, 75, 139); break; default: color = tenm_map_color(0, 0, 0); break; } temp = my->count[0] / 2; for (i = 0; i < my->count[1]; i++) { suffix = i * 4 + 4; if (tenm_draw_rectangle(((int) (my->count_d[0] + my->count_d[suffix + 0])) - temp, ((int) (my->count_d[1] + my->count_d[suffix + 1])) - temp, my->count[0], my->count[0], color) != 0) status = 1; } return status; } dangen-0.5/spqr/explosion.h0000644000175000017500000000056010276702737016610 0ustar00ooharaoohara00000000000000/* $Id: explosion.h,v 1.3 2004/07/06 02:51:14 oohara Exp $ */ #ifndef __DANGEN_EXPLOSION_H__ #define __DANGEN_EXPLOSION_H__ tenm_object *explosion_new(double x, double y, double dx, double dy, int size_debris, int number_debris, int color, double speed_debris, int life); #endif /* not __DANGEN_EXPLOSION_H__ */ dangen-0.5/spqr/flatdice.c0000644000175000017500000001112610276702737016336 0ustar00ooharaoohara00000000000000/* flatdice --- the dice that remember their last value * by Oohara Yuuma * $Id: flatdice.c,v 1.20 2005/07/06 13:26:10 oohara Exp $ */ #include /* malloc, rand */ #include #include "flatdice.h" /* return a random integer in [0, side - 1] * the return value is adjusted so that * * it is likely to differ from the last value * (this adjustment is strong if "repeat" is large) * * all possible values appear almost same times * (this adjustment is weak if "randomness" is large) */ flatdice * flatdice_new(int side, int randomness, int repeat) { int i; flatdice *new = NULL; /* sanity check */ if (side <= 0) { fprintf(stderr, "flatdice_new: side is non-positive (%d)\n", side); return NULL; } if (randomness <= 0) { fprintf(stderr, "flatdice_new: randomness is non-positive (%d)\n", randomness); return NULL; } if (repeat <= 0) { fprintf(stderr, "flatdice_new: repeat is non-positive (%d)\n", repeat); return NULL; } new = (flatdice *) malloc(sizeof(flatdice)); if (new == NULL) { fprintf(stderr, "flatdice_new: malloc(new) failed\n"); return NULL; } new->side = side; new->randomness = randomness; new->repeat = repeat; new->stock = NULL; new->last = -1; new->stock = (int *) malloc(sizeof(int) * side); if (new == NULL) { fprintf(stderr, "flatdice_new: malloc(new->stock) failed\n"); flatdice_delete(new); return NULL; } for (i = 0; i < side; i++) new->stock[i] = randomness; return new; } void flatdice_delete(flatdice *p) { if (p != NULL) { if (p->stock != NULL) { free(p->stock); p->stock = NULL; } free(p); } } /* return 1 (true) or 0 (false) */ int flatdice_valid(flatdice *p, int quiet) { int i; int total; /* sanity check */ if (p == NULL) { if (!quiet) fprintf(stderr, "flatdice_valid: p is NULL\n"); return 0; } if (p->side <= 0) { if (!quiet) fprintf(stderr, "flatdice_valid: p->side is non-positive (%d)\n", p->side); return 0; } if (p->randomness <= 0) { if (!quiet) fprintf(stderr, "flatdice_valid: p->randomness is non-positive (%d)\n", p->randomness); return 0; } if (p->repeat <= 0) { if (!quiet) fprintf(stderr, "flatdice_valid: p->repeat is non-positive (%d)\n", p->repeat); return 0; } if (p->stock == NULL) { if (!quiet) fprintf(stderr, "flatdice_valid: p->stock is NULL\n"); return 0; } total = 0; for (i = 0; i < p->side; i++) { if (p->stock[i] < 0) { if (!quiet) fprintf(stderr, "flatdice_valid: p->stock[%d] is negative (%d)\n", i, p->stock[i]); return 0; } if (i == p->last) total += p->stock[i]; else total += p->stock[i] * p->repeat; } if (total <= 0) { if (!quiet) fprintf(stderr, "flatdice_valid: total is non-positive (%d)\n", total); return 0; } return 1; } /* return [0, p->side - 1] on success, -1 on error */ int flatdice_next(flatdice *p) { int i; int total; int n1; int n2; int needed; int result = -1; /* sanity check */ if (p == NULL) { fprintf(stderr, "flatdice_next: p is NULL\n"); return -1; } if (!flatdice_valid(p, 0)) { fprintf(stderr, "flatdice_next: p is invalid\n"); return -1; } total = 0; for (i = 0; i < p->side; i++) { if (i == p->last) total += p->stock[i]; else total += p->stock[i] * p->repeat; } n1 = rand() % total + 1; n2 = 0; for (i = 0; i < p->side; i++) { if (((i == p->last) && (n2 + p->stock[i] >= n1)) || ((i != p->last) && (n2 + p->stock[i] * p->repeat >= n1))) { result = i; p->last = i; (p->stock[i])--; if (p->stock[i] < 0) p->stock[i] = 0; break; } if (i == p->last) n2 += p->stock[i]; else n2 += p->stock[i] * p->repeat; } needed = p->randomness; for (i = 0; i < p->side; i++) { if (needed > p->randomness - p->stock[i]) needed = p->randomness - p->stock[i]; } if (needed < 0) needed = 0; for (i = 0; i < p->side; i++) p->stock[i] += needed; return result; } /* return 0 on success, 1 on error */ int flatdice_reset(flatdice *p) { int i; /* sanity check */ if (p == NULL) { fprintf(stderr, "flatdice_reset: p is NULL\n"); return 1; } if (!flatdice_valid(p, 0)) { fprintf(stderr, "flatdice_reset: p is invalid\n"); return 1; } for (i = 0; i < p->side; i++) p->stock[i] = p->randomness; p->last = -1; return 0; } dangen-0.5/spqr/flatdice.h0000644000175000017500000000073410276702737016346 0ustar00ooharaoohara00000000000000/* $Id: flatdice.h,v 1.5 2005/07/06 12:35:11 oohara Exp $ */ #ifndef __FLATDICE_H__ #define __FLATDICE_H__ struct _flatdice { int side; int randomness; int repeat; int *stock; int last; }; typedef struct _flatdice flatdice; flatdice *flatdice_new(int side, int randomness, int repeat); void flatdice_delete(flatdice *p); int flatdice_valid(flatdice *p, int quiet); int flatdice_next(flatdice *p); int flatdice_reset(flatdice *p); #endif /* not __FLATDICE_H__ */ dangen-0.5/spqr/fragment.c0000644000175000017500000001502411625003517016354 0ustar00ooharaoohara00000000000000/* $Id: fragment.c,v 1.63 2011/08/23 20:02:23 oohara Exp $ */ #include /* malloc, rand */ #include #include "tenm_graphic.h" #include "tenm_math.h" #include "tenm_object.h" #include "const.h" #include "fragment.h" #define NEAR_ZERO 0.0001 static int fragment_act(tenm_object *my, const tenm_object *player); static int fragment_draw(tenm_object *my, int priority); tenm_object * fragment_new(double x, double y, double dx, double dy, double size_fragment, int number_fragment, int color, double speed_fragment, double speed_theta, int life) { int i; int suffix; int theta; int phi_axis; int phi_ellipse; int phi_fragment; double temp_speed; double length_axis; double length_ellipse; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; /* sanity check */ if (size_fragment < NEAR_ZERO) return NULL; if (number_fragment <= 0) return NULL; if (speed_fragment < NEAR_ZERO) return NULL; if (life <= 0) return NULL; count = (int *) malloc(sizeof(int) * 4); if (count == NULL) { fprintf(stderr, "fragment_new: malloc(count) failed\n"); return NULL; } count_d = (double *) malloc(sizeof(double) * (4 + 12 * number_fragment)); if (count_d == NULL) { fprintf(stderr, "fragment_new: malloc(count_d) failed\n"); free(count); return NULL; } /* list of count * [0] number of fragment * [1] color * [2] life * [3] time passed */ count[0] = number_fragment; count[1] = color; count[2] = life; count[3] = 0; /* list of count_d * [0] source x * [1] source y * [2] source dx * [3] source dy * [4--] fragment (x, y, dx, dy, x0, y0, * x_r1, x_r2, y_r1, y_r2, theta, dtheta) * (relative to source) */ count_d[0] = x; count_d[1] = y; count_d[2] = dx; count_d[3] = dy; for (i = 0; i < number_fragment; i++) { suffix = i * 12 + 4; theta = rand() % 360; temp_speed = (double) (6 + rand() % 95) / 100.0; count_d[suffix + 0] = 0.0; count_d[suffix + 1] = 0.0; count_d[suffix + 2] = speed_fragment * temp_speed * tenm_cos(theta); count_d[suffix + 3] = speed_fragment * temp_speed * tenm_sin(theta); phi_axis = rand() % 180; phi_ellipse = rand() % 360; phi_fragment = 45 + rand() % 46; length_axis = size_fragment * tenm_cos(phi_fragment); length_ellipse = size_fragment * tenm_sin(phi_fragment); count_d[suffix + 4] = length_axis * tenm_sin(phi_axis) * tenm_sin(phi_ellipse); count_d[suffix + 5] = length_axis * tenm_sin(phi_axis) * (-tenm_cos(phi_ellipse)); count_d[suffix + 6] = tenm_cos(phi_ellipse); count_d[suffix + 7] = -tenm_sin(phi_ellipse) * tenm_cos(phi_axis); count_d[suffix + 8] = tenm_sin(phi_ellipse); count_d[suffix + 9] = tenm_cos(phi_ellipse) * tenm_cos(phi_axis); count_d[suffix + 6] *= length_ellipse; count_d[suffix + 7] *= length_ellipse; count_d[suffix + 8] *= length_ellipse; count_d[suffix + 9] *= length_ellipse; count_d[suffix + 10] = 0.0; count_d[suffix + 11] = speed_theta - (double) (-15 + (rand() % 31)); } new = tenm_object_new("fragment", 0, 0, 0, x, y, 4, count, 4 + 12 * number_fragment, count_d, 0, NULL, (int (*)(tenm_object *, double)) NULL, NULL, (int (*)(tenm_object *, const tenm_object *)) (&fragment_act), (int (*)(tenm_object *, int)) (&fragment_draw)); if (new == NULL) { fprintf(stderr, "fragment_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); return NULL; } return new; } static int fragment_act(tenm_object *my, const tenm_object *player) { int i; int suffix; /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; (my->count[3])++; if (my->count[3] >= my->count[2]) { (my->count[0]) /= 2; my->count[3] = 0; } if (my->count[0] <= 0) return 1; /* fragment does not collide with anything, so let't move it here, * not in a separate move function */ my->count_d[0] += my->count_d[2]; my->count_d[1] += my->count_d[3]; for (i = 0; i < my->count[0]; i++) { suffix = i * 12 + 4; my->count_d[suffix + 0] += my->count_d[suffix + 2]; my->count_d[suffix + 1] += my->count_d[suffix + 3]; my->count_d[suffix + 10] += my->count_d[suffix + 11]; } return 0; } static int fragment_draw(tenm_object *my, int priority) { int i; int suffix; int status = 0; double a_x; double a_y; double b_x; double b_y; tenm_color color; /* sanity check */ if (my == NULL) return 0; if (priority != 0) return 0; switch (my->count[1]) { /* enemy shot */ case 0: color = tenm_map_color(99, 158, 79); color = tenm_map_color(99, 158, 114); break; case 1: color = tenm_map_color(99, 158, 114); color = tenm_map_color(99, 158, 138); break; case 2: color = tenm_map_color(79, 138, 158); color = tenm_map_color(99, 143, 158); break; case 3: color = tenm_map_color(79, 118, 158); color = tenm_map_color(99, 128, 158); break; case 4: color = tenm_map_color(118, 99, 158); break; case 5: color = tenm_map_color(142, 99, 158); break; /* dummy enemy shot */ case 6: color = tenm_map_color(158, 158, 158); break; /* enemy */ case 7: color = tenm_map_color(95, 47, 13); break; case 8: color = tenm_map_color(61, 95, 13); break; case 9: color = tenm_map_color(95, 13, 68); break; /* player */ case 10: color = tenm_map_color(10, 75, 139); break; default: color = tenm_map_color(0, 0, 0); break; } for (i = 0; i < my->count[0]; i++) { suffix = i * 12 + 4; a_x = my->count_d[0] + my->count_d[suffix + 0]; a_y = my->count_d[1] + my->count_d[suffix + 1]; b_x = my->count_d[suffix + 6] * tenm_cos((int) (my->count_d[suffix + 10])) + my->count_d[suffix + 7] * tenm_sin((int) (my->count_d[suffix + 10])); b_y = my->count_d[suffix + 8] * tenm_cos((int) (my->count_d[suffix + 10])) + my->count_d[suffix + 9] * tenm_sin((int) (my->count_d[suffix + 10])); b_x += my->count_d[suffix + 4]; b_y += my->count_d[suffix + 5]; b_x *= 0.5; b_y *= 0.5; if (tenm_draw_line((int) (a_x - b_x), (int) (a_y - b_y), (int) (a_x + b_x), (int) (a_y + b_y), 1, color) != 0) status = 1; } return status; } dangen-0.5/spqr/fragment.h0000644000175000017500000000064110276702737016373 0ustar00ooharaoohara00000000000000/* $Id: fragment.h,v 1.6 2003/08/13 16:33:59 oohara Exp $ */ #ifndef __DANGEN_FRAGMENT_H__ #define __DANGEN_FRAGMENT_H__ tenm_object *fragment_new(double x, double y, double dx, double dy, double size_fragment, int number_fragment, int color, double speed_fragment, double speed_theta, int life); #endif /* not __DANGEN_FRAGMENT_H__ */ dangen-0.5/spqr/gosanpachi.c0000644000175000017500000003263411625004112016663 0ustar00ooharaoohara00000000000000/* $Id: gosanpachi.c,v 1.38 2011/08/23 20:06:34 oohara Exp $ */ /* [very easy] Gosanpachi */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "stage-clear.h" #include "score.h" #include "gosanpachi.h" static int gosanpachi_move(tenm_object *my, double turn_per_frame); static int gosanpachi_hit(tenm_object *my, tenm_object *your); static void gosanpachi_next(tenm_object *my); static int gosanpachi_act(tenm_object *my, const tenm_object *player); static int gosanpachi_draw(tenm_object *my, int priority); static int gosanpachi_green(const tenm_object *my); tenm_object * gosanpachi_new(void) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = (double) (WINDOW_WIDTH / 2); double y = -35.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "gosanpachi_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 48.0, y - 36.0, x + 48.0, y + 36.0, x - 48.0, y + 36.0, x - 48.0, y - 36.0); if (p[0] == NULL) { fprintf(stderr, "gosanpachi_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 5); if (count == NULL) { fprintf(stderr, "gosanpachi_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 4); if (count_d == NULL) { fprintf(stderr, "gosanpachi_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] life mode * [3] life timer * [4] "was green when dead" flag */ /* list of count_d * [0] speed x * [1] speed y * [2] shoot aim x * [3] shoot aim y */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 0; count[4] = 0; count_d[0] = 0.0; count_d[1] = (((double) (WINDOW_HEIGHT / 4)) - y) / 60.0; count_d[2] = 0.0; count_d[3] = 1.0; new = tenm_object_new("Gosanpachi", ATTR_BOSS, ATTR_PLAYER_SHOT, 538, x, y, 5, count, 4, count_d, 1, p, (int (*)(tenm_object *, double)) (&gosanpachi_move), (int (*)(tenm_object *, tenm_object *)) (&gosanpachi_hit), (int (*)(tenm_object *, const tenm_object *)) (&gosanpachi_act), (int (*)(tenm_object *, int)) (&gosanpachi_draw)); if (new == NULL) { fprintf(stderr, "gosanpachi_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int gosanpachi_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "gosanpachi_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "gosanpachi_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int gosanpachi_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "gosanpachi_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "gosanpachi_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if (my->count[2] != 1) return 0; deal_damage(my, your, 0); if (gosanpachi_green(my)) add_chain(my, your); my->count[1] = 2; if (my->hit_point <= 0) { add_score(5000); set_background(1); gosanpachi_next(my); return 0; } return 0; } static void gosanpachi_next(tenm_object *my) { int n; /* sanity check */ if (my == NULL) { fprintf(stderr, "gosanpachi_next: my is NULL\n"); return; } tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy), 0); /* set "was green" flag before we change the life mode */ if (gosanpachi_green(my)) { n = 8; my->count[4] = 1; } else { n = 7; my->count[4] = 0; } tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 5000, n, 10.0, 6)); my->count[2] = 2; my->count[3] = 0; my->count[1] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.5; /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ tenm_mass_delete(my->mass); my->mass = NULL; } static int gosanpachi_act(tenm_object *my, const tenm_object *player) { int t; int i; int theta; double result[2]; double v[2]; /* sanity check */ if (my == NULL) { fprintf(stderr, "gosanpachi_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; (my->count[3])++; /* encounter */ if (my->count[2] == 0) { if (my->count[3] >= 60) { my->count[2] = 1; my->count[3] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; return 0; } return 0; } /* dead */ if (my->count[2] == 2) { if (gosanpachi_green(my)) i = 8; else i = 7; if ((my->count[3] >= 30) && (my->count[3] <= 75) && (my->count[3] % 15 == 0)) { theta = rand() % 360; tenm_table_add(explosion_new(my->x + 30.0 * tenm_cos(theta), my->y + 30.0 * tenm_sin(theta), 0.0, 0.0, 2, 300, i, 5.0, 8)); } if (my->count[3] > 120) { tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 3000, i, 10.0, 8)); tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 30.0, 100, i, 4.0, 0.0, 16)); tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 50.0, 30, i, 2.5, 0.0, 12)); tenm_table_add(stage_clear_new(100)); return 1; } return 0; } my->count_d[0] = 0.0; my->count_d[1] = 0.0; /* self-destruction */ if ((my->count[2] == 1) && (my->count[3] >= 3900)) { set_background(2); clear_chain(); gosanpachi_next(my); return 0; } /* shoot */ if (my->count[2] != 1) return 0; if (((my->count[3] >= 30) && (my->count[3] < 450)) || ((my->count[3] >= 1900) && (my->count[3] < 2320))) { if (my->count[3] < 450) t = my->count[3] - 30; else t = my->count[3] - 1900; if (t % 7 == 0) { tenm_table_add(laser_angle_new(my->x + 48.0, my->y - 36.0, 4.0 + ((double) (rand() % 8)) / 4.0, 140 + rand() % 36, 25.0, 2)); tenm_table_add(laser_angle_new(my->x - 48.0, my->y - 36.0, 4.0 + ((double) (rand() % 8)) / 4.0, 40 - rand() % 36, 25.0, 2)); } if ((t % 7 == 0) && (t % 21 != 0)) { tenm_table_add(normal_shot_point_new(my->x, my->y, 4.0, player->x, player->y, 0)); } } if (((my->count[3] >= 500) && (my->count[3] < 1214)) || ((my->count[3] >= 2370) && (my->count[3] < 3084))) { if (my->count[3] < 1214) t = my->count[3] - 500; else t = my->count[3] - 2370; if (t % 17 == 0) { tenm_table_add(laser_point_new(my->x + 12.0, my->y - 51.0, 4.0, my->x, my->y - 46.0, 25.0, 0)); tenm_table_add(laser_point_new(my->x + 84.0, my->y - 21.0, 4.0, my->x + 72.0, my->y - 16.0, 25.0, 0)); tenm_table_add(laser_point_new(my->x - 12.0, my->y - 51.0, 4.0, my->x, my->y - 46.0, 25.0, 0)); tenm_table_add(laser_point_new(my->x - 84.0, my->y - 21.0, 4.0, my->x - 72.0, my->y - 16.0, 25.0, 0)); if (t >= 119) { tenm_table_add(laser_point_new(my->x + 48.0, my->y - 36.0, 4.0, my->x + 43.0, my->y - 24.0, 25.0, 0)); tenm_table_add(laser_point_new(my->x - 48.0, my->y - 36.0, 4.0, my->x - 43.0, my->y - 24.0, 25.0, 0)); } } if ((t >= 238) && (t % 7 == 0)) { tenm_table_add(normal_shot_angle_new(my->x, my->y + 14.0, 4.0, 23 + rand() % 135, 4)); tenm_table_add(normal_shot_angle_new(my->x, my->y + 14.0, 4.0, -(23 + rand() % 135), 4)); } } if (((my->count[3] >= 1300) && (my->count[3] <= 1840)) || ((my->count[3] >= 3170) && (my->count[3] <= 3710))) { if (my->count[3] <= 1840) t = my->count[3] - 1300; else t = my->count[3] - 3170; if (t == 0) { my->count_d[2] = (double) (WINDOW_WIDTH / 2); my->count_d[3] = (double) (WINDOW_HEIGHT / 2); my->count_d[2] += (double) (-5 + rand() % 11); my->count_d[3] += (double) (-5 + rand() % 11); } theta = -t * 2; if (my->count[3] >= 3170) theta *= -1; my->count_d[0] = (((double) (WINDOW_WIDTH / 2)) - 48.0) * tenm_sin(theta); my->count_d[0] += ((double) (WINDOW_WIDTH / 2)); my->count_d[0] -= my->x; my->count_d[1] = 0.0; if (t % 7 == 0) { for (i = 0; i < 360; i += 45) { v[0] = my->count_d[2] - my->x; v[1] = my->count_d[3] - my->y; result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, i); tenm_table_add(normal_shot_point_new(my->x, my->y, 4.0, my->x + result[0], my->y + result[1], 1)); } } } return 0; } static int gosanpachi_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; /* sanity check */ if (my == NULL) { fprintf(stderr, "gosanpachi_draw: my is NULL\n"); return 0; } /* dead enemy has low priority */ if (((my->count[2] <= 1) && (priority != 0)) || ((my->count[2] > 1) && (priority != -1))) return 0; /* body */ if (gosanpachi_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 1) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (tenm_draw_line((int) (my->x + 12.0), (int) (my->y - 51.0), (int) (my->x + 84.0), (int) (my->y - 21.0), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 12.0), (int) (my->y - 51.0), (int) (my->x - 84.0), (int) (my->y - 21.0), 1, color) != 0) status = 1; /* core */ if (tenm_draw_line((int) (my->x + 48.0), (int) (my->y - 36.0), (int) (my->x + 48.0), (int) (my->y + 36.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 48.0), (int) (my->y + 36.0), (int) (my->x - 48.0), (int) (my->y + 36.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 48.0), (int) (my->y + 36.0), (int) (my->x - 48.0), (int) (my->y - 36.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 48.0), (int) (my->y - 36.0), (int) (my->x + 48.0), (int) (my->y - 36.0), 3, color) != 0) status = 1; /* hit point stat */ if (my->count[2] == 1) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 10, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "gosanpachi_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int gosanpachi_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if ((my->count[2] == 1) && (my->count[3] >= 1300) && (my->count[3] < 3870)) return 1; if ((my->count[2] == 2) && (my->count[4] != 0)) return 1; return 0; } dangen-0.5/spqr/gosanpachi.h0000644000175000017500000000035010276702737016701 0ustar00ooharaoohara00000000000000/* $Id: gosanpachi.h,v 1.1 2004/07/27 13:59:00 oohara Exp $ */ #ifndef __DANGEN_GOSANPACHI_H__ #define __DANGEN_GOSANPACHI_H__ #include "tenm_object.h" tenm_object *gosanpachi_new(void); #endif /* not __DANGEN_GOSANPACHI_H__ */ dangen-0.5/spqr/hatsuda.c0000644000175000017500000013525110276702737016222 0ustar00ooharaoohara00000000000000/* $Id: hatsuda.c,v 1.231 2005/07/12 20:34:49 oohara Exp $ */ /* [hard] 0x82da3104 */ /* read: hatsuda satoshi */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "stage-clear.h" #include "score.h" #include "ship.h" #include "hatsuda.h" #define NEAR_ZERO 0.0001 static int hatsuda_move(tenm_object *my, double turn_per_frame); static int hatsuda_hit(tenm_object *my, tenm_object *your); static void hatsuda_next(tenm_object *my); static int hatsuda_signal_shroud(tenm_object *my, int n); static int hatsuda_act(tenm_object *my, const tenm_object *player); static void hatsuda_act_reflect(tenm_object *my, const tenm_object *player, int direction); static int hatsuda_draw(tenm_object *my, int priority); static int hatsuda_green(const tenm_object *my); static tenm_object *hatsuda_wall_triangle_new(double y, double size, double speed, int n, int t); static int hatsuda_wall_triangle_move(tenm_object *my, double turn_per_frame); static int hatsuda_wall_triangle_act(tenm_object *my, const tenm_object *player); static double hatsuda_wall_triangle_edge(int t); static int hatsuda_wall_triangle_draw(tenm_object *my, int priority); static tenm_object *hatsuda_wall_reflect_new(double x, double y, double speed_x, double speed_y, int number_reflect); static int hatsuda_wall_reflect_move(tenm_object *my, double turn_per_frame); static int hatsuda_wall_reflect_act(tenm_object *my, const tenm_object *player); static int hatsuda_wall_reflect_draw(tenm_object *my, int priority); static tenm_object *hatsuda_shroud_new(int n); static int hatsuda_shroud_move(tenm_object *my, double turn_per_frame); static int hatsuda_shroud_act(tenm_object *my, const tenm_object *player); static int hatsuda_shroud_draw(tenm_object *my, int priority); tenm_object * hatsuda_new(void) { int i; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = (double) (WINDOW_WIDTH / 2); double y = ((double) (WINDOW_HEIGHT)) - 286.0 * tenm_cos(45); count = (int *) malloc(sizeof(int) * 8); if (count == NULL) { fprintf(stderr, "hatsuda_new: malloc(count) failed\n"); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "hatsuda_new: malloc(count_d) failed\n"); free(count); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] move mode * [3] move timer * [4] "was green when killed" flag * [5 -- 7] shroud index */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 0; count[4] = 0; for (i = 0; i < 3; i++) count[5 + i] = -1; count_d[0] = 0.0; count_d[1] = 0.0; new = tenm_object_new("0x82da3104", ATTR_BOSS, ATTR_PLAYER_SHOT, 400, x, y, 8, count, 2, count_d, 0, NULL, (int (*)(tenm_object *, double)) (&hatsuda_move), (int (*)(tenm_object *, tenm_object *)) (&hatsuda_hit), (int (*)(tenm_object *, const tenm_object *)) (&hatsuda_act), (int (*)(tenm_object *, int)) (&hatsuda_draw)); if (new == NULL) { fprintf(stderr, "hatsuda_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); return NULL; } return new; } static int hatsuda_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "hatsuda_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "hatsuda_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int hatsuda_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "hatsuda_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "hatsuda_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if ((my->count[2] != 1) && (my->count[2] != 3) && (my->count[2] != 5)) return 0; if ((my->count[2] == 5) && (my->count[3] < 290)) return 0; deal_damage(my, your, 0); if (hatsuda_green(my)) add_chain(my, your); my->count[1] = 2; if (my->hit_point <= 0) { if (my->count[2] == 1) add_score(10000); else if (my->count[2] == 3) add_score(15000); else if (my->count[2] == 5) add_score(35000); set_background(1); hatsuda_next(my); return 0; } return 0; } static void hatsuda_next(tenm_object *my) { int n; int i; /* sanity check */ if (my == NULL) { fprintf(stderr, "hatsuda_next: my is NULL\n"); return; } if ((my->count[2] != 1) && (my->count[2] != 3) && (my->count[2] != 5)) return; tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy), 0); /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ tenm_mass_delete(my->mass); my->mass = NULL; /* set "was green" flag before we change the life mode */ if (hatsuda_green(my)) { n = 8; my->count[4] = 1; } else { n = 7; my->count[4] = 0; } if (my->count[2] == 1) { tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 3000, n, 10.0, 8)); tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 2, 800, n, 6.0, 8)); my->hit_point = 750; my->count[2] = 2; my->count[3] = 0; my->count[1] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[2] == 3) { tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 3000, n, 10.0, 8)); tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 30.0, 100, n, 4.0, 0.0, 16)); tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 50.0, 30, n, 2.5, 0.0, 12)); my->hit_point = 400; my->count[2] = 4; my->count[3] = 0; my->count[1] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[2] == 5) { tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 5000, n, 10.0, 6)); my->count[2] = 6; my->count[3] = 0; my->count[1] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.5; for (i = 0; i < 3; i++) if (my->count[5 + i] >= 0) tenm_table_apply(my->count[5 + i], (int (*)(tenm_object *, int)) (&hatsuda_signal_shroud), 0); } } static int hatsuda_signal_shroud(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "0x82da3104 shroud") != 0) return 0; tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 1000, 9, 4.0, 6)); tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 30.0, 100, 9, 4.0, 0.0, 16)); tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 50.0, 30, 9, 2.5, 0.0, 12)); return 1; } static int hatsuda_act(tenm_object *my, const tenm_object *player) { int theta; int i; tenm_primitive **p = NULL; int n; /* sanity check */ if (my == NULL) { fprintf(stderr, "hatsuda_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; (my->count[3])++; /* speed change */ if (my->count[2] == 1) { my->count_d[0] = hatsuda_wall_triangle_edge(my->count[3]) - my->x; my->count_d[1] = 0.0; } /* encounter */ if (my->count[2] == 0) { if (my->count[3] == 60) { my->count_d[0] = (((double) (WINDOW_WIDTH / 2)) - my->x) / 60.0; my->count_d[1] = (40.0 - my->y) / 60.0; return 0; } if (my->count[3] >= 120) { my->count[2] = 1; my->count[3] = 0; my->count[4] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "hatsuda_act: malloc(p) failed (form 1)\n"); return 0; } p[0] = (tenm_primitive *) tenm_circle_new(my->x, my->y, 25.0); if (p[0] == NULL) { fprintf(stderr, "hatsuda_act: cannot set p[0] (form 1)\n"); free(p); return 0; } my->mass = tenm_mass_new(1, p); if (my->mass == NULL) { fprintf(stderr, "hatsuda_act: tenm_mass_new failed (form 1)\n"); (p[0])->delete(p[0]); free(p); return 0; } return 0; } return 0; } else if (my->count[2] == 2) { if (my->count[3] == 30) { my->count_d[0] = (((double) (WINDOW_WIDTH / 2)) - my->x) / 60.0; my->count_d[1] = (((double) (WINDOW_HEIGHT / 2)) - my->y) / 60.0; return 0; } if (my->count[3] == 90) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; return 0; } if (my->count[3] >= 120) { my->count[2] = 3; my->count[3] = 0; my->count[4] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "hatsuda_act: malloc(p) failed (form 2)\n"); return 0; } p[0] = (tenm_primitive *) tenm_polygon_new(4, my->x + 50.0 * tenm_cos(45), my->y + 50.0 * tenm_cos(45), my->x - 50.0 * tenm_cos(15), my->y + 50.0 * tenm_cos(45), my->x - 50.0 * tenm_cos(15), my->y - 50.0 * tenm_cos(15), my->x + 50.0 * tenm_cos(45), my->y - 50.0 * tenm_cos(15)); if (p[0] == NULL) { fprintf(stderr, "hatsuda_act: cannot set p[0] (form 2)\n"); free(p); return 0; } my->mass = tenm_mass_new(1, p); if (my->mass == NULL) { fprintf(stderr, "hatsuda_act: tenm_mass_new failed (form 2)\n"); (p[0])->delete(p[0]); free(p); return 0; } return 0; } return 0; } else if (my->count[2] == 4) { if (my->count[3] >= 90) { my->count[2] = 5; my->count[3] = 0; my->count[4] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "hatsuda_act: malloc(p) failed (form 3)\n"); return 0; } p[0] = (tenm_primitive *) tenm_polygon_new(3, my->x + 50.0 * tenm_cos(45), my->y + 50.0 * tenm_sin(45), my->x + 50.0 * tenm_cos(165), my->y + 50.0 * tenm_sin(165), my->x + 50.0 * tenm_cos(285), my->y + 50.0 * tenm_sin(285)); if (p[0] == NULL) { fprintf(stderr, "hatsuda_act: cannot set p[0] (form 3)\n"); free(p); return 0; } my->mass = tenm_mass_new(1, p); if (my->mass == NULL) { fprintf(stderr, "hatsuda_act: tenm_mass_new failed (form 3)\n"); (p[0])->delete(p[0]); free(p); return 0; } return 0; } return 0; } /* dead */ if (my->count[2] == 6) { if (hatsuda_green(my)) i = 8; else i = 7; if ((my->count[3] >= 30) && (my->count[3] <= 75) && (my->count[3] % 15 == 0)) { theta = rand() % 360; tenm_table_add(explosion_new(my->x + 30.0 * tenm_cos(theta), my->y + 30.0 * tenm_sin(theta), 0.0, 0.0, 2, 300, i, 5.0, 8)); } if (my->count[3] > 120) { tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 3000, i, 10.0, 8)); tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 30.0, 100, i, 4.0, 0.0, 16)); tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 50.0, 30, i, 2.5, 0.0, 12)); tenm_table_add(stage_clear_new(100)); return 1; } return 0; } /* self-destruction */ if (((my->count[2] == 1) && (my->count[3] >= 2052)) || ((my->count[2] == 3) && (my->count[3] >= 1850)) || ((my->count[2] == 5) && (my->count[3] >= 2230))) { set_background(2); clear_chain(); hatsuda_next(my); return 0; } /* shoot */ if ((my->count[2] == 1) && (my->count[3] <= 1872)) { if (my->count[3] % 17 == 0) { tenm_table_add(laser_point_new(my->x, my->y, 5.0, player->x, player->y, 25.0, 4)); } if (my->count[3] % 26 == 13) n = 1; else n = 0; if (my->count[3] % 312 >= 156) n = 1 - n; switch (my->count[3] % 156) { case 13: tenm_table_add(hatsuda_wall_triangle_new(40.0, 40.0, 5.5, n, my->count[3])); break; case 26: tenm_table_add(hatsuda_wall_triangle_new(200.0, 40.0, -5.5, n, my->count[3])); break; case 39: if (my->count[3] > 312) tenm_table_add(hatsuda_wall_triangle_new(360.0, 40.0, 5.5, n, my->count[3])); break; case 52: tenm_table_add(hatsuda_wall_triangle_new(120.0, 40.0, -5.5, n, my->count[3])); break; case 65: tenm_table_add(hatsuda_wall_triangle_new(280.0, 40.0, 5.5, n, my->count[3])); break; case 78: if (my->count[3] > 312) tenm_table_add(hatsuda_wall_triangle_new(440.0, 40.0, -5.5, n, my->count[3])); break; case 91: tenm_table_add(hatsuda_wall_triangle_new(40.0, 40.0, -5.5, n, my->count[3])); break; case 104: tenm_table_add(hatsuda_wall_triangle_new(200.0, 40.0, 5.5, n, my->count[3])); break; case 117: if (my->count[3] > 312) tenm_table_add(hatsuda_wall_triangle_new(360.0, 40.0, -5.5, n, my->count[3])); break; case 130: tenm_table_add(hatsuda_wall_triangle_new(120.0, 40.0, 5.5, n, my->count[3])); break; case 143: if (my->count[3] > 312) tenm_table_add(hatsuda_wall_triangle_new(280.0, 40.0, -5.5, 0, my->count[3])); break; case 0: if (my->count[3] > 312) tenm_table_add(hatsuda_wall_triangle_new(440.0, 40.0, 5.5, n, my->count[3])); break; default: break; } } if ((my->count[2] == 3) && (my->count[3] <= 1720)) { if (my->count[3] % 86 == 0) { hatsuda_act_reflect(my, player, 3); hatsuda_act_reflect(my, player, 7); } if (my->count[3] % 86 == 43) { hatsuda_act_reflect(my, player, 9); hatsuda_act_reflect(my, player, 1); } if ((my->count[3] > 172) && (my->count[3] % 7 == 0)) { theta = -90 + (my->count[3] -172) * (-6); tenm_table_add(laser_angle_new(my->x, my->y, 4.0, theta, 25.0, 3)); tenm_table_add(laser_angle_new(my->x, my->y, 2.5, theta - 5, 25.0, 3)); tenm_table_add(laser_angle_new(my->x, my->y, 2.5, theta + 5, 25.0, 3)); tenm_table_add(laser_angle_new(my->x, my->y, 6.0, theta - 11, 25.0, 3)); tenm_table_add(laser_angle_new(my->x, my->y, 6.0, theta + 11, 25.0, 3)); } } if (my->count[2] == 5) { if (my->count[3] == 30) for (i = 0; i < 3; i++) my->count[5 + i] = tenm_table_add(hatsuda_shroud_new(i)); if ((my->count[3] >= 530) && (my->count[3] <= 2100) && (my->count[3] % 5 == 0)) tenm_table_add(normal_shot_point_new(my->x, my->y, 7.0, player->x + (double) ((rand() % 151) - 75), player->y + (double) ((rand() % 151) - 75), 4)); } return 0; } /* reflection shot * direction * 789 * 4*6 * 123 */ static void hatsuda_act_reflect(tenm_object *my, const tenm_object *player, int direction) { double x_aim; double y_aim; int number_reflect; double dx; double dy; double length; /* sanity check */ if (my == NULL) { fprintf(stderr, "hatsuda_act_reflect: my is NULL\n"); return; } if (player == NULL) return; if ((direction < 1) || (direction > 9) || (direction == 5)) { fprintf(stderr, "hatsuda_act_reflect: strange direction(%d)\n", direction); return; } x_aim = player->x; y_aim = player->y; number_reflect = 0; if ((direction == 7) || (direction == 4) || (direction == 1)) { x_aim = -x_aim; number_reflect++; } if ((direction == 9) || (direction == 6) || (direction == 3)) { x_aim = 2.0 * ((double) WINDOW_WIDTH) - x_aim; number_reflect++; } if ((direction == 1) || (direction == 2) || (direction == 3)) { y_aim = -y_aim; number_reflect++; } if ((direction == 7) || (direction == 8) || (direction == 9)) { y_aim = 2.0 * ((double) WINDOW_HEIGHT) - y_aim; number_reflect++; } dx = x_aim - my->x; dy = y_aim - my->y; length = tenm_sqrt((int) (dx * dx + dy * dy)); if (length < NEAR_ZERO) length = 1.0; tenm_table_add(hatsuda_wall_reflect_new(my->x, my->y, 6.0 * dx / length, 6.0 * dy / length, number_reflect)); } static int hatsuda_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; double x; int theta; int i; double c; double length; /* sanity check */ if (my == NULL) { fprintf(stderr, "hatsuda_draw: my is NULL\n"); return 0; } /* decoration */ if (priority == 0) { if (hatsuda_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(181, 190, 92); else color = tenm_map_color(157, 182, 123); } else { if (my->count[1] >= 1) color = tenm_map_color(200, 164, 92); else color = tenm_map_color(182, 147, 123); } if (my->count[2] == 0) { if (my->count[3] <= 60) { c = ((double) (my->count[3])) / 60.0; for (i = 0; i < 360; i += 120) { if (tenm_draw_line((int) (my->x + 286.0 * tenm_cos(45 + i)), (int) (my->y + 286.0 * tenm_sin(45 + i)), (int) (my->x + 286.0 * tenm_cos(45 + i) * (1.0 - c) + 286.0 * tenm_cos(165 + i) * c), (int) (my->y + 286.0 * tenm_sin(45 + i) * (1.0 - c) + 286.0 * tenm_sin(165 + i) * c), 1, color)) status = 1; } } else if (my->count[3] <= 120) { c = ((double) (my->count[3] - 60)) / 60.0; length = 286.0 * (1.0 - c) + 50.0 * c; for (i = 0; i < 360; i += 120) { theta = 45 + i + (my->count[3] - 60) * 6; if (tenm_draw_line((int) (my->x + length * tenm_cos(theta)), (int) (my->y + length * tenm_sin(theta)), (int) (my->x + length * tenm_cos(theta + 120)), (int) (my->y + length * tenm_sin(theta + 120)), 1, color)) status = 1; } } } else if ((my->count[2] == 1) || (my->count[2] == 3) || (my->count[2] == 4)) { for (i = 0; i < 360; i += 120) { if (tenm_draw_line((int) (my->x + 50.0 * tenm_cos(45 + i)), (int) (my->y + 50.0 * tenm_sin(45 + i)), (int) (my->x + 50.0 * tenm_cos(165 + i)), (int) (my->y + 50.0 * tenm_sin(165 + i)), 1, color)) status = 1; } } else if (my->count[2] == 2) { for (i = 0; i < 360; i += 120) { if ((my->count[3] < 30) || (my->count[3] >= 90)) theta = 45 + i; else theta = 45 + i + (my->count[3] - 30) * 6; if (tenm_draw_line((int) (my->x + 50.0 * tenm_cos(theta)), (int) (my->y + 50.0 * tenm_sin(theta)), (int) (my->x + 50.0 * tenm_cos(theta + 120)), (int) (my->y + 50.0 * tenm_sin(theta + 120)), 1, color)) status = 1; } } if (my->count[2] == 1) { color = tenm_map_color(158, 158, 158); x = hatsuda_wall_triangle_edge(my->count[3]); if (tenm_draw_line((int) x, 0, (int) x, WINDOW_HEIGHT, 1, color)) status = 1; } if ((my->count[2] == 2) &&(my->count[3] > 90) && (my->count[3] <= 120)) { color = tenm_map_color(95, 47, 13); length = 50.0 + ((double) (120 - my->count[3])) * 3.0; if (tenm_draw_line((int) (my->x + length * tenm_cos(45)), (int) (my->y + length * tenm_cos(45)), (int) (my->x - length * tenm_cos(15)), (int) (my->y + length * tenm_cos(45)), 1, color)) status = 1; if (tenm_draw_line((int) (my->x - length * tenm_cos(15)), (int) (my->y + length * tenm_cos(45)), (int) (my->x - length * tenm_cos(15)), (int) (my->y - length * tenm_cos(15)), 1, color)) status = 1; if (tenm_draw_line((int) (my->x - length * tenm_cos(15)), (int) (my->y - length * tenm_cos(15)), (int) (my->x + length * tenm_cos(45)), (int) (my->y - length * tenm_cos(15)), 1, color)) status = 1; if (tenm_draw_line((int) (my->x + length * tenm_cos(45)), (int) (my->y - length * tenm_cos(15)), (int) (my->x + length * tenm_cos(45)), (int) (my->y + length * tenm_cos(45)), 1, color)) status = 1; } if ((my->count[2] == 4) &&(my->count[3] > 30) && (my->count[3] <= 90)) { color = tenm_map_color(95, 47, 13); length = 50.0 + ((double) (90 - my->count[3])) * 3.0; for (i = 0; i < 360; i += 120) { theta = 45 + i + (my->count[3] - 30) * 6; if (tenm_draw_line((int) (my->x + length * tenm_cos(theta)), (int) (my->y + length * tenm_sin(theta)), (int) (my->x + length * tenm_cos(theta + 120)), (int) (my->y + length * tenm_sin(theta + 120)), 1, color)) status = 1; } } } /* body */ /* dead enemy has low priority */ if (((my->count[2] <= 1) && (priority == 0)) || ((my->count[2] > 1) && (priority == -1))) { if (hatsuda_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 1) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (my->count[2] == 1) { if (tenm_draw_circle((int) (my->x), (int) (my->y), 25, 3, color) != 0) status = 1; } else if (my->count[2] == 3) { length = 50.0; if (tenm_draw_line((int) (my->x + length * tenm_cos(45)), (int) (my->y + length * tenm_cos(45)), (int) (my->x - length * tenm_cos(15)), (int) (my->y + length * tenm_cos(45)), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - length * tenm_cos(15)), (int) (my->y + length * tenm_cos(45)), (int) (my->x - length * tenm_cos(15)), (int) (my->y - length * tenm_cos(15)), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - length * tenm_cos(15)), (int) (my->y - length * tenm_cos(15)), (int) (my->x + length * tenm_cos(45)), (int) (my->y - length * tenm_cos(15)), 3, color)) status = 1; if (tenm_draw_line((int) (my->x + length * tenm_cos(45)), (int) (my->y - length * tenm_cos(15)), (int) (my->x + length * tenm_cos(45)), (int) (my->y + length * tenm_cos(45)), 3, color)) status = 1; } else if ((my->count[2] == 5) || (my->count[2] == 6)) { length = 50.0; for (i = 0; i < 360; i += 120) { theta = 45 + i; if (tenm_draw_line((int) (my->x + length * tenm_cos(theta)), (int) (my->y + length * tenm_sin(theta)), (int) (my->x + length * tenm_cos(theta + 120)), (int) (my->y + length * tenm_sin(theta + 120)), 3, color)) status = 1; } } } /* hit point stat */ if ((priority == 0) &&((my->count[2] == 1) || (my->count[2] == 3) || ((my->count[2] == 5) && (my->count[3] >= 290)))) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 5, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "hatsuda_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int hatsuda_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if ((my->count[2] == 1) && (my->count[3] > 312) && (my->count[3] < 2022)) return 1; if ((my->count[2] == 2) && (my->count[4] != 0) && (my->count[3] < 30)) return 1; if ((my->count[2] == 3) && (my->count[3] > 172) && (my->count[3] < 1820)) return 1; if ((my->count[2] == 4) && (my->count[4] != 0) && (my->count[3] < 30)) return 1; if ((my->count[2] == 5) && (my->count[3] >= 530) && (my->count[3] < 2200)) return 1; if ((my->count[2] == 6) && (my->count[4] != 0)) return 1; return 0; } static tenm_object * hatsuda_wall_triangle_new(double y, double size, double speed, int n, int t) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x; /* sanity check */ if (size < NEAR_ZERO) { fprintf(stderr, "hatsuda_wall_triangle_new: size is non-positive " "(%f)\n", size); return NULL; } if ((n < 0) || (n > 1)) { fprintf(stderr, "hatsuda_wall_triangle_new: strange n (%d)\n", n); return NULL; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "hatsuda_wall_triangle_new: malloc(p) failed\n"); return NULL; } if (speed > 0.0) x = 1.0 - size; else x = ((double) (WINDOW_WIDTH)) - 1.0 + size; if (n == 0) { p[0] = (tenm_primitive *) tenm_polygon_new(3, x - size, y - size, x - size, y + size, x + size, y + size); } else { p[0] = (tenm_primitive *) tenm_polygon_new(3, x + size, y - size, x + size, y + size, x - size, y + size); } if (p[0] == NULL) { fprintf(stderr, "hatsuda_wall_triangle_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 6); if (count == NULL) { fprintf(stderr, "hatsuda_wall_triangle_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 3); if (count_d == NULL) { fprintf(stderr, "hatsuda_wall_triangle_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] n * [1] move mode * [2] move timer */ /* list of count_d * [0] speed x * [1] speed y * [2] size */ count[0] = n; count[1] = 0; count[2] = t; count_d[0] = speed; count_d[1] = 0.0; count_d[2] = size; new = tenm_object_new("0x82da3104 wall triangle", ATTR_ENEMY | ATTR_OPAQUE, 0, 1, x, y, 6, count, 3, count_d, 1, p, (int (*)(tenm_object *, double)) (&hatsuda_wall_triangle_move), (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&hatsuda_wall_triangle_act), (int (*)(tenm_object *, int)) (&hatsuda_wall_triangle_draw)); if (new == NULL) { fprintf(stderr, "hatsuda_wall_triangle_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int hatsuda_wall_triangle_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "hatsuda_wall_triangle_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "hatsuda_wall_triangle_move: " "strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); if (!in_window_object(my)) return 1; return 0; } static int hatsuda_wall_triangle_act(tenm_object *my, const tenm_object *player) { double edge_x; /* sanity check */ if (my == NULL) { fprintf(stderr, "hatsuda_wall_triangle_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[2])++; if (my->count[1] == 0) { edge_x = hatsuda_wall_triangle_edge(my->count[2]); if ((my->x + my->count_d[2] >= edge_x) && (my->x - my->count_d[2] <= edge_x)) { my->count[1] = 1; my->count[2] = 0; if (my->count_d[0] > 0.0) my->count_d[1] = my->count_d[0]; else my->count_d[1] = -my->count_d[0]; if (my->y - my->count_d[2] > player->y) my->count_d[1] *= -1.0; my->count_d[0] = 0.0; } } return 0; } static double hatsuda_wall_triangle_edge(int t) { if (t < 180) return ((double) (WINDOW_WIDTH / 2)); return ((double) (WINDOW_WIDTH / 2)) + ((double) (WINDOW_WIDTH / 3)) * tenm_sin(t * 2); } static int hatsuda_wall_triangle_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; double size; /* sanity check */ if (my == NULL) { fprintf(stderr, "hatsuda_wall_triangle_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; /* body */ color = tenm_map_color(95, 13, 68); size = my->count_d[2]; if (my->count[0] == 0) { if (tenm_draw_line((int) (my->x - size), (int) (my->y - size), (int) (my->x - size), (int) (my->y + size), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - size), (int) (my->y + size), (int) (my->x + size), (int) (my->y + size), 3, color)) status = 1; if (tenm_draw_line((int) (my->x + size), (int) (my->y + size), (int) (my->x - size), (int) (my->y - size), 3, color)) status = 1; } else { if (tenm_draw_line((int) (my->x + size), (int) (my->y - size), (int) (my->x + size), (int) (my->y + size), 3, color)) status = 1; if (tenm_draw_line((int) (my->x + size), (int) (my->y + size), (int) (my->x - size), (int) (my->y + size), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - size), (int) (my->y + size), (int) (my->x + size), (int) (my->y - size), 3, color)) status = 1; } return status; } static tenm_object * hatsuda_wall_reflect_new(double x, double y, double speed_x, double speed_y, int number_reflect) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; /* sanity check */ if (number_reflect < 0) { fprintf(stderr, "hatsuda_wall_reflect_new: number_reflect is negative " "(%d)\n", number_reflect); return NULL; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "hatsuda_wall_reflect_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 20.0, y + 20.0, x - 20.0, y + 20.0, x - 20.0, y - 20.0, x + 20.0, y - 20.0); if (p[0] == NULL) { fprintf(stderr, "hatsuda_wall_reflect_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 1); if (count == NULL) { fprintf(stderr, "hatsuda_wall_reflect_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "hatsuda_wall_reflect_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] number_reflect */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = number_reflect; count_d[0] = speed_x; count_d[1] = speed_y; new = tenm_object_new("0x82da3104 wall reflect", ATTR_ENEMY | ATTR_OPAQUE, 0, 1, x, y, 1, count, 2, count_d, 1, p, (int (*)(tenm_object *, double)) (&hatsuda_wall_reflect_move), (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&hatsuda_wall_reflect_act), (int (*)(tenm_object *, int)) (&hatsuda_wall_reflect_draw)); if (new == NULL) { fprintf(stderr, "hatsuda_wall_reflect_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int hatsuda_wall_reflect_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "hatsuda_wall_reflect_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "hatsuda_wall_reflect_move: " "strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); if (!in_window_object(my)) return 1; return 0; } static int hatsuda_wall_reflect_act(tenm_object *my, const tenm_object *player) { int reflected = 0; /* sanity check */ if (my == NULL) { fprintf(stderr, "hatsuda_wall_reflect_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* don't reflect if the player is immutable */ if ((get_ship() < 0) || (player->count[1] > 0)) my->count[0] = 0; if (my->count[0] > 0) { if ((my->x < 0.0) || (my->x > ((double) WINDOW_WIDTH))) { my->count_d[0] *= -1.0; reflected = 1; } if ((my->y < 0.0) || (my->y > ((double) WINDOW_HEIGHT))) { my->count_d[1] *= -1.0; reflected = 1; } if (reflected != 0) (my->count[0])--; } return 0; } static int hatsuda_wall_reflect_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; /* sanity check */ if (my == NULL) { fprintf(stderr, "hatsuda_wall_reflect_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; /* body */ color = tenm_map_color(95, 13, 68); if (tenm_draw_line((int) (my->x + 20.0), (int) (my->y + 20.0), (int) (my->x - 20.0), (int) (my->y + 20.0), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - 20.0), (int) (my->y + 20.0), (int) (my->x - 20.0), (int) (my->y - 20.0), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - 20.0), (int) (my->y - 20.0), (int) (my->x + 20.0), (int) (my->y - 20.0), 3, color)) status = 1; if (tenm_draw_line((int) (my->x + 20.0), (int) (my->y - 20.0), (int) (my->x + 20.0), (int) (my->y + 20.0), 3, color)) status = 1; return status; } static tenm_object * hatsuda_shroud_new(int n) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x; double y; double dx_a; double dy_a; double dx_b; double dy_b; /* sanity check */ if ((n < 0) || (n > 2)) { fprintf(stderr, "hatsuda_shroud_new: strange n (%d)\n", n); return NULL; } x = (double) (WINDOW_WIDTH / 2); y = (double) (WINDOW_HEIGHT / 2); x += 200.0 * tenm_cos(n * 120); y += 200.0 * tenm_sin(n * 120); dx_a = 150.0 * tenm_cos(n * 120); dy_a = 150.0 * tenm_sin(n * 120); dx_b = 5.0 * tenm_cos(n * 120 + 90); dy_b = 5.0 * tenm_sin(n * 120 + 90); p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "hatsuda_shroud_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(4, x + dx_a + dx_b, y + dy_a + dy_b, x - dx_a + dx_b, y - dy_a + dy_b, x - dx_a - dx_b, y - dy_a - dy_b, x + dx_a - dx_b, y + dy_a - dy_b); if (p[0] == NULL) { fprintf(stderr, "hatsuda_shroud_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 10); if (count == NULL) { fprintf(stderr, "hatsuda_shroud_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "hatsuda_shroud_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] n * [1] move mode * [2] move timer */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = n; count[1] = 0; count[2] = 0; count_d[0] = 0.0; count_d[1] = 0.0; new = tenm_object_new("0x82da3104 shroud", 0, 0, 1, x, y, 10, count, 2, count_d, 1, p, (int (*)(tenm_object *, double)) (&hatsuda_shroud_move), (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&hatsuda_shroud_act), (int (*)(tenm_object *, int)) (&hatsuda_shroud_draw)); if (new == NULL) { fprintf(stderr, "hatsuda_shroud_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int hatsuda_shroud_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "hatsuda_shroud_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "hatsuda_shroud_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); if (!in_window_object(my)) return 1; return 0; } static int hatsuda_shroud_act(tenm_object *my, const tenm_object *player) { double x; double y; int i; double dx_a; double dy_a; int theta; /* sanity check */ if (my == NULL) { fprintf(stderr, "hatsuda_shroud_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* speed change */ (my->count[2])++; if (my->count[1] == 1) { if (my->count[2] < 200) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } else { if (my->count[2] < 1100) theta = my->count[0] * 120 + my->count[2] - 200; else if (my->count[2] < 1200) theta = my->count[0] * 120 + 1100 - 200; else theta = my->count[0] * 120 + 1100 - 200 - (my->count[2] - 1200); x = (double) (WINDOW_WIDTH / 2); y = (double) (WINDOW_HEIGHT / 2); x += 200.0 * tenm_cos(theta); y += 200.0 * tenm_sin(theta); my->count_d[0] = x - my->x; my->count_d[1] = y - my->y; } } /* encounter */ if (my->count[1] == 0) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; if (my->count[2] > 60) { my->attr = ATTR_BOSS | ATTR_OPAQUE; my->hit_mask = 0; my->count[1] = 1; my->count[2] = 0; return 0; } return 0; } if (my->count[1] != 1) return 0; /* shoot */ if ((my->count[2] <= 2010) && (((my->count[2] >= 132) && (my->count[2] % 11 == 0)) || (my->count[2] % 33 == 0))) { dx_a = 150.0 * tenm_cos(my->count[0] * 120); dy_a = 150.0 * tenm_sin(my->count[0] * 120); for (i = -60; i <= 60; i += 60) { tenm_table_add(laser_angle_new(my->x + dx_a, my->y + dy_a, 6.0, my->count[0] * 120 + i, 25.0, 1)); tenm_table_add(laser_angle_new(my->x - dx_a, my->y - dy_a, 6.0, my->count[0] * 120 + i + 180, 25.0, 1)); } } return 0; } static int hatsuda_shroud_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; int width; double dx_a; double dy_a; double dx_b; double dy_b; /* sanity check */ if (my == NULL) { fprintf(stderr, "hatsuda_shroud_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; /* body */ if (my->count[1] == 0) width = 1; else width = 3; if ((my->count[1] == 0) && (my->count[2] < 30)) color = tenm_map_color(182, 123, 162); else color = tenm_map_color(95, 13, 68); dx_a = 150.0 * tenm_cos(my->count[0] * 120); dy_a = 150.0 * tenm_sin(my->count[0] * 120); dx_b = 5.0 * tenm_cos(my->count[0] * 120 + 90); dy_b = 5.0 * tenm_sin(my->count[0] * 120 + 90); if (tenm_draw_line((int) (my->x + dx_a + dx_b), (int) (my->y + dy_a + dy_b), (int) (my->x - dx_a + dx_b), (int) (my->y - dy_a + dy_b), width, color)) status = 1; if (tenm_draw_line((int) (my->x - dx_a + dx_b), (int) (my->y - dy_a + dy_b), (int) (my->x - dx_a - dx_b), (int) (my->y - dy_a - dy_b), width, color)) status = 1; if (tenm_draw_line((int) (my->x - dx_a - dx_b), (int) (my->y - dy_a - dy_b), (int) (my->x + dx_a - dx_b), (int) (my->y + dy_a - dy_b), width, color)) status = 1; if (tenm_draw_line((int) (my->x + dx_a - dx_b), (int) (my->y + dy_a - dy_b), (int) (my->x + dx_a + dx_b), (int) (my->y + dy_a + dy_b), width, color)) status = 1; return status; } dangen-0.5/spqr/hatsuda.h0000644000175000017500000000034010276702737016215 0ustar00ooharaoohara00000000000000/* $Id: hatsuda.h,v 1.1 2004/04/21 06:28:57 oohara Exp $ */ #ifndef __DANGEN_HATSUDA_H__ #define __DANGEN_HATSUDA_H__ #include "tenm_object.h" tenm_object *hatsuda_new(void); #endif /* not __DANGEN_SILVER_CHIMERA_H__ */ dangen-0.5/spqr/hugin.c0000644000175000017500000005753211625004226015673 0ustar00ooharaoohara00000000000000/* $Id: hugin.c,v 1.72 2011/08/23 20:07:50 oohara Exp $ */ /* [very easy] Hugin */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "stage-clear.h" #include "score.h" #include "hugin.h" #define NEAR_ZERO 0.0001 static int hugin_move(tenm_object *my, double turn_per_frame); static int hugin_hit(tenm_object *my, tenm_object *your); static void hugin_next(tenm_object *my); static int hugin_act(tenm_object *my, const tenm_object *player); static int hugin_draw(tenm_object *my, int priority); static int hugin_green(const tenm_object *my); static tenm_object *munin_new(int table_index); static int munin_move(tenm_object *my, double turn_per_frame); static int munin_hit(tenm_object *my, tenm_object *your); static int munin_signal(tenm_object *my, int n); static int munin_act(tenm_object *my, const tenm_object *player); static int munin_draw(tenm_object *my, int priority); static int munin_green(const tenm_object *my); tenm_object * hugin_new(void) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = (double) (WINDOW_WIDTH / 2); double y = -39.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "hugin_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 40.0, y - 40.0, x + 40.0, y + 40.0, x - 40.0, y + 40.0, x - 40.0, y - 40.0); if (p[0] == NULL) { fprintf(stderr, "hugin_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 8); if (count == NULL) { fprintf(stderr, "hugin_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 4); if (count_d == NULL) { fprintf(stderr, "hugin_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] life mode * [3] life timer * [4] shoot randomness * [5] move direction * [6] "munin killed" flag * [7] "was green when killed" flag */ /* list of count_d * [0] speed x * [1] speed y * [2] shoot direction x * [3] shoot direction y */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 0; count[4] = 0; count[5] = 0; count[6] = 0; count[7] = 0; count_d[0] = 0.0; count_d[1] = (((double) (WINDOW_HEIGHT / 4)) - y) / 90.0; count_d[2] = 0.0; count_d[3] = 1.0; new = tenm_object_new("Hugin", ATTR_BOSS, ATTR_PLAYER_SHOT, 500, x, y, 8, count, 4, count_d, 1, p, (int (*)(tenm_object *, double)) (&hugin_move), (int (*)(tenm_object *, tenm_object *)) (&hugin_hit), (int (*)(tenm_object *, const tenm_object *)) (&hugin_act), (int (*)(tenm_object *, int)) (&hugin_draw)); if (new == NULL) { fprintf(stderr, "hugin_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int hugin_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "hugin_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "hugin_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int hugin_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "hugin_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "hugin_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if (my->count[2] != 1) return 0; deal_damage(my, your, 0); if (hugin_green(my)) add_chain(my, your); my->count[1] = 2; if (my->hit_point <= 0) { add_score(3000); set_background(1); hugin_next(my); return 0; } return 0; } static void hugin_next(tenm_object *my) { int n; /* sanity check */ if (my == NULL) { fprintf(stderr, "hugin_next: my is NULL\n"); return; } tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy), 0); /* set "was green" flag before we change the life mode */ if (hugin_green(my)) { n = 8; my->count[7] = 1; } else { n = 7; my->count[7] = 0; } tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 5000, n, 10.0, 6)); my->count[2] = 2; my->count[3] = 0; my->count[1] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.5; /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ tenm_mass_delete(my->mass); my->mass = NULL; } static int hugin_act(tenm_object *my, const tenm_object *player) { double result[2]; double v[2]; int theta; int t; double x; int i; /* sanity check */ if (my == NULL) { fprintf(stderr, "hugin_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; (my->count[3])++; /* encounter */ if (my->count[2] == 0) { if (my->count[3] >= 90) { my->count[2] = 1; my->count[3] = -1; my->count_d[0] = 0.0; my->count_d[1] = 0.0; return 0; } return 0; } /* dead */ if (my->count[2] == 2) { if (hugin_green(my)) i = 8; else i = 7; if ((my->count[3] >= 30) && (my->count[3] <= 75) && (my->count[3] % 15 == 0)) { theta = rand() % 360; tenm_table_add(explosion_new(my->x + 30.0 * tenm_cos(theta), my->y + 30.0 * tenm_sin(theta), 0.0, 0.0, 2, 300, i, 5.0, 8)); } if (my->count[3] > 120) { tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 3000, i, 10.0, 8)); tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 30.0, 100, i, 4.0, 0.0, 16)); tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 50.0, 30, i, 2.5, 0.0, 12)); tenm_table_add(stage_clear_new(100)); return 1; } return 0; } /* self-destruction */ if ((my->count[2] == 1) && (my->count[3] >= 2160)) { set_background(2); clear_chain(); hugin_next(my); return 0; } if (my->count[3] == 270) tenm_table_add(munin_new(my->table_index)); t = my->count[3] % 160; /* move */ if (my->count[3] == 270) { my->count_d[0] = (((double) (WINDOW_WIDTH * 3 / 4)) - my->x) / 45.0; my->count_d[1] = 0.0; } else if (my->count[3] == 315) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } else if (my->count[3] >= 320) { if (t == 110) { if (my->x < (double) (WINDOW_WIDTH / 2)) my->count[5] = 0; else my->count[5] = 1; } if ((t >= 110) && (t <= 155)) { x = ((double) (WINDOW_WIDTH / 4)) * tenm_sin(-90 + (t - 110) * 4); x += (double) (WINDOW_WIDTH / 2); if (my->count[5] != 0) x = ((double) (WINDOW_WIDTH)) - x; my->count_d[0] = x - my->x; my->count_d[1] = 0.0; } else { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } } /* shoot */ if (my->count[3] >= 2080) return 0; if (t == 0) { if (my->count[6] == 0) { my->count_d[2] = player->x; if ((double) (rand() % (WINDOW_WIDTH + 1)) > my->count_d[2]) my->count[4] = 0; else my->count[4] = 1; if (rand() % 2 == 0) my->count[4] += 2; } else { my->count[4] = 4; my->count_d[2] = player->x - my->x; my->count_d[3] = player->y - my->y; if (my->count_d[2] * my->count_d[2] + my->count_d[3] * my->count_d[3] < NEAR_ZERO) { my->count_d[2] = 0.0; my->count_d[3] = 1.0; } v[0] = my->count_d[2]; v[1] = my->count_d[3]; result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, 5 - (rand() % 2) * 10); my->count_d[2] = result[0]; my->count_d[3] = result[1]; } } if (my->count[4] < 4) { if ((my->count[3] % 160 < 90) && ((my->count[3] % 160) % 6 == 0)) { if (my->count[4] < 2) { tenm_table_add(normal_shot_point_new(my->x + 100.0, my->y - 85.0, 6.0, my->count_d[2] + 45.0, player->y, 4)); tenm_table_add(normal_shot_point_new(my->x - 100.0, my->y - 85.0, 6.0, my->count_d[2] - 45.0, player->y, 4)); } else { tenm_table_add(normal_shot_point_new(my->x + 100.0, my->y - 85.0, 6.0, my->count_d[2] - 120.0, player->y, 4)); tenm_table_add(normal_shot_point_new(my->x - 100.0, my->y - 85.0, 6.0, my->count_d[2] + 120.0, player->y, 4)); } if (my->count[4] == 0) my->count_d[2] += 15.0; else my->count_d[2] -= 15.0; if (my->count_d[2] < 0.0) my->count_d[2] = 0.0; if (my->count_d[2] > (double) WINDOW_WIDTH) my->count_d[2] = (double) WINDOW_WIDTH; } } else { if ((my->count[3] % 2 == 0) && (my->count[3] % 160 <= 110)) { if (my->count[3] % 160 <= 30) { theta = 0; } else { theta = rand() % (((my->count[3] % 160) - 30) * 2 + 1); theta -= (my->count[3] % 160) - 30; } v[0] = my->count_d[2]; v[1] = my->count_d[3]; result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, theta); tenm_table_add(normal_shot_point_new(my->x, my->y, 6.0, my->x + result[0], my->y + result[1], 2)); } } return 0; } static int hugin_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; /* sanity check */ if (my == NULL) { fprintf(stderr, "hugin_draw: my is NULL\n"); return 0; } /* dead enemy has low priority */ if (((my->count[2] <= 1) && (priority != 0)) || ((my->count[2] > 1) && (priority != -1))) return 0; /* body */ if (hugin_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 1) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } /* wing */ if (tenm_draw_line((int) (my->x + 40.0), (int) (my->y - 40.0), (int) (my->x + 100.0), (int) (my->y - 85.0), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 40.0), (int) (my->y - 40.0), (int) (my->x - 100.0), (int) (my->y - 85.0), 1, color) != 0) status = 1; /* core */ if (tenm_draw_line((int) (my->x + 40.0), (int) (my->y - 40.0), (int) (my->x + 40.0), (int) (my->y + 40.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 40.0), (int) (my->y + 40.0), (int) (my->x - 40.0), (int) (my->y + 40.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 40.0), (int) (my->y + 40.0), (int) (my->x - 40.0), (int) (my->y - 40.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 40.0), (int) (my->y - 40.0), (int) (my->x + 40.0), (int) (my->y - 40.0), 3, color) != 0) status = 1; /* hit point stat */ if (my->count[2] == 1) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 10, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "hugin_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int hugin_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if ((my->count[2] == 1) && (my->count[6] != 0) && (my->count[3] < 2130)) return 1; if ((my->count[2] == 2) && (my->count[7] != 0)) return 1; return 0; } static tenm_object * munin_new(int table_index) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = (double) (WINDOW_WIDTH / 4); double y = -39.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "munin_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 40.0, y - 40.0, x + 40.0, y + 40.0, x - 40.0, y + 40.0, x - 40.0, y - 40.0); if (p[0] == NULL) { fprintf(stderr, "munin_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 8); if (count == NULL) { fprintf(stderr, "munin_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 4); if (count_d == NULL) { fprintf(stderr, "munin_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] life mode * [3] life timer * [4] shoot randomness * [5] move direction * [6] Hugin index */ /* list of count_d * [0] speed x * [1] speed y * [2] shoot direction x * [3] shoot direction y */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 0; count[4] = -1; count[5] = 0; count[6] = table_index; count_d[0] = 0.0; count_d[1] = (((double) (WINDOW_HEIGHT / 4)) - y) / 45.0; count_d[2] = 0.0; count_d[3] = 1.0; new = tenm_object_new("Munin", ATTR_ENEMY, ATTR_PLAYER_SHOT, 500, x, y, 8, count, 4, count_d, 1, p, (int (*)(tenm_object *, double)) (&munin_move), (int (*)(tenm_object *, tenm_object *)) (&munin_hit), (int (*)(tenm_object *, const tenm_object *)) (&munin_act), (int (*)(tenm_object *, int)) (&munin_draw)); if (new == NULL) { fprintf(stderr, "munin_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int munin_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "munin_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "munin_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int munin_hit(tenm_object *my, tenm_object *your) { int n; /* sanity check */ if (my == NULL) { fprintf(stderr, "munin_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "munin_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if (my->count[2] != 1) return 0; deal_damage(my, your, 0); if (munin_green(my)) add_chain(my, your); my->count[1] = 41; if (my->hit_point <= 0) { add_score(3000); if (munin_green(my)) n = 8; else n = 7; tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 3000, n, 10.0, 8)); tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 30.0, 100, n, 4.0, 0.0, 16)); tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 50.0, 30, n, 2.5, 0.0, 12)); tenm_table_apply(my->count[6], (int (*)(tenm_object *, int)) (&munin_signal), 0); return 1; } return 0; } static int munin_signal(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "Hugin") != 0) return 0; my->count[6] = 1; return 0; } static int munin_act(tenm_object *my, const tenm_object *player) { int i; int j; double x; double y; double v[2]; double result[2]; int theta; double speed; int t; /* sanity check */ if (my == NULL) { fprintf(stderr, "munin_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; (my->count[3])++; t = my->count[3] % 160; /* encounter */ if (my->count[2] == 0) { if (my->count[3] == 45) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[3] >= 50) { my->count[2] = 1; my->count[3] = 320; return 0; } return 0; } /* move */ if (t == 110) { if (my->x < (double) (WINDOW_WIDTH / 2)) my->count[5] = 0; else my->count[5] = 1; } if ((t >= 110) && (t <= 155)) { x = ((double) (WINDOW_WIDTH / 4)) * tenm_sin(-90 + (t - 110) * 4); x += (double) (WINDOW_WIDTH / 2); if (my->count[5] != 0) x = ((double) (WINDOW_WIDTH)) - x; my->count_d[0] = x - my->x; my->count_d[1] = 0.0; } else { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } /* shoot */ if (my->count[3] < 480) return 0; if (my->count[3] >= 2080) return 0; if (t == 0) { if (my->count[4] < 0) my->count[4] = rand() % 3; else if (rand() % 5 != 0) my->count[4] += 1 + rand() % 2; while (my->count[4] >= 3) my->count[4] -= 3; while (my->count[4] < 0) my->count[4] += 3; } switch (my->count[4]) { case 0: if ((t < 60) && (t % 15 == 0)) { for (i = 0; i < 2; i++) for (j = -2; j <= 2; j++) { x = my->x - 100.0 + 200.0 * ((double) i); y = my->y - 85.0; theta = 80 + 20 * i + 24 * j; if (t < 30) theta += 12 - 24 * i; tenm_table_add(laser_angle_new(x, y, 4.0, theta, 25.0, 0)); } } break; case 1: if (t == 10) { my->count_d[2] = player->x - my->x; my->count_d[3] = player->y - my->y; if (my->count_d[2] * my->count_d[2] + my->count_d[3] * my->count_d[3] < NEAR_ZERO) { my->count_d[2] = 0.0; my->count_d[3] = 1.0; } } if ((t == 20) || (t == 30) || (t == 40) || (t == 50)) { if (t == 20) theta = 8; else if (t == 30) theta = 24; else if (t == 40) theta = 40; else theta = 0; for (i = 0; i < 2; i++) for (j = -1; j <= 1; j++) { if (j == 0) continue; x = my->x - 100.0 + 200.0 * ((double) i); y = my->y - 85.0; v[0] = my->count_d[2] - (-100.0 + 200.0 * ((double) i)); v[1] = my->count_d[3] - (-85.0); result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, theta * j); tenm_table_add(laser_point_new(x, y, 5.5, x + result[0], y + result[1], 25.0, 1)); if (t == 50) break; } } break; case 2: if ((t % 8 == 0) && (t < 80)) { for (i = 0; i < 2; i++) { x = my->x - 100.0 + 200.0 * ((double) i); y = my->y - 85.0; if (t < 40) theta = 80 + 13 * (t / 8); else theta = 152 - 13 * ((t - 40) / 8); if (i != 0) theta = 180 - theta; speed = 3.0 + 0.8 * ((double) ((t % 40) / 8)); tenm_table_add(laser_angle_new(x, y, speed, theta, 25.0, 2)); } } break; default: fprintf(stderr, "munin_act: undefined shoot mode (%d)\n", my->count[4]); break; } return 0; } static int munin_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; /* sanity check */ if (my == NULL) { fprintf(stderr, "munin_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; /* body */ if (munin_green(my)) { if (my->count[1] >= 40) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 40) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } /* wing */ if (tenm_draw_line((int) (my->x + 40.0), (int) (my->y - 40.0), (int) (my->x + 100.0), (int) (my->y - 85.0), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 40.0), (int) (my->y - 40.0), (int) (my->x - 100.0), (int) (my->y - 85.0), 1, color) != 0) status = 1; /* core */ if (tenm_draw_line((int) (my->x + 40.0), (int) (my->y - 40.0), (int) (my->x + 40.0), (int) (my->y + 40.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 40.0), (int) (my->y + 40.0), (int) (my->x - 40.0), (int) (my->y + 40.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 40.0), (int) (my->y + 40.0), (int) (my->x - 40.0), (int) (my->y - 40.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 40.0), (int) (my->y - 40.0), (int) (my->x + 40.0), (int) (my->y - 40.0), 3, color) != 0) status = 1; /* hit point stat */ if (my->count[1] >= 1) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 10, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "munin_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int munin_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if ((my->count[2] == 1) && (my->count[3] >= 480) && (my->count[3] < 2130)) return 1; return 0; } dangen-0.5/spqr/hugin.h0000644000175000017500000000031710276702741015675 0ustar00ooharaoohara00000000000000/* $Id: hugin.h,v 1.1 2004/07/23 12:47:28 oohara Exp $ */ #ifndef __DANGEN_HUGIN_H__ #define __DANGEN_HUGIN_H__ #include "tenm_object.h" tenm_object *hugin_new(void); #endif /* not __DANGEN_HUGIN_H__ */ dangen-0.5/spqr/insane-hand.c0000644000175000017500000016352611625004404016745 0ustar00ooharaoohara00000000000000/* $Id: insane-hand.c,v 1.211 2011/08/23 20:09:40 oohara Exp $ */ /* [normal] Hell Salvage */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "normal-enemy.h" #include "stage-clear.h" #include "score.h" #include "ship.h" #include "insane-hand.h" #define NEAR_ZERO 0.0001 static int insane_hand_move(tenm_object *my, double turn_per_frame); static int insane_hand_hit(tenm_object *my, tenm_object *your); static void insane_hand_next(tenm_object *my); static int insane_hand_act(tenm_object *my, const tenm_object *player); static int insane_hand_draw(tenm_object *my, int priority); static int insane_hand_body_line(double a_x, double a_y, double b_x, double b_y, int width, tenm_color color, int theta); static void insane_hand_body_rotate(double *result, const double *v, int theta); static int insane_hand_green(const tenm_object *my); static tenm_object *insane_hand_ship_new(double x, double y); static int insane_hand_ship_move(tenm_object *my, double turn_per_frame); static int insane_hand_ship_hit(tenm_object *my, tenm_object *your); static int insane_hand_ship_signal_bit(tenm_object *my, int n); static int insane_hand_ship_act(tenm_object *my, const tenm_object *player); static int insane_hand_ship_draw(tenm_object *my, int priority); static int insane_hand_ship_green(const tenm_object *my); static tenm_object *insane_hand_ship_bit_new(double x, double y); static int insane_hand_ship_bit_move(tenm_object *my, double turn_per_frame); static int insane_hand_ship_bit_act(tenm_object *my, const tenm_object *player); static int insane_hand_ship_bit_draw(tenm_object *my, int priority); static tenm_object *insane_hand_ship_shot_new(double x, double y, double v_x, double v_y); static int insane_hand_ship_shot_move(tenm_object *my, double turn_per_frame); static int insane_hand_ship_shot_hit(tenm_object *my, tenm_object *your); static int insane_hand_ship_shot_act(tenm_object *my, const tenm_object *player); static int insane_hand_ship_shot_draw(tenm_object *my, int priority); tenm_object * insane_hand_new(void) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = (double) (WINDOW_WIDTH / 2); double y = -75.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "insane_hand_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 50.0, y - 25.0, x + 50.0, y + 25.0, x - 50.0, y + 25.0, x - 50.0, y - 25.0); if (p[0] == NULL) { fprintf(stderr, "insane_hand_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 8); if (count == NULL) { fprintf(stderr, "insane_hand_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 4); if (count_d == NULL) { fprintf(stderr, "insane_hand_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] life mode * [3] life timer * [4 -- 5] hand theta * [6] shoot randomness * [7] "was green when killed" flag */ /* list of count_d * [0] speed x * [1] speed y * [2 -- 3] shoot randomness */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 0; count[4] = 75; count[5] = 165; count[6] = 0; count_d[0] = 0.0; count_d[1] = (179.0 - y) / 90.0; count_d[2] = 0.0; count_d[3] = 0.0; new = tenm_object_new("Insane Hand", 0, 0, 1000, x, y, 8, count, 4, count_d, 1, p, (int (*)(tenm_object *, double)) (&insane_hand_move), (int (*)(tenm_object *, tenm_object *)) (&insane_hand_hit), (int (*)(tenm_object *, const tenm_object *)) (&insane_hand_act), (int (*)(tenm_object *, int)) (&insane_hand_draw)); if (new == NULL) { fprintf(stderr, "insane_hand_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int insane_hand_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "insane_hand_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "insane_hand_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int insane_hand_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "insane_hand_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "insane_hand_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if ((my->count[2] != 1) && (my->count[2] != 3)) return 0; deal_damage(my, your, 0); if (insane_hand_green(my)) add_chain(my, your); my->count[1] = 2; if (my->hit_point <= 0) { if (my->count[2] == 1) add_score(6250); else if (my->count[2] == 3) add_score(18750); set_background(1); insane_hand_next(my); return 0; } return 0; } static void insane_hand_next(tenm_object *my) { int n; /* sanity check */ if (my == NULL) { fprintf(stderr, "insane_hand_next: my is NULL\n"); return; } if ((my->count[2] != 1) && (my->count[2] != 3)) return; tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy), 0); /* set "was green" flag before we change the life mode */ if (insane_hand_green(my)) { n = 8; my->count[7] = 1; } else { n = 7; my->count[7] = 0; } if (my->count[2] == 1) { tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 50.0, 5, n, 2.0, 0.0, 16)); tenm_table_add(fragment_new(my->x, my->y - 80.0, 0.0, 0.0, 50.0, 5, n, 2.0, 0.0, 16)); tenm_table_add(fragment_new(my->x, my->y - 160.0, 0.0, 0.0, 50.0, 5, n, 2.0, 0.0, 16)); my->hit_point = 500; my->count[2] = 2; my->count[3] = 0; my->count[1] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; return; } else if (my->count[2] == 3) { tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 5000, n, 10.0, 6)); tenm_table_add(fragment_new(my->x + 50.0, my->y + 25.0, 0.0, 0.0, 30.0, 5, n, 5.0, 15.0, 16)); tenm_table_add(fragment_new(my->x - 50.0, my->y + 25.0, 0.0, 0.0, 30.0, 5, n, 5.0, 15.0, 16)); my->count[2] = 4; my->count[3] = 0; my->count[1] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.5; /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ tenm_mass_delete(my->mass); my->mass = NULL; return; } } static int insane_hand_act(tenm_object *my, const tenm_object *player) { int t; int theta; double x; double y; int i; double speed; double length; double dx; double dy; /* sanity check */ if (my == NULL) { fprintf(stderr, "insane_hand_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; (my->count[3])++; /* encounter */ if (my->count[2] == 0) { if (my->count[3] == 90) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (((my->count[3] >= 90) && (my->count[3] < 105)) || ((my->count[3] >= 120) && (my->count[3] < 135))) { my->count[4] -= 5; my->count[5] -= 5; } if (((my->count[3] >= 105) && (my->count[3] < 120)) || ((my->count[3] >= 135) && (my->count[3] < 150))) { my->count[4] += 5; my->count[5] += 5; } if (my->count[3] >= 240) { my->count[2] = 1; my->count[3] = 0; my->attr = ATTR_BOSS; my->hit_mask = ATTR_PLAYER_SHOT; return 0; } return 0; } if (my->count[2] == 2) { /* reset hand */ if (my->count[3] >= 30) { if ((my->count[4] + 5 >= 75) && (my->count[4] - 5 <= 75)) my->count[4] = 75; else if (my->count[4] > 75) my->count[4] -= 5; else my->count[4] += 5; if ((my->count[5] + 5 >= 165) && (my->count[5] - 5 <= 165)) my->count[5] = 165; else if (my->count[5] > 165) my->count[5] -= 5; else my->count[5] += 5; } if (my->count[3] == 30) { my->count_d[0] = (((double) (WINDOW_WIDTH / 2)) - my->x) / 90.0; my->count_d[1] = (179.0 - my->y) / 90.0; my->count[7] = 0; } if (my->count[3] == 120) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; my->count[2] = 3; my->count[3] = 0; my->count[7] = 0; } return 0; } /* dead */ if (my->count[2] == 4) { if (insane_hand_green(my)) i = 8; else i = 7; if ((my->count[3] >= 30) && (my->count[3] <= 75) && (my->count[3] % 15 == 0)) { theta = rand() % 360; tenm_table_add(explosion_new(my->x + 30.0 * tenm_cos(theta), my->y + 30.0 * tenm_sin(theta), 0.0, 0.0, 2, 300, i, 5.0, 8)); } if (my->count[3] > 120) { tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 3000, i, 10.0, 8)); tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 30.0, 100, i, 4.0, 0.0, 16)); tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 50.0, 30, i, 2.5, 0.0, 12)); tenm_table_add(stage_clear_new(100)); return 1; } return 0; } /* self-destruction */ if ((my->count[2] == 1) && (my->count[3] >= 4070)) { set_background(2); clear_chain(); insane_hand_next(my); return 0; } if ((my->count[2] == 3) && (my->count[3] >= 3030)) { set_background(2); clear_chain(); insane_hand_next(my); return 0; } /* move hand */ if (my->count[2] == 1) { if ((my->count[3] >= 800) && (my->count[3] < 815)) { my->count[4] -= 5; my->count[5] -= 5; } if ((my->count[3] >= 890) && (my->count[3] < 905)) { my->count[4] += 5; my->count[5] += 5; } if ((my->count[3] >= 1380) && (my->count[3] < 1395)) { my->count[4] -= 5; my->count[5] -= 5; } if ((my->count[3] >= 1395) && (my->count[3] < 1410)) { my->count[4] += 5; my->count[5] += 5; } if ((my->count[3] >= 1880) && (my->count[3] < 1895)) { my->count[4] -= 5; my->count[5] -= 5; } if ((my->count[3] >= 1970) && (my->count[3] < 1985)) { my->count[4] += 5; my->count[5] += 5; } if ((my->count[3] >= 2460) && (my->count[3] < 2475)) { my->count[4] -= 5; my->count[5] -= 5; } if ((my->count[3] >= 2475) && (my->count[3] < 2490)) { my->count[4] += 5; my->count[5] += 5; } if ((my->count[3] >= 2675) && (my->count[3] < 2690)) { my->count[4] -= 5; my->count[5] -= 5; } if ((my->count[3] >= 2765) && (my->count[3] < 2780)) { my->count[4] += 5; my->count[5] += 5; } if ((my->count[3] >= 3975) && (my->count[3] < 3990)) { my->count[4] -= 5; my->count[5] -= 5; } if ((my->count[3] >= 3990) && (my->count[3] < 4005)) { my->count[4] += 5; my->count[5] += 5; } } else if (my->count[2] == 3) { if (my->count[3] % 60 < 30) { my->count[4] -= 5; my->count[5] -= 10; } else { my->count[4] += 5; my->count[5] += 10; } } /* speed change */ if (my->count[2] == 1) { if (my->count[3] == 450) { my->count_d[0] = -6.0; my->count_d[1] = 0.0; } if (my->count[3] == 495) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[3] == 505) { my->count_d[0] = 6.0; my->count_d[1] = 0.0; } if (my->count[3] == 595) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[3] == 600) { my->count_d[0] = -6.0; my->count_d[1] = 0.0; } if (my->count[3] == 690) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[3] == 820) { my->count_d[0] = 0.0; my->count_d[1] = 6.0; } if (my->count[3] == 890) { my->count_d[0] = 0.0; my->count_d[1] = -6.0; } if (my->count[3] == 960) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[3] == 1060) { my->count_d[0] = 6.0; my->count_d[1] = 0.0; } if (my->count[3] == 1105) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[3] == 1530) { my->count_d[0] = 6.0; my->count_d[1] = 0.0; } if (my->count[3] == 1575) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[3] == 1585) { my->count_d[0] = -6.0; my->count_d[1] = 0.0; } if (my->count[3] == 1675) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[3] == 1680) { my->count_d[0] = 6.0; my->count_d[1] = 0.0; } if (my->count[3] == 1770) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[3] == 1900) { my->count_d[0] = 0.0; my->count_d[1] = 6.0; } if (my->count[3] == 1970) { my->count_d[0] = 0.0; my->count_d[1] = -6.0; } if (my->count[3] == 2040) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[3] == 2140) { my->count_d[0] = -6.0; my->count_d[1] = 0.0; } if (my->count[3] == 2185) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[3] == 2630) { my->count_d[0] = -6.0; my->count_d[1] = 0.0; } if (my->count[3] == 2675) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[3] == 2695) { my->count_d[0] = 0.0; my->count_d[1] = 6.0; } if (my->count[3] == 2765) { my->count_d[0] = 0.0; my->count_d[1] = -6.0; } if (my->count[3] == 2835) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[3] == 3925) { my->count_d[0] = 6.0; my->count_d[1] = 0.0; } if (my->count[3] == 3970) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } } else if (my->count[2] == 3) { if (my->count[3] < 480) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } else { t = my->count[3] - 480; my->count_d[0] = ((double) (WINDOW_WIDTH / 2)) + 200.0 * tenm_sin(t * 2) - my->x; my->count_d[1] = 179.0 + 100.0 * tenm_sin(t * 3) - my->y; } } /* add normal enemy */ if (my->count[2] == 1) { if (my->count[3] == 890) { tenm_table_add(normal_enemy_new(my->x, my->y + 25.0 + 50.0 * tenm_sin(60), BALL_CAPTAIN, 0, 70, -1, 0, -1, 0, 5, 2, /* move 0 */ 70, 0.0, -6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 100, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 45, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3, /* move 3 */ 275, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4, /* move 4 */ 9999, 0.0, 0.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 4, /* shoot 0 */ 70, 10, 0, 0, 0, 1, /* shoot 1 */ 9999, 10, 0, 0, 1, 1)); } if (my->count[3] == 1970) { tenm_table_add(normal_enemy_new(my->x, my->y + 25.0 + 50.0 * tenm_sin(60), BALL_CAPTAIN, 0, 70, -1, 0, -1, 0, 5, 2, /* move 0 */ 70, 0.0, -6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 100, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 45, -6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3, /* move 3 */ 275, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4, /* move 4 */ 9999, 0.0, 0.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 4, /* shoot 0 */ 70, 10, 0, 0, 0, 1, /* shoot 1 */ 9999, 10, 0, 0, 1, 1)); } if (my->count[3] == 2765) tenm_table_add(insane_hand_ship_new(my->x + 25.0, my->y + 31.0 + 50.0 * tenm_sin(60))); } /* shoot */ if (my->count[2] == 1) { if ((my->count[3] == 30) || (my->count[3] == 1110) || (my->count[3] == 2190)) { my->count[6] = rand() % 4; my->count_d[2] = (double) (-5 + (rand() % 11)); my->count_d[3] = (double) (-5 + (rand() % 11)); } if ((((my->count[3] >= 30) && (my->count[3] <= 156)) || ((my->count[3] >= 216) && (my->count[3] <= 342)) || ((my->count[3] >= 1110) && (my->count[3] <= 1236)) || ((my->count[3] >= 1296) && (my->count[3] <= 1422)) || ((my->count[3] >= 2190) && (my->count[3] <= 2316)) || ((my->count[3] >= 2376) && (my->count[3] <= 2502))) && (my->count[3] % 6 == 0)) { if (my->count[3] <= 156) t = my->count[3] - 30; else if (my->count[3] <= 342) t = my->count[3] - 216; else if (my->count[3] <= 1236) t = my->count[3] - 1110; else if (my->count[3] <= 1422) t = my->count[3] - 1296; else if (my->count[3] <= 2316) t = my->count[3] - 2190; else t = my->count[3] - 2376; theta = (t / 6) * (-17); if (my->count[6] % 2 != 0) theta = 180 - theta; x = my->x; y = my->y; if (my->count[6] < 2) x += 35.0; else x -= 35.0; x += my->count_d[2]; y += my->count_d[3]; tenm_table_add(normal_shot_angle_new(x, y, 1.5 + 0.2 * ((double) (t / 5)), theta, 4)); if (my->count[6] % 2 != 0) theta += 178; else theta -= 178; tenm_table_add(normal_shot_angle_new(x, y, 2.5, theta, 2)); } if ((((my->count[3] >= 60) && (my->count[3] <= 186)) || ((my->count[3] >= 246) && (my->count[3] <= 372)) || ((my->count[3] >= 1140) && (my->count[3] <= 1266)) || ((my->count[3] >= 1326) && (my->count[3] <= 1452)) || ((my->count[3] >= 2220) && (my->count[3] <= 2346)) || ((my->count[3] >= 2406) && (my->count[3] <= 2532))) && (my->count[3] % 6 == 0)) { if (my->count[3] <= 186) t = my->count[3] - 60; else if (my->count[3] <= 372) t = my->count[3] - 246; else if (my->count[3] <= 1266) t = my->count[3] - 1140; else if (my->count[3] <= 1452) t = my->count[3] - 1326; else if (my->count[3] <= 2346) t = my->count[3] - 2220; else t = my->count[3] - 2406; theta = (t / 6) * (-17); if (my->count[6] % 2 == 0) theta = 180 - theta; x = my->x; y = my->y; if (my->count[6] < 2) x -= 35.0; else x += 35.0; x += my->count_d[2]; y += my->count_d[3]; tenm_table_add(normal_shot_angle_new(x, y, 1.5 + 0.2 * ((double) (t / 5)), theta, 4)); if (my->count[6] % 2 == 0) theta += 178; else theta -= 178; tenm_table_add(normal_shot_angle_new(x, y, 2.5, theta, 2)); } if ((my->count[3] == 186) || (my->count[3] == 1266)) { my->count[6] = (my->count[6] + 2) % 4; my->count_d[2] = (double) (-5 + (rand() % 11)); my->count_d[3] = (double) (-5 + (rand() % 11)); } if (((my->count[3] >= 505) && (my->count[3] <= 595)) || ((my->count[3] >= 1585) && (my->count[3] <= 1675))) { if (my->count[3] <= 595) t = my->count[3] - 505; else t = my->count[3] - 1585; if (t % 30 == 0) tenm_table_add(normal_shot_point_new(my->x, my->y, 4.0, player->x, player->y, 2)); if ((t % 32 == 0) || (t % 32 == 12)) { tenm_table_add(laser_angle_new(my->x - 48.0, my->y, 3.0, 70, 25.0, 3)); tenm_table_add(laser_angle_new(my->x + 48.0, my->y, 3.0, 70, 25.0, 3)); tenm_table_add(laser_angle_new(my->x - 48.0, my->y, 3.0, -70, 25.0, 3)); tenm_table_add(laser_angle_new(my->x + 48.0, my->y, 3.0, -70, 25.0, 3)); tenm_table_add(laser_angle_new(my->x - 48.0, my->y, 3.0, 110, 25.0, 3)); tenm_table_add(laser_angle_new(my->x + 48.0, my->y, 3.0, 110, 25.0, 3)); tenm_table_add(laser_angle_new(my->x - 48.0, my->y, 3.0, -110, 25.0, 3)); tenm_table_add(laser_angle_new(my->x + 48.0, my->y, 3.0, -110, 25.0, 3)); } if ((t % 32 == 4) || (t % 32 == 24)) { tenm_table_add(laser_angle_new(my->x - 48.0, my->y, 1.5, 70, 25.0, 3)); tenm_table_add(laser_angle_new(my->x + 48.0, my->y, 1.5, 70, 25.0, 3)); tenm_table_add(laser_angle_new(my->x - 48.0, my->y, 1.5, -70, 25.0, 3)); tenm_table_add(laser_angle_new(my->x + 48.0, my->y, 1.5, -70, 25.0, 3)); tenm_table_add(laser_angle_new(my->x - 48.0, my->y, 1.5, 110, 25.0, 3)); tenm_table_add(laser_angle_new(my->x + 48.0, my->y, 1.5, 110, 25.0, 3)); tenm_table_add(laser_angle_new(my->x - 48.0, my->y, 1.5, -110, 25.0, 3)); tenm_table_add(laser_angle_new(my->x + 48.0, my->y, 1.5, -110, 25.0, 3)); } } if ((my->count[3] >= 600) && (my->count[3] <= 690) && (my->count[3] % 15 == 0)) { for (i = -2; i <= 2; i++) tenm_table_add(normal_shot_new(my->x, my->y - 80.0 + 40.0 * ((double) i), 1.5, 3.6 - 0.8 * ((double) i), 5, -2, 0)); } if ((my->count[3] >= 1680) && (my->count[3] <= 1770) && (my->count[3] % 15 == 0)) { for (i = -2; i <= 2; i++) tenm_table_add(normal_shot_new(my->x, my->y - 80.0 + 40.0 * ((double) i), -1.5, 3.6 - 0.8 * ((double) i), 5, -2, 0)); } if ((my->count[3] == 820) || (my->count[3] == 1900) || (my->count[3] == 2695)) { my->count_d[2] = (double) (-5 + (rand() % 11)); my->count_d[3] = (double) (-5 + (rand() % 11)); } if (((my->count[3] >= 820) && (my->count[3] < 880)) || ((my->count[3] >= 2695) && (my->count[3] < 2755))) { if (my->count[3] < 880) t = my->count[3] - 820; else t = my->count[3] - 2695; tenm_table_add(laser_angle_new(my->x - 36.0 + my->count_d[2], my->y + my->count_d[3], 2.0, 178 + 15 * (t % 10), 25.0, 2)); tenm_table_add(laser_angle_new(my->x + 36.0 + my->count_d[2], my->y + my->count_d[3], 2.0, 88 - 15 * (t % 10), 25.0, 2)); } if (((my->count[3] >= 820) && (my->count[3] < 876)) || ((my->count[3] >= 2695) && (my->count[3] < 2751))) { if (my->count[3] < 876) t = my->count[3] - 820; else t = my->count[3] - 2695; if (t % 2 == 0) speed = 3.5; else speed = 4.5; tenm_table_add(laser_angle_new(my->x - 36.0 + my->count_d[2], my->y + my->count_d[3], speed, 178 + 5 * (t % 28), 25.0, 2)); tenm_table_add(laser_angle_new(my->x + 36.0 + my->count_d[2], my->y + my->count_d[3], speed, 88 - 5 * (t % 28), 25.0, 2)); } if ((my->count[3] >= 1900) && (my->count[3] < 1960)) { t = my->count[3] - 1900; tenm_table_add(laser_angle_new(my->x + 36.0 + my->count_d[2], my->y + my->count_d[3], 2.0, 2 - 15 * (t % 10), 25.0, 2)); tenm_table_add(laser_angle_new(my->x - 36.0 + my->count_d[2], my->y + my->count_d[3], 2.0, 92 + 15 * (t % 10), 25.0, 2)); } if ((my->count[3] >= 1900) && (my->count[3] < 1956)) { t = my->count[3] - 1900; if (t % 2 == 0) speed = 3.5; else speed = 4.5; tenm_table_add(laser_angle_new(my->x + 36.0 + my->count_d[2], my->y + my->count_d[3], speed, 2 - 5 * (t % 28), 25.0, 2)); tenm_table_add(laser_angle_new(my->x - 36.0 + my->count_d[2], my->y + my->count_d[3], speed, 92 + 5 * (t % 28), 25.0, 2)); } if ((my->count[3] >= 2835) && (my->count[3] <= 3825) && (my->count[3] % 30 == 15)) { x = player->x - my->x; y = player->y - (my->y - 80.0); length = tenm_sqrt((int) (x * x + y * y)); if (length < NEAR_ZERO) length = 1.0; for (i = -2; i <= 2; i++) tenm_table_add(normal_shot_new(my->x, my->y - 80.0 + 40.0 * ((double) i), 4.0 * x / length, 4.0 * y / length - 0.6 * ((double) i), 5, -2, 0)); } } else if (my->count[2] == 3) { /* hand */ if (my->count[3] == 60) { my->count[6] = rand() % 2; } else if (my->count[3] % 420 == 60) { if (rand() % 3 != 0) my->count[6] = 1 - my->count[6]; } if ((my->count[3] < 2940) && (my->count[3] % 420 >= 60)) { t = (my->count[3] - 60) % 420; length = 50.0 / tenm_sqrt(2); x = 50.0; y = 25.0; for (i = 0; i < 2; i++) { dx = length * tenm_cos(my->count[4 + i]); dy = length * tenm_sin(my->count[4 + i]); switch (my->count[6]) { case 0: if ((t % 5 == 0) || ((my->count[3] >= 900) && (t % 5 < 3))) { if (i == 1) { tenm_table_add(laser_angle_new(my->x + x + dx, my->y + y + dy, 5.0, t * 11, 25.0, 2)); tenm_table_add(laser_angle_new(my->x - x - dx, my->y + y + dy, 5.0, 180 - t * 11, 25.0, 2)); } } if (t % 13 == 0) { tenm_table_add(normal_shot_point_new(my->x, my->y, 4.0, player->x, player->y, 4)); } break; case 1: if (t % 19 == 0) { if (i == 0) { tenm_table_add(laser_point_new(my->x + x + dx, my->y + y + dy, 5.5, player->x - 100.0, player->y, 25.0, 0)); tenm_table_add(laser_point_new(my->x - x - dx, my->y + y + dy, 5.5, player->x + 100.0, player->y, 25.0, 0)); if (my->count[3] >= 900) { tenm_table_add(laser_point_new(my->x + x + dx, my->y + y + dy, 7.5, player->x + 100.0, player->y, 25.0, 0)); tenm_table_add(laser_point_new(my->x - x - dx, my->y + y + dy, 7.5, player->x - 100.0, player->y, 25.0, 0)); } } else if (i == 1) { tenm_table_add(laser_point_new(my->x + x + dx, my->y + y + dy, 4.0, player->x, player->y, 25.0, 1)); tenm_table_add(laser_point_new(my->x - x - dx, my->y + y + dy, 4.0, player->x, player->y, 25.0, 1)); } } break; default: fprintf(stderr, "insane_hand_draw: undefined shoot mode (%d)\n", my->count[6]); break; } x += dx; y += dy; } } } return 0; } static int insane_hand_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; int theta_rotate; double length_hand; double x; double y; double dx; double dy; int i; int width; /* sanity check */ if (my == NULL) { fprintf(stderr, "insane_hand_draw: my is NULL\n"); return 0; } theta_rotate = 0; if (my->count[2] == 0) { if (my->count[3] >= 240) theta_rotate = 0; else if (my->count[3] < 150) theta_rotate = -180; else theta_rotate = -180 + (my->count[3] - 150) * 2; } /* decoration */ if ((priority == 0) && (my->count[2] <= 1)) { if (insane_hand_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(181, 190, 92); else color = tenm_map_color(157, 182, 123); } else { if (my->count[1] >= 1) color = tenm_map_color(200, 164, 92); else color = tenm_map_color(182, 147, 123); } /* shaft */ if (insane_hand_body_line(my->x + 20.0, my->y - 25.0, my->x + 20.0, my->y - 625.0, 1, color, theta_rotate) != 0) status = 1; if (insane_hand_body_line(my->x - 20.0, my->y - 25.0, my->x - 20.0, my->y - 625.0, 1, color, theta_rotate) != 0) status = 1; } /* body */ /* dead enemy has low priority */ if (((my->count[2] <= 3) && (priority == 0)) || ((my->count[2] > 3) && (priority == -1))) { if (insane_hand_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 1) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } /* hand */ if (my->count[2] <= 3) { length_hand = 50.0 / tenm_sqrt(2); x = 50.0; y = 25.0; for (i = 0; i < 2; i++) { dx = length_hand * tenm_cos(my->count[4 + i]); dy = length_hand * tenm_sin(my->count[4 + i]); if (insane_hand_body_line(my->x + x, my->y + y, my->x + x + dx, my->y + y + dy, 1, color, theta_rotate) != 0) status = 1; if (insane_hand_body_line(my->x - x, my->y + y, my->x - x - dx, my->y + y + dy, 1, color, theta_rotate) != 0) status = 1; x += dx; y += dy; } } /* core */ if (my->count[2] == 0) width = 1; else width = 3; if (insane_hand_body_line(my->x + 50.0, my->y - 25.0, my->x + 50.0, my->y + 25.0, width, color, theta_rotate) != 0) status = 1; if (insane_hand_body_line(my->x + 50.0, my->y + 25.0, my->x - 50.0, my->y + 25.0, width, color, theta_rotate) != 0) status = 1; if (insane_hand_body_line(my->x - 50.0, my->y + 25.0, my->x - 50.0, my->y - 25.0, width, color, theta_rotate) != 0) status = 1; if (insane_hand_body_line(my->x - 50.0, my->y - 25.0, my->x + 50.0, my->y - 25.0, width, color, theta_rotate) != 0) status = 1; } /* hit point stat */ if ((priority == 0) && ((my->count[2] == 1) || (my->count[2] == 3))) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 10, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "insane_hand_draw: draw_string failed\n"); status = 1; } } return status; } static int insane_hand_body_line(double a_x, double a_y, double b_x, double b_y, int width, tenm_color color, int theta) { double a_result[2]; double a_v[2]; double b_result[2]; double b_v[2]; a_v[0] = a_x; a_v[1] = a_y; a_result[0] = a_v[0]; a_result[1] = a_v[1]; insane_hand_body_rotate(a_result, a_v, theta); b_v[0] = b_x; b_v[1] = b_y; b_result[0] = b_v[0]; b_result[1] = b_v[1]; insane_hand_body_rotate(b_result, b_v, theta); return tenm_draw_line((int) (a_result[0]), (int) (a_result[1]), (int) (b_result[0]), (int) (b_result[1]), width, color); } /* rotate the point v (arg 2) which is a part of the boss * by theta (arg 3) degree * result (arg 1) and v (arg 2) must be double[2] (you must allocate enough * memory before calling this function) * the result is undefined if result (arg 1) and v (arg 2) overlap */ static void insane_hand_body_rotate(double *result, const double *v, int theta) { double temp_result[2]; double temp_v[2]; double center_x = (double) (WINDOW_WIDTH / 2); double center_y = (double) (WINDOW_HEIGHT / 2); /* sanity check */ if (result == NULL) { fprintf(stderr, "insane_hand_body_rotate: result is NULL\n"); return; } if (v == NULL) { fprintf(stderr, "insane_hand_body_rotate: v is NULL\n"); return; } temp_v[0] = v[0] - center_x; temp_v[1] = v[1] - center_y; temp_result[0] = temp_v[0]; temp_result[1] = temp_v[1]; vector_rotate(temp_result, temp_v, theta); result[0] = temp_result[0] + center_x; result[1] = temp_result[1] + center_y; } /* return 1 (true) or 0 (false) */ static int insane_hand_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if ((my->count[2] == 1) && (my->count[3] >= 800) && (my->count[3] < 4040)) return 1; if ((my->count[2] == 3) && (my->count[3] >= 900) && (my->count[3] < 3000)) return 1; if (((my->count[2] == 2) || (my->count[2] == 4)) && (my->count[7] != 0)) return 1; return 0; } static tenm_object * insane_hand_ship_new(double x, double y) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; int i; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 2); if (p == NULL) { fprintf(stderr, "insane_hand_ship_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 32.0, y + 18.0, x + 23.0, y + 30.0, x - 41.0, y - 18.0, x - 32.0, y - 30.0); if (p[0] == NULL) { fprintf(stderr, "insane_hand_ship_new: cannot set p[0]\n"); free(p); return NULL; } p[1] = (tenm_primitive *) tenm_polygon_new(4, x + 9.0, y - 18.0, x - 18.0, y + 18.0, x - 50.0, y - 6.0, x - 23.0, y - 42.0); if (p[1] == NULL) { fprintf(stderr, "insane_hand_ship_new: cannot set p[0]\n"); (p[0])->delete(p[0]); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 5); if (count == NULL) { fprintf(stderr, "insane_hand_ship_new: malloc(count) failed\n"); for (i = 0; i < 2; i++) (p[i])->delete(p[i]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "insane_hand_ship_new: malloc(count_d) failed\n"); free(count); for (i = 0; i < 2; i++) (p[i])->delete(p[i]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] life timer * [3] shoot timer * [4] bit index */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = 0; count[1] = 0; count[2] = -70; count[3] = 0; count[4] = -1; count_d[0] = 0.0; count_d[1] = -6.0; new = tenm_object_new("Insane Hand ship", ATTR_ENEMY, ATTR_PLAYER_SHOT, 400, x, y, 5, count, 2, count_d, 2, p, (int (*)(tenm_object *, double)) (&insane_hand_ship_move), (int (*)(tenm_object *, tenm_object *)) (&insane_hand_ship_hit), (int (*)(tenm_object *, const tenm_object *)) (&insane_hand_ship_act), (int (*)(tenm_object *, int)) (&insane_hand_ship_draw)); if (new == NULL) { fprintf(stderr, "insane_hand_ship_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); for (i = 0; i < 2; i++) (p[i])->delete(p[i]); free(p); return NULL; } return new; } static int insane_hand_ship_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "insane_hand_ship_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "insane_hand_ship_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); if ((my->count[2] > 0) && (!in_window_object(my))) return 1; return 0; } static int insane_hand_ship_hit(tenm_object *my, tenm_object *your) { int n; /* sanity check */ if (my == NULL) { fprintf(stderr, "insane_hand_ship_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "insane_hand_ship_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; deal_damage(my, your, 0); if (insane_hand_ship_green(my)) add_chain(my, your); my->count[1] = 41; if (my->hit_point <= 0) { add_score(15000); if (my->count[4] >= 0) tenm_table_apply(my->count[4], (int (*)(tenm_object *, int)) (&insane_hand_ship_signal_bit), 0); if (insane_hand_ship_green(my)) n = 8; else n = 7; tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 1000, n, 8.0, 6)); tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 2, 300, n, 5.0, 8)); return 1; } return 0; } static int insane_hand_ship_signal_bit(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "Insane Hand ship bit") != 0) return 0; tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 1000, 9, 8.0, 6)); tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 2, 300, 9, 5.0, 8)); return 1; } static int insane_hand_ship_act(tenm_object *my, const tenm_object *player) { int i; /* sanity check */ if (my == NULL) { fprintf(stderr, "insane_hand_ship_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; (my->count[2])++; if (my->count[2] == -69) my->count[4] = tenm_table_add(insane_hand_ship_bit_new(my->x + 52.0, my->y + 39.0)); if (my->count[2] == 0) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[2] == 1090) { my->count_d[0] = 6.0; my->count_d[1] = 0.0; } if (my->count[2] == 1135) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[2] >= 1140) { my->count_d[1] += 0.1; } if ((my->count[2] <= 90) || (my->count[2] >= 990)) return 0; (my->count[3])++; if (my->count[3] % 100 == 0) { for (i = -4; i <= 4; i++) { tenm_table_add(insane_hand_ship_shot_new(my->x, my->y, 7.0 * tenm_cos(15 * i), 7.0 * tenm_sin(15 * i))); } } return 0; } static int insane_hand_ship_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; /* sanity check */ if (my == NULL) { fprintf(stderr, "insane_hand_ship_draw: my is NULL\n"); return 0; } /* body */ if (priority == 0) { if (insane_hand_ship_green(my)) { if (my->count[1] >= 40) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 40) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (tenm_draw_line((int) (my->x + 32.0), (int) (my->y + 18.0), (int) (my->x + 23.0), (int) (my->y + 30.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 23.0), (int) (my->y + 30.0), (int) (my->x - 9.0), (int) (my->y + 6.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 9.0), (int) (my->y + 6.0), (int) (my->x - 18.0), (int) (my->y + 18.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 18.0), (int) (my->y + 18.0), (int) (my->x - 50.0), (int) (my->y - 6.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 50.0), (int) (my->y - 6.0), (int) (my->x - 23.0), (int) (my->y - 42.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 23.0), (int) (my->y - 42.0), (int) (my->x + 9.0), (int) (my->y - 18.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 9.0), (int) (my->y - 18.0), (int) (my->x), (int) (my->y - 6.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x), (int) (my->y - 6.0), (int) (my->x + 32.0), (int) (my->y + 18.0), 3, color) != 0) status = 1; } /* hit point stat */ if ((priority == 0) && (my->count[1] > 0)) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 33, ((int) (my->y)) - 10, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "insane_hand_ship_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int insane_hand_ship_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if ((my->count[2] > 90) && (my->count[2] < 1090)) return 1; return 0; } static tenm_object * insane_hand_ship_bit_new(double x, double y) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "insane_hand_ship_bit_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_circle_new(x, y, 25.0); if (p[0] == NULL) { fprintf(stderr, "insane_hand_ship_bit_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 2); if (count == NULL) { fprintf(stderr, "insane_hand_ship_bit_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 4); if (count_d == NULL) { fprintf(stderr, "insane_hand_ship_bit_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] life timer * [1] shoot timer */ /* list of count_d * [0] speed x * [1] speed y * [2] origin x * [3] origin y */ count[0] = -69; count[1] = 0; count_d[0] = 0.0; count_d[1] = -6.0; count_d[2] = 0.0; count_d[3] = 0.0; new = tenm_object_new("Insane Hand ship bit", ATTR_ENEMY, 0, 1, x, y, 2, count, 4, count_d, 1, p, (int (*)(tenm_object *, double)) (&insane_hand_ship_bit_move), (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&insane_hand_ship_bit_act), (int (*)(tenm_object *, int)) (&insane_hand_ship_bit_draw)); if (new == NULL) { fprintf(stderr, "insane_hand_ship_bit_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int insane_hand_ship_bit_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "insane_hand_ship_bit_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "insane_hand_ship_bit_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); if ((my->count[0] > 0) && (!in_window_object(my))) return 1; return 0; } static int insane_hand_ship_bit_act(tenm_object *my, const tenm_object *player) { double x; double y; double px; double py; /* sanity check */ if (my == NULL) { fprintf(stderr, "insane_hand_ship_bit_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[0])++; if (my->count[0] == 0) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; my->count_d[2] = my->x; my->count_d[3] = my->y; } if (my->count[0] == 990) { my->count_d[0] = (my->count_d[2] - my->x) / 100.0; my->count_d[1] = (my->count_d[3] - my->y) / 100.0; } if (my->count[0] == 1090) { my->count_d[0] = 6.0; my->count_d[1] = 0.0; } if (my->count[0] == 1135) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[0] >= 1140) { my->count_d[1] += 0.1; } if ((my->count[0] <= 30) || (my->count[0] >= 990)) return 0; (my->count[1])++; /* speed change */ x = my->x * 0.8 + my->y * 0.6; y = -(my->x) * 0.6 + my->y * 0.8; px = player->x * 0.8 + player->y * 0.6; py = -(player->x) * 0.6 + player->y * 0.8; my->count_d[0] = 0.0; my->count_d[1] = 0.0; /* don't chase if the player is immutable */ if ((get_ship() < 0) || (player->count[1] > 0)) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } else if (x - 25.0 > px) { my->count_d[0] = -3.2; my->count_d[1] = -2.4; } else if (x - 10.0 < px) { my->count_d[0] = 3.2; my->count_d[1] = 2.4; } else if (y - 5.0 > py) { my->count_d[0] = 1.2; my->count_d[1] = -1.6; } else if (y + 5.0 < py) { my->count_d[0] = -1.2; my->count_d[1] = 1.6; } if (my->x + my->count_d[0] < 0.0) my->count_d[0] = 0.0 - my->x; if (my->x + my->count_d[0] > ((double) WINDOW_WIDTH)) my->count_d[0] = ((double) WINDOW_WIDTH) - my->x; if (my->y + my->count_d[1] < 0.0) my->count_d[1] = 0.0 - my->y; if (my->y + my->count_d[1] > ((double) WINDOW_HEIGHT)) my->count_d[1] = ((double) WINDOW_HEIGHT) - my->y; /* shoot */ if (my->count[1] % 30 == 0) { tenm_table_add(laser_new(my->x, my->y, 3.0, -4.0, 15.0, -20.0, 0, -2, 0)); tenm_table_add(laser_new(my->x, my->y, -3.0, 4.0, -15.0, 20.0, 0, -2, 0)); tenm_table_add(laser_new(my->x, my->y, -4.0 * tenm_cos(15) + (-3.0) * (-tenm_sin(15)), -4.0 * tenm_sin(15) + (-3.0) * tenm_cos(15), -20.0 * tenm_cos(15) + (-15.0) * (-tenm_sin(15)), -20.0 * tenm_sin(15) + (-15.0) * tenm_cos(15), 0, -2, 0)); tenm_table_add(laser_new(my->x, my->y, -4.0 * tenm_cos(-15) + (-3.0) * (-tenm_sin(-15)), -4.0 * tenm_sin(-15) + (-3.0) * tenm_cos(-15), -20.0 * tenm_cos(-15) +(-15.0) * (-tenm_sin(-15)), -20.0 * tenm_sin(-15) +(-15.0) * tenm_cos(-15), 0, -2, 0)); } return 0; } static int insane_hand_ship_bit_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; /* sanity check */ if (my == NULL) return 0; if (priority != 0) return 0; /* decoration */ color = tenm_map_color(182, 123, 162); if (tenm_draw_line((int) (my->x + 15.0), (int) (my->y - 20.0), (int) (my->x + 15.0 - 40.0 * tenm_cos(15) - 30.0 * (-tenm_sin(15))), (int) (my->y - 20.0 - 40.0 * tenm_sin(15) - 30.0 * tenm_cos(15)), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 15.0), (int) (my->y + 20.0), (int) (my->x - 15.0 - 40.0 * tenm_cos(-15) - 30.0 * (-tenm_sin(-15))), (int) (my->y + 20.0 - 40.0 * tenm_sin(-15) - 30.0 * tenm_cos(-15)), 1, color) != 0) status = 1; /* body */ color = tenm_map_color(95, 13, 68); if (tenm_draw_circle((int) (my->x), (int) (my->y), 25, 3, color) != 0) status = 1; return status; } static tenm_object * insane_hand_ship_shot_new(double x, double y, double v_x, double v_y) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; /* sanity check */ if (v_x * v_x + v_y * v_y < NEAR_ZERO) { fprintf(stderr, "insane_hand_ship_shot_new: speed is too small " "(%f, %f)\n", v_x, v_y); return NULL; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "insane_hand_ship_shot_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_circle_new(x, y, 5.0); if (p[0] == NULL) { fprintf(stderr, "insane_hand_ship_shot_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 1); if (count == NULL) { fprintf(stderr, "insane_hand_ship_shot_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 4); if (count_d == NULL) { fprintf(stderr, "insane_hand_ship_shot_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } if (v_y > 0.1) { count_d[2] = -(-0.25) * 0.6; count_d[3] = (-0.25) * 0.8; } else if (v_y < -0.1) { count_d[2] = -(0.25) * 0.6; count_d[3] = (0.25) * 0.8; } else { count_d[2] = 0.0; count_d[3] = 0.0; } /* list of count * [0] color (for delete_enemy_shot) */ count[0] = 4; /* list of count_d * [0] dx * [1] dy * [2] ddx * [3] ddy */ count_d[0] = v_x * 0.8 - v_y * 0.6; count_d[1] = v_x * 0.6 + v_y * 0.8; new = tenm_object_new("Insane Hand ship shot", ATTR_ENEMY_SHOT, ATTR_OPAQUE, 1, x, y, 1, count, 4, count_d, 1, p, (int (*)(tenm_object *, double)) (&insane_hand_ship_shot_move), (int (*)(tenm_object *, tenm_object *)) (&insane_hand_ship_shot_hit), (int (*)(tenm_object *, const tenm_object *)) (&insane_hand_ship_shot_act), (int (*)(tenm_object *, int)) (&insane_hand_ship_shot_draw)); if (new == NULL) { fprintf(stderr, "insane_hand_ship_shot_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int insane_hand_ship_shot_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "insane_hand_ship_shot_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "insane_hand_ship_shot_move: " "strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; tenm_move_mass(my->mass, dx_temp, dy_temp); if (!in_window_object(my)) return 1; return 0; } static int insane_hand_ship_shot_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "insane_hand_ship_shot_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "insane_hand_ship_shot_hit: your is NULL\n"); return 0; } if (your->attr & ATTR_OPAQUE) return 1; return 0; } static int insane_hand_ship_shot_act(tenm_object *my, const tenm_object *player) { /* sanity check */ if (my == NULL) { fprintf(stderr, "insane_hand_ship_shot_act: my is NULL\n"); return 0; } if (player == NULL) return 0; my->count_d[0] += my->count_d[2]; my->count_d[1] += my->count_d[3]; return 0; } static int insane_hand_ship_shot_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; /* sanity check */ if (my == NULL) { fprintf(stderr, "insane_hand_ship_shot_draw: my is NULL\n"); return 0; } /* return if it is not my turn */ if (priority != 1) return 0; color = tenm_map_color(75, 0, 239); if (tenm_draw_circle((int) (my->x), (int) (my->y), 5, 2, color) != 0) status = 1; return status; } dangen-0.5/spqr/insane-hand.h0000644000175000017500000000035510276702741016752 0ustar00ooharaoohara00000000000000/* $Id: insane-hand.h,v 1.1 2004/06/08 06:22:08 oohara Exp $ */ #ifndef __DANGEN_INSANE_HAND_H__ #define __DANGEN_INSANE_HAND_H__ #include "tenm_object.h" tenm_object *insane_hand_new(void); #endif /* not __DANGEN_INSANE_HAND_H__ */ dangen-0.5/spqr/laser.c0000644000175000017500000001620110276702741015663 0ustar00ooharaoohara00000000000000/* $Id: laser.c,v 1.51 2004/08/13 15:27:39 oohara Exp $ */ #include /* malloc, rand */ #include #include "const.h" #include "tenm_object.h" #include "tenm_math.h" #include "tenm_graphic.h" #include "util.h" #include "tenm_primitive.h" #include "laser.h" #define NEAR_ZERO 0.0001 static int laser_move(tenm_object *my, double turn_per_frame); static int laser_act(tenm_object *my, const tenm_object *player); static int laser_draw(tenm_object *my, int priority); /* speed must be positive --- use laser_new instead if you want a laser * that doesn't move */ tenm_object * laser_angle_new(double x, double y, double speed, int theta, double length, int color) { /* sanity check */ if (speed < NEAR_ZERO) { fprintf(stderr, "laser_angle_new: speed is non-positive (%f)\n", speed); return NULL; } if (length <= NEAR_ZERO) { fprintf(stderr, "laser_angle_new: length is non-positive (%f)\n", length); return NULL; } return laser_new(x, y, speed * tenm_cos(theta), speed * tenm_sin(theta), length * tenm_cos(theta), length * tenm_sin(theta), color, -2, 0); } /* speed must be positive --- use laser_new instead if you want a laser * that doesn't move * if (x, y) and (target_x, target_y) are very close, shoot at a random * direction */ tenm_object * laser_point_new(double x, double y, double speed, double target_x, double target_y, double length, int color) { double dx; double dy; double temp; int temp_theta; /* sanity check */ if (speed < NEAR_ZERO) { fprintf(stderr, "laser_point_new: speed is non-positive (%f)\n", speed); return NULL; } if (length <= NEAR_ZERO) { fprintf(stderr, "laser_point_new: length is non-positive (%f)\n", length); return NULL; } dx = target_x - x; dy = target_y - y; temp = tenm_sqrt((int) (dx * dx + dy * dy)); if (temp <= NEAR_ZERO) { /* shoot at a random direction */ temp_theta = rand() % 360; dx = tenm_cos(temp_theta); dy = tenm_sin(temp_theta); temp = 1.0; } return laser_new(x, y, speed * dx / temp, speed * dy / temp, length * dx / temp, length * dy / temp, color, -2, 0); } /* list of count * [0] color * [1] life */ /* list of count_d * [0] speed x * [1] speed y */ /* if life > 0 when created, the shot disappears after _life frames * when immortal > 0, the shot does not disappear even if * it is out of the window */ tenm_object * laser_new(double x, double y, double speed_x, double speed_y, double length_x, double length_y, int color, int life, int immortal_time) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; /* sanity check */ if (life == 0) { fprintf(stderr, "laser_new: life is 0\n"); return NULL; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "laser_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_segment_new(x, y, x + length_x, y + length_y); if (p[0] == NULL) { fprintf(stderr, "laser_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 3); if (count == NULL) { fprintf(stderr, "laser_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "laser_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } count[0] = color; count[1] = life; count[2] = immortal_time; count_d[0] = speed_x; count_d[1] = speed_y; new = tenm_object_new("laser", ATTR_ENEMY_SHOT, 0, 1, x, y, 3, count, 2, count_d, 1, p, (int (*)(tenm_object *, double)) (&laser_move), NULL, (int (*)(tenm_object *, const tenm_object *)) (&laser_act), (int (*)(tenm_object *, int)) (&laser_draw)); if (new == NULL) { fprintf(stderr, "laser_new: tenm_object_new failed\n"); free(count_d); free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int laser_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "laser_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "laser_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; tenm_move_mass(my->mass, dx_temp, dy_temp); if ((my->count[2] <= 0) && (!in_window_object(my))) return 1; return 0; } static int laser_act(tenm_object *my, const tenm_object *player) { /* sanity check */ if (my == NULL) { fprintf(stderr, "laser_act: my is NULL\n"); return 0; } /* player == NULL is OK */ if (my->count[1] > 0) { (my->count[1])--; if (my->count[1] <= 0) return 1; } if (my->count[2] > 0) (my->count[2])--; return 0; } static int laser_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; /* sanity check */ if (my == NULL) { fprintf(stderr, "laser_draw: my is NULL\n"); return 0; } if (my->mass == NULL) { fprintf(stderr, "laser_draw: my->mass is NULL\n"); return 0; } /* return if it is not my turn */ if (priority != 1) return 0; switch (my->count[0]) { case 0: color = tenm_map_color(49, 191, 0); color = tenm_map_color(0, 223, 55); color = tenm_map_color(0, 191, 47); break; case 1: color = tenm_map_color(0, 223, 55); color = tenm_map_color(0, 191, 127); break; case 2: color = tenm_map_color(0, 191, 255); color = tenm_map_color(0, 167, 223); break; case 3: color = tenm_map_color(0, 127, 255); color = tenm_map_color(0, 111, 223); break; case 4: color = tenm_map_color(70, 0, 223); color = tenm_map_color(75, 0, 239); break; case 5: color = tenm_map_color(163, 0, 223); color = tenm_map_color(175, 0, 239); break; default: fprintf(stderr, "laser_draw: strange my->count[0] (%d)\n", my->count[0]); color = tenm_map_color(0, 0, 0); break; } /* width > 1 costs much, but width = 1 looks too bad */ if (tenm_draw_line((int) (((tenm_segment *) my->mass->p[0])->a->x), (int) (((tenm_segment *) my->mass->p[0])->a->y), (int) (((tenm_segment *) my->mass->p[0])->b->x), (int) (((tenm_segment *) my->mass->p[0])->b->y), 3, color) != 0) status = 1; /* if (tenm_draw_primitive(my->mass->p[0], tenm_map_color(0, 0, 0)) != 0) status = 1; */ return status; } dangen-0.5/spqr/laser.h0000644000175000017500000000130510276702741015667 0ustar00ooharaoohara00000000000000/* $Id: laser.h,v 1.7 2004/07/06 02:50:57 oohara Exp $ */ #ifndef __DANGEN_LASER_H__ #define __DANGEN_LASER_H__ #include "tenm_object.h" tenm_object *laser_angle_new(double x, double y, double speed, int theta, double length, int color); tenm_object *laser_point_new(double x, double y, double speed, double target_x, double target_y, double length, int color); tenm_object *laser_new(double x, double y, double speed_x, double speed_y, double length_x, double length_y, int color, int life, int immortal_time); #endif /* not __DANGEN_LASER_H__ */ dangen-0.5/spqr/last-boss.c0000644000175000017500000016617110276702741016500 0ustar00ooharaoohara00000000000000/* $Id: last-boss.c,v 1.431 2005/07/12 20:33:12 oohara Exp $ */ #include /* malloc, rand */ #include /* strlen */ #include #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "const.h" #include "tenm_table.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "util.h" #include "background.h" #include "chain.h" #include "explosion.h" #include "stage-clear.h" #include "score.h" #include "ship.h" /* deal_damage */ #include "player-shot.h" #include "last-boss.h" #define NEAR_ZERO 0.0001 static int last_boss_hit(tenm_object *my, tenm_object *your); static void last_boss_next(tenm_object *my); static int last_boss_act(tenm_object *my, const tenm_object *player); static int last_boss_act_0(tenm_object *my, const tenm_object *player); static int last_boss_act_1(tenm_object *my, const tenm_object *player); static int last_boss_act_2(tenm_object *my, const tenm_object *player); static int last_boss_act_3(tenm_object *my, const tenm_object *player); static int last_boss_act_4(tenm_object *my, const tenm_object *player); static int last_boss_act_5(tenm_object *my, const tenm_object *player); static int last_boss_draw(tenm_object *my, int priority); static int last_boss_green(const tenm_object *my); static tenm_object *last_boss_cage_new(int n); static int last_boss_cage_act(tenm_object *my, const tenm_object *player); static int last_boss_cage_draw(tenm_object *my, int priority); static tenm_object *last_boss_star_dust_new(int n); static int last_boss_star_dust_act(tenm_object *my, const tenm_object *player); static int last_boss_star_dust_draw(tenm_object *my, int priority); static tenm_object * last_boss_spotlight_new(int n); static int last_boss_spotlight_act(tenm_object *my, const tenm_object *player); static int last_boss_spotlight_draw(tenm_object *my, int priority); static tenm_object *last_boss_horizon_circle_new(int n); static int last_boss_horizon_circle_act(tenm_object *my, const tenm_object *player); static int last_boss_horizon_circle_sights(double *result, const double *v1, const double *v2); static int last_boss_horizon_circle_draw(tenm_object *my, int priority); static tenm_object *last_boss_horizon_new(double x, double y, int n); static int last_boss_horizon_act(tenm_object *my, const tenm_object *player); static int last_boss_horizon_draw(tenm_object *my, int priority); static tenm_object *last_boss_twist_circle_new(int n); static int last_boss_twist_circle_act(tenm_object *my, const tenm_object *player); static int last_boss_twist_circle_draw(tenm_object *my, int priority); static tenm_object *last_boss_matrix_new(int n); static int last_boss_matrix_act(tenm_object *my, const tenm_object *player); static tenm_object *last_boss_cross_circle_new(int n); static int last_boss_cross_circle_act(tenm_object *my, const tenm_object *player); static int last_boss_cross_circle_draw(tenm_object *my, int priority); static tenm_object *last_boss_cross_new(double x, double y, int n); static int last_boss_cross_act(tenm_object *my, const tenm_object *player); static int last_boss_cross_draw(tenm_object *my, int priority); tenm_object * last_boss_new(void) { int i; int suffix; tenm_object *new = NULL; int *count = NULL; tenm_primitive **p = NULL; double x = (double) (WINDOW_WIDTH / 2); double y = (double) (WINDOW_HEIGHT / 4); p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "last_boss_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_circle_new(x, y, 60.0); if (p[0] == NULL) { fprintf(stderr, "last_boss_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 19); if (count == NULL) { (p[0])->delete(p[0]); free(p); fprintf(stderr, "last_boss_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] mode * [1] shoot timer * [2] demo timer * [3] for deal_damage * [4 -- 15] decoration circle management * suffix + 0: center x * suffix + 1: center y * suffix + 2: radius * [16] immutable timer * [17] "damaged" timer * [18] "was green when killed" flag */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 0; for (i = 0; i < 4; i++) { suffix = i * 3 + 4; if (i == 0) { count[suffix + 0] = WINDOW_WIDTH / 2; count[suffix + 1] = WINDOW_HEIGHT / 4; count[suffix + 2] = -240 + 2; } else { count[suffix + 0] = WINDOW_WIDTH / 2 - 50 + (rand() % 100); count[suffix + 1] = WINDOW_HEIGHT / 4 - 50 + (rand() % 100); count[suffix + 2] = (i - 1) * (-80) + 2; } } count[16] = 0; count[17] = 0; count[18] = 0; new = tenm_object_new("L", 0, 0, 750, x, y, 19, count, 0, NULL, 1, p, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) (&last_boss_hit), (int (*)(tenm_object *, const tenm_object *)) (&last_boss_act), (int (*)(tenm_object *, int)) (&last_boss_draw)); if (new == NULL) { fprintf(stderr, "last_boss_new: tenm_object_new failed\n"); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int last_boss_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) return 0; if (your == NULL) return 0; if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if (my->count[2] >= 0) return 0; if (my->count[16] > 0) return 0; deal_damage(my, your, 3); if (last_boss_green(my)) add_chain(my, your); my->count[17] = 2; if (my->hit_point <= 0) { set_background(1); switch (my->count[0]) { case 0: add_score(20000); break; case 1: add_score(30000); break; case 2: add_score(40000); break; case 3: add_score(50000); break; case 4: add_score(60000); break; case 5: add_score(100000); break; default: fprintf(stderr, "last_boss_hit: undefined mode (%d)\n", my->count[0]); break; } last_boss_next(my); return 0; } return 0; } static void last_boss_next(tenm_object *my) { int n; /* sanity check */ if (my == NULL) { fprintf(stderr, "last_boss_next: my is NULL\n"); return; } tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy), 0); /* set "was green" flag before we change the life mode */ if (last_boss_green(my)) { n = 8; my->count[18] = 1; } else { n = 7; my->count[18] = 0; } tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 5000, n, 10.0, 6)); (my->count[0])++; if (my->count[0] == 1) { my->hit_point = 1000; } else if (my->count[0] == 2) { my->hit_point = 600; } else if (my->count[0] == 3) { my->hit_point = 750; } else if (my->count[0] == 4) { my->hit_point = 400; } else if (my->count[0] == 5) { my->hit_point = 1500; } else { /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ tenm_mass_delete(my->mass); my->mass = NULL; } my->count[1] = 0; my->count[2] = 0; my->count[17] = 0; } static int last_boss_act(tenm_object *my, const tenm_object *player) { int i; int suffix; int theta; /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; /* for deal_damage */ my->count[3] = 0; /* "damaged" count down */ if (my->count[17] > 0) (my->count[17])--; /* encounter */ if ((my->count[0] == 0) && (my->count[2] == 210)) { my->attr = ATTR_BOSS; my->hit_mask = ATTR_PLAYER_SHOT; } /* dead */ if (my->count[0] == 6) { my->count[16] = 0; (my->count[1])++; if (last_boss_green(my)) i = 8; else i = 7; if ((my->count[1] >= 30) && (my->count[1] <= 90) && (my->count[1] % 5 == 0)) { theta = rand() % 360; tenm_table_add(explosion_new(my->x + 30.0 * tenm_cos(theta), my->y + 30.0 * tenm_sin(theta), 0.0, 0.0, 2, 300, i, 5.0, 8)); } if (my->count[1] == 120) { tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 15000, i, 16.0, 15)); tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 2, 3000, i, 12.0, 15)); tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 3, 600, i, 9.0, 15)); tenm_table_add(stage_clear_new(200)); return 1; } return 0; } /* the boss is immutable if the player is immutable */ if ((get_ship() < 0) || (player->count[1] > 0)) my->count[16] = 100; else if (my->count[16] > 0) (my->count[16])--; /* decoration management */ for (i = 0; i < 4; i++) { suffix = i * 3 + 4; my->count[suffix + 2] += 2; if (my->count[suffix + 2] > 60) { if (i != 0) { my->count[suffix + 0] = (WINDOW_WIDTH / 2) - 50 + (rand() % 100); my->count[suffix + 1] = (WINDOW_HEIGHT / 4) - 50 + (rand() % 100); } my->count[suffix + 2] = 2; } } /* attack */ if (my->count[0] == 0) { last_boss_act_0(my, player); } else if (my->count[0] == 1) { last_boss_act_1(my, player); } else if (my->count[0] == 2) { last_boss_act_2(my, player); } else if (my->count[0] == 3) { last_boss_act_3(my, player); } else if (my->count[0] == 4) { last_boss_act_4(my, player); } else if (my->count[0] == 5) { last_boss_act_5(my, player); } return 0; } static int last_boss_act_0(tenm_object *my, const tenm_object *player) { /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; if (my->count[2] >= 0) { (my->count[2])++; if ((my->count[2] == 240) || (my->count[2] == 300) || (my->count[2] == 345) || (my->count[2] == 375) || (my->count[2] == 400) || (my->count[2] == 420)) tenm_table_add(last_boss_star_dust_new(1)); if ((my->count[2] == 440) || (my->count[2] == 460) || (my->count[2] == 480) || (my->count[2] == 500) || (my->count[2] == 520) || (my->count[2] == 540)) tenm_table_add(last_boss_star_dust_new(0)); if (my->count[2] >= 559) { my->count[1] = 0; my->count[2] = -1; return 0; } return 0; } /* self-destruction */ (my->count[2])--; if (my->count[2] <= -4030) { set_background(2); clear_chain(); last_boss_next(my); return 0; } if (my->count[1] == 0) { tenm_table_add(last_boss_star_dust_new(0)); } tenm_table_add(laser_angle_new(my->x + (double) (-40 + (rand() % 81)), my->y + (double) (-40 + (rand() % 81)), 8.5 + ((double) (rand() % 8)) / 4.0, rand() % 360, 25.0, 3)); (my->count[1])++; if (my->count[1] >= 20) my->count[1] = 0; return 0; } static int last_boss_act_1(tenm_object *my, const tenm_object *player) { /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; if (my->count[2] >= 0) { (my->count[2])++; if (my->count[2] == 30) tenm_table_add(last_boss_twist_circle_new(1)); if ((my->count[2] == 300) || (my->count[2] == 435)) tenm_table_add(last_boss_twist_circle_new(0)); if (my->count[2] >= 524) { my->count[1] = 0; my->count[2] = -1; return 0; } return 0; } /* self-destruction */ (my->count[2])--; if (my->count[2] <= -4030) { set_background(2); clear_chain(); last_boss_next(my); return 0; } if (my->count[1] == 0) { tenm_table_add(last_boss_twist_circle_new(0)); } (my->count[1])++; if (my->count[1] >= 90) my->count[1] = 0; return 0; } static int last_boss_act_2(tenm_object *my, const tenm_object *player) { /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; if (my->count[2] >= 0) { (my->count[2])++; if (my->count[2] == 60) tenm_table_add(last_boss_cage_new(1)); if (my->count[2] == 240) tenm_table_add(last_boss_cage_new(2)); if ((my->count[2] == 390) || (my->count[2] == 510)) tenm_table_add(last_boss_cage_new(0)); if (my->count[2] == 538) tenm_table_add(normal_shot_point_new(my->x, my->y, 9.0, player->x, player->y, 3)); if (my->count[2] >= 629) { my->count[1] = 0; my->count[2] = -1; return 0; } return 0; } /* self-destruction */ (my->count[2])--; if (my->count[2] <= -4030) { set_background(2); clear_chain(); last_boss_next(my); return 0; } if (my->count[1] == 0) { tenm_table_add(last_boss_cage_new(0)); } if (my->count[1] % 4 == 0) { tenm_table_add(normal_shot_point_new(my->x, my->y, 9.0, player->x + (double) (-50 + (rand() % 101)), player->y + (double) (-50 + (rand() % 101)), 3)); } (my->count[1])++; if (my->count[1] >= 120) my->count[1] = 0; return 0; } static int last_boss_act_3(tenm_object *my, const tenm_object *player) { /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; if (my->count[2] >= 0) { (my->count[2])++; if (my->count[2] == 30) tenm_table_add(last_boss_spotlight_new(0)); if (my->count[2] == 150) tenm_table_add(last_boss_spotlight_new(1)); if (my->count[2] == 250) { tenm_table_add(last_boss_spotlight_new(0)); tenm_table_add(last_boss_spotlight_new(2)); } if (my->count[2] == 330) { tenm_table_add(last_boss_spotlight_new(1)); tenm_table_add(last_boss_spotlight_new(3)); } if (my->count[2] >= 404) { my->count[1] = 0; my->count[2] = -1; return 0; } return 0; } /* self-destruction */ (my->count[2])--; if (my->count[2] <= -4030) { set_background(2); clear_chain(); last_boss_next(my); return 0; } if (my->count[1] == 0) { tenm_table_add(last_boss_spotlight_new(0)); tenm_table_add(last_boss_spotlight_new(2)); } if (my->count[1] == 75) { tenm_table_add(last_boss_spotlight_new(1)); tenm_table_add(last_boss_spotlight_new(3)); } if (my->count[1] % 15 == 0) tenm_table_add(normal_shot_point_new(my->x + (double) (-40 + rand() % 81), my->y + (double) (-40 + rand() % 81), 9.0, player->x, player->y, 4)); (my->count[1])++; if (my->count[1] >= 150) my->count[1] = 0; return 0; } static int last_boss_act_4(tenm_object *my, const tenm_object *player) { /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; if (my->count[2] >= 0) { (my->count[2])++; if (my->count[2] == 30) tenm_table_add(last_boss_horizon_circle_new(1)); if (my->count[2] == 240) tenm_table_add(last_boss_horizon_circle_new(2)); if (my->count[2] == 420) tenm_table_add(last_boss_horizon_circle_new(0)); if (my->count[2] >= 569) { my->count[1] = 0; my->count[2] = -1; return 0; } return 0; } /* self-destruction */ (my->count[2])--; if (my->count[2] <= -4030) { set_background(2); clear_chain(); last_boss_next(my); return 0; } if (my->count[1] == 0) { tenm_table_add(last_boss_horizon_circle_new(0)); } if (my->count[1] % 15 == 0) tenm_table_add(laser_point_new(my->x, my->y, 15.0, player->x, player->y, 25.0, 0)); (my->count[1])++; if (my->count[1] >= 150) my->count[1] = 0; return 0; } static int last_boss_act_5(tenm_object *my, const tenm_object *player) { /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; if (my->count[2] >= 0) { (my->count[2])++; if ((my->count[2] == 30) || (my->count[2] == 110) || (my->count[2] == 190) || (my->count[2] == 270) || (my->count[2] == 350) || (my->count[2] == 430) || (my->count[2] == 510) || (my->count[2] == 590)) tenm_table_add(last_boss_cross_circle_new(1)); if ((my->count[2] == 310) || (my->count[2] == 390) || (my->count[2] == 470) || (my->count[2] == 550)) tenm_table_add(last_boss_cross_circle_new(0)); if (my->count[2] >= 629) { my->count[1] = 0; my->count[2] = -1; return 0; } return 0; } /* self-destruction */ (my->count[2])--; if (my->count[2] <= -8030) { set_background(2); clear_chain(); last_boss_next(my); return 0; } if (my->count[1] % 60 == 0) { tenm_table_add(last_boss_matrix_new(0)); } if (my->count[1] % 60 == 30) { tenm_table_add(last_boss_matrix_new(1)); } if (my->count[1] % 80 == 0) { tenm_table_add(last_boss_cross_circle_new(0)); } if (my->count[1] % 80 == 40) { tenm_table_add(last_boss_cross_circle_new(1)); } (my->count[1])++; if (my->count[1] >= 240) my->count[1] = 0; return 0; } static int last_boss_draw(tenm_object *my, int priority) { int i; int r; int width; int suffix; int status = 0; tenm_color color; char temp[32]; /* sanity check */ if (my == NULL) return 0; /* decoration */ if ((priority == -1) && (my->count[0] < 6)) { for (i = 0; i < 4; i++) { suffix = i * 3 + 4; if (my->count[suffix + 2] <= 0) continue; if (last_boss_green(my)) { if (i == 0) color = tenm_map_color(157, 182, 123); else color = tenm_map_color(190, 206, 167); } else { if (i == 0) color = tenm_map_color(182, 148, 123); else color = tenm_map_color(206, 183, 167); } if (tenm_draw_circle(my->count[suffix + 0], my->count[suffix + 1], my->count[suffix + 2], 1, color) != 0) status = 1; } if ((my->count[16] > 0) && (my->count[16] < 100)) { if (last_boss_green(my)) color = tenm_map_color(222, 225, 179); else color = tenm_map_color(230, 214, 179); if (tenm_draw_circle((int) (my->x), (int) (my->y), 60 + my->count[16] * 3, 1, color) != 0) status = 1; } } /* body */ width = 2; if ((my->count[0] == 0) && (my->count[2] >= 0)) { if (my->count[2] < 180) { return status; } else if (my->count[2] < 210) { r = 60 + (210 - my->count[2]); width = 1; } else { r = 60; } } else { r = 60; } /* dead enemy has low priority */ if (((my->count[0] < 6) && (priority == 0)) || ((my->count[0] >= 6) && (my->count[1] < 120) && (priority == -1))) { if (last_boss_green(my)) { if (my->count[16] > 0) color = tenm_map_color(190, 206, 167); else if (my->count[17] >= 1) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[16] > 0) color = tenm_map_color(206, 183, 167); else if (my->count[17] >= 1) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (tenm_draw_circle((int) (my->x), (int) (my->y), r, width, color) != 0) status = 1; /* hit point stat */ if ((my->count[0] < 6) && (my->count[2] < 0)) { sprintf(temp, "%d", my->hit_point); if (draw_string((int) my->x, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "last_boss_draw: draw_string failed\n"); status = 1; } } } return status; } /* return 1 (true) or 0 (false) */ static int last_boss_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if (my->count[0] < 6) { if ((my->count[2] >= 0) && (my->count[2] < 30) && (my->count[18] != 0)) return 1; if (my->count[2] >= 0) return 0; if (((my->count[0] < 5) && (my->count[2] <= -4000)) || ((my->count[0] >= 5) && (my->count[2] <= -8000))) return 0; return 1; } if ((my->count[0] == 6) && (my->count[18] != 0)) return 1; return 0; } static tenm_object * last_boss_cage_new(int n) { tenm_object *new = NULL; int *count = NULL; /* sanity check */ if ((n < 0) || (n > 2)) { fprintf(stderr, "last_boss_cage_new: strange n (%d)\n", n); return NULL; } count = (int *) malloc(sizeof(int) * 13); if (count == NULL) { fprintf(stderr, "last_boss_cage_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] color (for delete_enemy_shot) * [1] number of circles * [2] radius * [3 -- 12] center (x, y) */ count[0] = 1; if (n == 1) count[1] = 2; else if (n == 2) count[1] = 3; else count[1] = 5; count[2] = 5; if (n == 1) { count[3] = rand() % 11 - 5 + (WINDOW_WIDTH / 2); count[4] = rand() % (WINDOW_HEIGHT / 4); count[5] = rand() % 11 - 5 + (WINDOW_WIDTH / 2); count[6] = rand() % (WINDOW_HEIGHT / 4) + (WINDOW_HEIGHT / 2); count[7] = 0.0; count[8] = 0.0; count[9] = 0.0; count[10] = 0.0; count[11] = 0.0; count[12] = 0.0; } else if (n == 2) { count[3] = rand() % (WINDOW_WIDTH / 3); count[4] = rand() % (WINDOW_HEIGHT / 3); count[5] = rand() % (WINDOW_WIDTH / 3) + (WINDOW_WIDTH * 2 / 3); count[6] = rand() % (WINDOW_HEIGHT / 3); count[7] = rand() % 11 - 5 + (WINDOW_WIDTH / 2); count[8] = rand() % (WINDOW_HEIGHT / 3) + (WINDOW_HEIGHT * 2 / 3); count[9] = 0.0; count[10] = 0.0; count[11] = 0.0; count[12] = 0.0; } else { count[3] = rand() % (WINDOW_WIDTH / 3); count[4] = rand() % (WINDOW_HEIGHT / 3); count[5] = rand() % (WINDOW_WIDTH / 3) + (WINDOW_WIDTH * 2 / 3); count[6] = rand() % (WINDOW_HEIGHT / 3); count[7] = rand() % (WINDOW_WIDTH / 3); count[8] = rand() % (WINDOW_HEIGHT / 3) + (WINDOW_HEIGHT * 2 / 3); count[9] = rand() % (WINDOW_WIDTH / 3) + (WINDOW_WIDTH * 2 / 3); count[10] = rand() % (WINDOW_HEIGHT / 3) + (WINDOW_HEIGHT * 2 / 3); count[11] = rand() % (WINDOW_WIDTH / 3) + (WINDOW_WIDTH / 3); count[12] = rand() % (WINDOW_HEIGHT / 3) + (WINDOW_HEIGHT / 3); } /* ATTR_ENEMY_SHOT is only to clear it when the player is killed */ new = tenm_object_new("L cage", ATTR_ENEMY_SHOT, 0, 0, (double) (WINDOW_WIDTH / 2), (double) (WINDOW_HEIGHT / 4), 13, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&last_boss_cage_act), (int (*)(tenm_object *, int)) (&last_boss_cage_draw)); if (new == NULL) { fprintf(stderr, "last_boss_cage_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int last_boss_cage_act(tenm_object *my, const tenm_object *player) { int i; int j; int suffix_i; int suffix_j; int dx; int dy; int distance_2; double c; double x1; double y1; double x2; double y2; /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; my->count[2] += 5; if (my->count[2] > 850) return 1; if (my->count[2] % 50 != 0) return 0; for (i = 0; i < my->count[1]; i++) for (j = i + 1; j < my->count[1]; j++) { suffix_i = 3 + 2 * i; suffix_j = 3 + 2 * j; dx = my->count[suffix_i + 0] - my->count[suffix_j + 0]; dy = my->count[suffix_i + 1] - my->count[suffix_j + 1]; distance_2 = dx * dx + dy * dy; if (my->count[2] * my->count[2] > distance_2 / 4 + 625) { /* abuse of distance_2 */ c = tenm_sqrt(my->count[2] * my->count[2] - distance_2 / 4) / tenm_sqrt(distance_2); x1 = ((double) (my->count[suffix_i + 0] + my->count[suffix_j + 0])) / 2.0; y1 = ((double) (my->count[suffix_i + 1] + my->count[suffix_j + 1])) / 2.0; x2 = ((double) -dy) * c; y2 = ((double) dx) * c; tenm_table_add(laser_point_new(x1 + x2, y1 + y2, 8.0, x1 - x2, y1 - y2, 25.0, 1)); tenm_table_add(laser_point_new(x1 - x2, y1 - y2, 8.0, x1 + x2, y1 + y2, 25.0, 1)); } } return 0; } static int last_boss_cage_draw(tenm_object *my, int priority) { int i; int suffix; tenm_color color; int status = 0; /* sanity check */ if (my == NULL) return 0; if (priority != 0) return 0; color = tenm_map_color(99, 158, 138); for (i = 0; i < my->count[1]; i++) { suffix = 3 + 2 * i; if (tenm_draw_circle(my->count[suffix + 0], my->count[suffix + 1], my->count[2], 1, color) != 0) status = 1; } return status; } static tenm_object * last_boss_star_dust_new(int n) { tenm_object *new = NULL; int *count = NULL; double x; double y; /* sanity check */ if ((n < 0) || (n > 2)) { fprintf(stderr, "last_boss_star_dust_new: strange n (%d)\n", n); return NULL; } count = (int *) malloc(sizeof(int) * 2); if (count == NULL) { fprintf(stderr, "last_boss_star_dust_new: malloc(count) failed\n"); return NULL; } x = (double) ((rand() % (WINDOW_WIDTH - 200)) + 100); if (n == 1) y = (double) ((rand() % ((WINDOW_HEIGHT - 200) / 2)) + 100); else y = (double) ((rand() % (WINDOW_HEIGHT - 200)) + 100); /* list of count * [0] color (for delete_enemy_shot) * [1] shoot timer */ count[0] = 4; count[1] = 2; /* ATTR_ENEMY_SHOT is only to clear it when the player is killed */ new = tenm_object_new("L star dust", ATTR_ENEMY_SHOT, 0, 0, x, y, 2, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&last_boss_star_dust_act), (int (*)(tenm_object *, int)) (&last_boss_star_dust_draw)); if (new == NULL) { fprintf(stderr, "last_boss_star_dust_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int last_boss_star_dust_act(tenm_object *my, const tenm_object *player) { int i; int n; int theta; double from_x; double from_y; double temp[2]; double result[2]; double speed; /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; if (my->count[1] > 100) { n = rand() % 2; theta = rand() % 360; if (rand() % 2 == 0) speed = 6.0; else speed = 4.5; from_x = my->x + ((double) (my->count[1])) * tenm_cos(theta); from_y = my->y + ((double) (my->count[1])) * tenm_sin(theta); temp[0] = player->x - from_x; temp[1] = player->y - from_y; if (temp[0] * (my->x - from_x) + temp[1] * (my->y - from_y) < -NEAR_ZERO) { theta += 180; from_x = my->x + ((double) (my->count[1])) * tenm_cos(theta); from_y = my->y + ((double) (my->count[1])) * tenm_sin(theta); temp[0] = player->x - from_x; temp[1] = player->y - from_y; } for (i = 0; i < 12; i++) { tenm_table_add(normal_shot_point_new(from_x, from_y, speed, from_x + temp[0], from_y + temp[1], 4)); if (speed < 5.0) speed = 6.0; else speed = 4.5; if (n == 0) theta += 30; else theta -= 30; from_x = my->x + ((double) (my->count[1])) * tenm_cos(theta); from_y = my->y + ((double) (my->count[1])) * tenm_sin(theta); result[0] = 1.0; result[1] = 0.0; vector_rotate(result, temp, 30); temp[0] = result[0]; temp[1] = result[1]; } return 1; } (my->count[1])++; return 0; } static int last_boss_star_dust_draw(tenm_object *my, int priority) { tenm_color color; int status = 0; /* sanity check */ if (my == NULL) return 0; if (priority != 0) return 0; color = tenm_map_color(118, 99, 158); if (my->count[1] > 0) if (tenm_draw_circle((int) (my->x), (int) (my->y), my->count[1], 1, color) != 0) status = 1; color = tenm_map_color(158, 158, 158); if (my->count[1] > 50) if (tenm_draw_circle((int) (my->x), (int) (my->y), (my->count[1] - 50) * 2, 1, color) != 0) status = 1; return status; } static tenm_object * last_boss_spotlight_new(int n) { double x; double y; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; /* sanity check */ if ((n < 0) || (n > 3)) { fprintf(stderr, "last_boss_spotlight_new: strange n (%d)\n", n); return NULL; } count = (int *) malloc(sizeof(int) * 7); if (count == NULL) { fprintf(stderr, "last_boss_spotlight_new: malloc(count) failed\n"); return NULL; } count_d = (double *) malloc(sizeof(double) * 3); if (count_d == NULL) { fprintf(stderr, "last_boss_spotlight_new: malloc(count_d) failed\n"); free(count); return NULL; } /* list of count * [0] color (for delete_enemy_shot) * [1] move timer * [2] shoot timer * [3] shoot theta * [4] shoot theta delta * [5] shoot direction * [6] mode */ count[0] = 6; count[1] = -(rand() % 25); count[2] = 0; count[3] = rand() % 360; if (rand() % 2 == 0) count[4] = 7; else count[4] = -7; if (rand() % 2 == 0) count[5] = 90; else count[5] = -90; count[6] = 0; /* list of count_d * [0] dx * [1] dy * [2] radius */ if (n == 0) { x = 0.0; y = 0.0; count_d[0] = 4.8; count_d[1] = 3.6; } else if (n == 1) { x = (double) WINDOW_WIDTH; y = 0.0; count_d[0] = -4.8; count_d[1] = 3.6; } else if (n == 2) { x = (double) WINDOW_WIDTH; y = (double) WINDOW_HEIGHT; count_d[0] = -4.8; count_d[1] = -3.6; } else { x = 0.0; y = (double) WINDOW_HEIGHT; count_d[0] = 4.8; count_d[1] = -3.6; } count_d[2] = 2.5; /* ATTR_ENEMY_SHOT is only to clear it when the player is killed */ new = tenm_object_new("L spotlight", ATTR_ENEMY_SHOT, 0, 0, x, y, 7, count, 3, count_d, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&last_boss_spotlight_act), (int (*)(tenm_object *, int)) (&last_boss_spotlight_draw)); if (new == NULL) { fprintf(stderr, "last_boss_spotlight_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); return NULL; } return new; } static int last_boss_spotlight_act(tenm_object *my, const tenm_object *player) { int i; int theta; double dx; double dy; /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; /* move */ if (my->count[6] != 1) { if (my->count[1] >= 0) { /* no need to interpolate */ my->x += my->count_d[0]; my->y += my->count_d[1]; } if (my->count[6] == 0) (my->count[1])++; else (my->count[1])--; } /* shoot */ if (my->count[6] != 0) { (my->count[2])++; if ((my->count[2] >= 0) && (my->count[2] % 12 == 0)) { for (i = 0; i < 5; i++) { theta = my->count[3] + i * 72; dx = my->count_d[2] * tenm_cos(theta); dy = my->count_d[2] * tenm_sin(theta); tenm_table_add(normal_shot_angle_new(my->x + dx, my->y + dy, 6.0, theta + my->count[5], 0)); } my->count[3] += my->count[4]; } } /* mode change */ if ((my->count[6] == 0) && (my->count[1] >= 0)) { my->count_d[2] += 2.5; if (6.0 * ((double) (my->count[1])) > 800.0 + my->count_d[2]) return 1; dx = player->x - my->x; dy = player->y - my->y; if (dx * dx + dy * dy < (my->count_d[2] * my->count_d[2]) - NEAR_ZERO) { my->count[6] = 1; my->count[0] = 0; my->count[2] = -30; my->count_d[0] *= -1.0; my->count_d[1] *= -1.0; } } else if (my->count[6] == 1) { /* abuse of shoot timer*/ if (my->count[2] >= 72) my->count[6] = 2; } else if (my->count[6] == 2) { my->count_d[2] -= 2.5; if ((my->count[1] < 0) || (my->count_d[2] < NEAR_ZERO)) return 1; } return 0; } static int last_boss_spotlight_draw(tenm_object *my, int priority) { tenm_color color; int status = 0; /* sanity check */ if (my == NULL) return 0; if (priority != 0) return 0; if (my->count[1] < 0) return 0; if (my->count[6] == 0) color = tenm_map_color(158, 158, 158); else color = tenm_map_color(0, 191, 47); if (tenm_draw_circle((int) (my->x), (int) (my->y), (int) (my->count_d[2]), 1, color) != 0) status = 1; return status; } static tenm_object * last_boss_horizon_circle_new(int n) { int i; int suffix; tenm_object *new = NULL; int *count = NULL; /* sanity check */ if ((n < 0) || (n > 2)) { fprintf(stderr, "last_boss_horizon_circle_new: strange n (%d)\n", n); return NULL; } count = (int *) malloc(sizeof(int) * 25); if (count == NULL) { fprintf(stderr, "last_boss_horizon_circle_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] color (for delete_enemy_shot) * [1] number of circles * [] circle data * suffix + 0: radius * suffix + 1: center theta * suffix + 2: dr * suffix + 3: dtheta * [] circle pair data * sights in/out at the last frame * 1: in the window * 0: out of the window */ count[0] = 6; if (n == 1) { count[1] = 2; count[2] = 5; count[3] = 65; count[4] = 5; count[5] = 2; count[6] = 5; count[7] = -85; count[8] = 5; count[9] = -1; } else if (n == 2) { count[1] = 3; for (i = 0; i < 3; i++) { suffix = i * 4 + 2; count[suffix + 0] = rand() % 100 - 110; count[suffix + 1] = rand() % 360; count[suffix + 2] = 5; if (i == 0) count[suffix + 3] = -2; else if (i == 1) count[suffix + 3] = -1; else if (i == 2) count[suffix + 3] = 1; else count[suffix + 3] = 2; } } else { count[1] = 4; for (i = 0; i < 4; i++) { suffix = i * 4 + 2; count[suffix + 0] = rand() % 100 - 110; count[suffix + 1] = rand() % 360; count[suffix + 2] = 5; if (i == 0) count[suffix + 3] = -2; else if (i == 1) count[suffix + 3] = -1; else if (i == 2) count[suffix + 3] = 1; else count[suffix + 3] = 2; } } for (i = 18; i <= 24; i++) count[i] = 1; /* ATTR_ENEMY_SHOT is only to clear it when the player is killed */ new = tenm_object_new("L horizon circle", ATTR_ENEMY_SHOT, 0, 0, (double) (WINDOW_WIDTH / 2), (double) (WINDOW_HEIGHT / 4), 25, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&last_boss_horizon_circle_act), (int (*)(tenm_object *, int)) (&last_boss_horizon_circle_draw)); if (new == NULL) { fprintf(stderr, "last_boss_horizon_circle_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int last_boss_horizon_circle_act(tenm_object *my, const tenm_object *player) { int i; int j; int n; int suffix; int dtheta; int sight_suffix; int sight_in; double o_x; double o_y; double radius; double result[2]; double v1[2]; double v2[2]; /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; n = 0; for (i = 0; i < my->count[1]; i++) { suffix = i * 4 + 2; if ((my->count[suffix + 2] > 0) || (my->count[suffix + 0] >= 5)) { my->count[suffix + 0] += my->count[suffix + 2]; my->count[suffix + 1] += my->count[suffix + 3]; if (my->count[suffix + 0] > 450) my->count[suffix + 2] *= -1; n++; } } if (n <= 0) return 1; o_x = (double) WINDOW_WIDTH / 2; o_y = (double) WINDOW_HEIGHT / 4; sight_suffix = my->count[1] * 4 + 2; for (i = 0; i < my->count[1]; i++) for (j =i + 1; j < my->count[1]; j++) { result[0] = 0.0; result[1] = 0.0; suffix = i * 4 + 2; if (my->count[suffix + 0] < 5) continue; radius = (double) (my->count[suffix + 0]); v1[0] = o_x + radius * tenm_cos(my->count[suffix + 1]); v1[1] = o_y + radius * tenm_sin(my->count[suffix + 1]); dtheta = my->count[suffix + 1]; suffix = j * 4 + 2; if (my->count[suffix + 0] < 5) continue; radius = (double) (my->count[suffix + 0]); v2[0] = o_x + radius * tenm_cos(my->count[suffix + 1]); v2[1] = o_y + radius * tenm_sin(my->count[suffix + 1]); dtheta -= my->count[suffix + 1]; if (last_boss_horizon_circle_sights(result, v1, v2) == 0) { if ((result[0] > NEAR_ZERO) && (result[0] < ((double) WINDOW_WIDTH) - NEAR_ZERO) && (result[1] > NEAR_ZERO) && (result[1] < ((double) WINDOW_HEIGHT) - NEAR_ZERO)) sight_in = 1; else sight_in = 0; if ((my->count[sight_suffix] != sight_in) && ((dtheta < -2) || (dtheta > 2)) && ((result[0] < 50.0) || (result[0] > ((double) WINDOW_WIDTH) - 50.0) || (result[1] < 50.0) || (result[1] > ((double) WINDOW_HEIGHT) - 50.0))) { if ((result[0] * 3.0 >= result[1] * 4.0) && ((((double) WINDOW_WIDTH) - result[0]) * 3.0 >= result[1] * 4.0)) { tenm_table_add(last_boss_horizon_new(result[0], -1.0, 0)); } else if ((result[0] * 3.0 >= (((double) WINDOW_HEIGHT) - result[1]) * 4.0) && ((((double) WINDOW_WIDTH) - result[0]) * 3.0 >= (((double) WINDOW_HEIGHT) - result[1]) * 4.0)) { tenm_table_add(last_boss_horizon_new(result[0], ((double) WINDOW_HEIGHT)+ 1.0, 1)); } else if ((result[0] * 3.0 < result[1] * 4.0) && (result[0] * 3.0 < (((double) WINDOW_HEIGHT) - result[1]) * 4.0)) { tenm_table_add(last_boss_horizon_new(-1.0, result[1], 2)); } else if (((((double) WINDOW_WIDTH) - result[0]) * 3.0 < result[1] * 4.0) && ((((double) WINDOW_WIDTH) - result[0]) * 3.0 < (((double) WINDOW_HEIGHT) - result[1]) * 4.0)) { tenm_table_add(last_boss_horizon_new(((double) WINDOW_WIDTH) + 1.0, result[1], 3)); } } my->count[sight_suffix] = sight_in; sight_suffix++; } } return 0; } /* set result (arg 1) to the other intersection of two circles * which pass the center of L * v1 (arg 2) and v2 (arg 3) are the centers of the circles * all arguments must be double[2] (you must allocate enough memory * before calling this function) * return: * 0 on success * 1 if there is only one intersection point * 2 on error */ static int last_boss_horizon_circle_sights(double *result, const double *v1, const double *v2) { double dot; double length; double c; double o_x = (double) (WINDOW_WIDTH / 2); double o_y = (double) (WINDOW_HEIGHT / 4); /* sanity check */ if (result == NULL) { fprintf(stderr, "last_boss_horizon_circle_sights: result is NULL\n"); return 2; } if (v1 == NULL) { fprintf(stderr, "last_boss_horizon_circle_sights: v1 is NULL\n"); return 2; } if (v2 == NULL) { fprintf(stderr, "last_boss_horizon_circle_sights: v2 is NULL\n"); return 2; } dot = (o_x - v1[0]) * (v2[0] - v1[0]) + (o_y - v1[1]) * (v2[1] - v1[1]); length = (v2[0] - v1[0]) * (v2[0] - v1[0]) + (v2[1]-v1[1]) * (v2[1]-v1[1]); if (length < NEAR_ZERO) return 1; c = dot / length; result[0] = 2.0 * (c * (v2[0] - v1[0]) - (o_x - v1[0])) + o_x; result[1] = 2.0 * (c * (v2[1] - v1[1]) - (o_y - v1[1])) + o_y; return 0; } static int last_boss_horizon_circle_draw(tenm_object *my, int priority) { int i; int suffix; int x; int y; double radius; tenm_color color; int status = 0; /* sanity check */ if (my == NULL) return 0; if (priority != 0) return 0; color = tenm_map_color(158, 158, 158); for (i = 0; i < my->count[1]; i++) { suffix = i * 4 + 2; if (my->count[suffix + 0] >= 5) { radius = (double) (my->count[suffix + 0]); x = WINDOW_WIDTH / 2 + (int) (radius * tenm_cos(my->count[suffix + 1])); y = WINDOW_HEIGHT / 4 + (int) (radius * tenm_sin(my->count[suffix + 1])); if (tenm_draw_circle(x, y, (int) radius, 1, color) != 0) status = 1; } } return status; } static tenm_object * last_boss_horizon_new(double x, double y, int n) { tenm_object *new = NULL; int *count = NULL; /* sanity check */ if ((n < 0) || (n > 3)) { fprintf(stderr, "last_boss_horizon_new: strange n (%d)\n", n); return NULL; } count = (int *) malloc(sizeof(int) * 3); if (count == NULL) { fprintf(stderr, "last_boss_horizon_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] color (for delete_enemy_shot) * [1] n * [2] shoot timer */ count[0] = 5; count[1] = n; count[2] = 20; /* ATTR_ENEMY_SHOT is only to clear it when the player is killed */ new = tenm_object_new("L horizon", ATTR_ENEMY_SHOT, 0, 0, x, y, 3, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&last_boss_horizon_act), (int (*)(tenm_object *, int)) (&last_boss_horizon_draw)); if (new == NULL) { fprintf(stderr, "last_boss_horizon_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int last_boss_horizon_act(tenm_object *my, const tenm_object *player) { /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; (my->count[2])--; if (my->count[2] <= 0) { tenm_table_add(laser_point_new(my->x, my->y, 15.0, player->x, player->y, 25.0, 1)); if (my->count[1] == 0) { tenm_table_add(laser_new(my->x, my->y, 0.0, 0.0, 0.0, 800.0, 5, 7, 0)); } else if (my->count[1] == 1) { tenm_table_add(laser_new(my->x, my->y, 0.0, 0.0, 0.0, -800.0, 5, 7, 0)); } else if (my->count[1] == 2) { tenm_table_add(laser_new(my->x, my->y, 0.0, 0.0, 800.0, 0.0, 5, 7, 0)); } else if (my->count[1] == 3) { tenm_table_add(laser_new(my->x, my->y, 0.0, 0.0, -800.0, 0.0, 5, 7, 0)); } else { fprintf(stderr, "last_boss_horizon_act: strange my->count[1] (%d)\n", my->count[1]); } return 1; } return 0; } static int last_boss_horizon_draw(tenm_object *my, int priority) { tenm_color color; int status = 0; /* sanity check */ if (my == NULL) return 0; if (priority != 0) return 0; if (my->count[2] <= 0) return 1; color = tenm_map_color(175, 0, 239); if (tenm_draw_circle((int) (my->x), (int) (my->y), my->count[2] * 6, 1, color) != 0) status = 1; /* color = tenm_map_color(142, 99, 158); if (my->count[1] == 0) { if (tenm_draw_line((int) (my->x), (int) (my->y), (int) (my->x), (int) (my->y + 800.0), 1, color) != 0) status = 1; } else if (my->count[1] == 1) { if (tenm_draw_line((int) (my->x), (int) (my->y), (int) (my->x), (int) (my->y - 800.0), 1, color) != 0) status = 1; } else if (my->count[1] == 2) { if (tenm_draw_line((int) (my->x), (int) (my->y), (int) (my->x + 800.0), (int) (my->y), 1, color) != 0) status = 1; } else if (my->count[1] == 3) { if (tenm_draw_line((int) (my->x), (int) (my->y), (int) (my->x - 800.0), (int) (my->y), 1, color) != 0) status = 1; } else { fprintf(stderr, "last_boss_horizon_draw: strange my->count[1] (%d)\n", my->count[1]); } */ return status; } static tenm_object * last_boss_twist_circle_new(int n) { double x; double y; tenm_object *new = NULL; int *count = NULL; /* sanity check */ if ((n < 0) || (n > 1)) { fprintf(stderr, "last_boss_twist_circle_new: strange n (%d)\n", n); return NULL; } count = (int *) malloc(sizeof(int) * 8); if (count == NULL) { fprintf(stderr, "last_boss_twist_circle_new: malloc(count) failed\n"); return NULL; } if (n == 1) { x = (double) ((WINDOW_WIDTH / 2) - 5 + (rand() % 11)); y = (double) ((WINDOW_HEIGHT / 2) - 5 + (rand() % 11)); } else { x = (double) ((WINDOW_WIDTH / 3) + (rand() % (WINDOW_WIDTH / 3))); y = (double) ((WINDOW_HEIGHT / 3) + (rand() % (WINDOW_HEIGHT / 3))); } /* list of count * [0] color (for delete_enemy_shot) * [1] dtheta total * [2] appear timer * [3] radius of the small circle * [4] radius ratio * [5] theta of the small circle * [6] theta of the laser * [7] dtheta of the small circle */ count[0] = 6; count[1] = 0; count[2] = 49; count[3] = 50; count[4] = 6; if (n == 1) { count[5] = -95 - rand() % 11; count[6] = 185 + rand() % 11; count[7] = -3; } else { count[5] = rand() % 360; count[6] = rand() % 360; if (rand() % 2 == 0) count[7] = 3; else count[7] = -3; } /* ATTR_ENEMY_SHOT is only to clear it when the player is killed */ new = tenm_object_new("L twist circle", ATTR_ENEMY_SHOT, 0, 0, x, y, 8, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&last_boss_twist_circle_act), (int (*)(tenm_object *, int)) (&last_boss_twist_circle_draw)); if (new == NULL) { fprintf(stderr, "last_boss_twist_circle_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int last_boss_twist_circle_act(tenm_object *my, const tenm_object *player) { double temp; double x; double y; /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; if (my->count[2] > 0) { (my->count[2])--; return 0; } my->count[5] += my->count[7]; my->count[6] += (-1) * my->count[7] * my->count[4]; my->count[1] += my->count[7]; if ((my->count[1] < -720) || (my->count[1] > 720)) return 1; temp = (double) (my->count[3] * (my->count[4] - 1)); x = my->x + temp * tenm_cos(my->count[5]); y = my->y + temp * tenm_sin(my->count[5]); if ((my->count[1] < -360) || (my->count[1] > 360)) { my->count[0] = 0; if (my->count[1] % (my->count[7] * 20) != 0) return 0; tenm_table_add(laser_point_new(x, y, 3.0, player->x, player->y, (double) (my->count[3]), 0)); } else { my->count[0] = 2; if (my->count[1] % (my->count[7] * 2) != 0) return 0; tenm_table_add(laser_angle_new(x, y, 3.0, my->count[6], (double) (my->count[3]), 2)); } return 0; } static int last_boss_twist_circle_draw(tenm_object *my, int priority) { int x; int y; double temp; tenm_color color; int status = 0; /* sanity check */ if (my == NULL) return 0; if (priority != 0) return 0; if (my->count[2] > 0) { color = tenm_map_color(158, 158, 158); if (tenm_draw_circle((int) (my->x), (int) (my->y), (my->count[3] - my->count[2]) * my->count[4], 1, color) != 0) status = 1; if ((my->count[3] - my->count[2]) * my->count[4] > my->count[3]) { temp = (double) ((my->count[3] - my->count[2]) * my->count[4] - my->count[3]); x = (int) (my->x + temp * tenm_cos(my->count[5])); y = (int) (my->y + temp * tenm_sin(my->count[5])); if (tenm_draw_circle(x, y, my->count[3], 1, color) != 0) status = 1; } } else { if ((my->count[1] < -360) || (my->count[1] > 360)) color = tenm_map_color(99, 158, 114); else color = tenm_map_color(99, 143, 158); if (tenm_draw_circle((int) (my->x), (int) (my->y), my->count[3] * my->count[4], 1, color) != 0) status = 1; temp = (double) (my->count[3] * (my->count[4] - 1)); x = (int) (my->x + temp * tenm_cos(my->count[5])); y = (int) (my->y + temp * tenm_sin(my->count[5])); if (tenm_draw_circle(x, y, my->count[3], 1, color) != 0) status = 1; } return status; } static tenm_object * last_boss_matrix_new(int n) { double x; tenm_object *new = NULL; int *count = NULL; /* sanity check */ if ((n < 0) || (n > 1)) { fprintf(stderr, "last_boss_matrix_new: strange n (%d)\n", n); return NULL; } count = (int *) malloc(sizeof(int) * 3); if (count == NULL) { fprintf(stderr, "last_boss_matrix_new: malloc(count) failed\n"); return NULL; } if (n == 0) x = 0.0; else x = (double) (WINDOW_WIDTH); /* list of count * [0] color (for delete_enemy_shot) * [1] n * [2] shoot timer */ count[0] = 3; count[1] = n; count[2] = rand() % 15; /* ATTR_ENEMY_SHOT is only to clear it when the player is killed */ new = tenm_object_new("L matrix", ATTR_ENEMY_SHOT, 0, 0, x, 0.0, 3, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&last_boss_matrix_act), (int (*)(tenm_object *, int)) NULL); if (new == NULL) { fprintf(stderr, "last_boss_matrix_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int last_boss_matrix_act(tenm_object *my, const tenm_object *player) { double speed; double dx; /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; /* no need to interpolate */ if (my->count[1] == 0) { my->x += 4.5; if (my->x > (double) (WINDOW_WIDTH + WINDOW_HEIGHT)) return 1; } else { my->x -= 4.5; if (my->x < (double) -WINDOW_HEIGHT) return 1; } (my->count[2])++; if (my->count[2] % 3 == 0) { if (my->count[2] == 3) speed = 6.0; else if (my->count[2] == 6) speed = 9.0; else if (my->count[2] == 9) speed = 12.0; else if (my->count[2] == 12) speed = 15.0; else speed = 18.0; if (my->count[1] == 0) dx = -speed + 4.5; else dx = speed - 4.5; tenm_table_add(normal_shot_new(my->x, my->y, dx, speed, 3, -2, 1+((int)(((double)WINDOW_HEIGHT)/speed)))); } if (my->count[2] >= 15) my->count[2] = 0; return 0; } static tenm_object * last_boss_cross_circle_new(int n) { tenm_object *new = NULL; int *count = NULL; /* sanity check */ if ((n < 0) || (n > 1)) { fprintf(stderr, "last_boss_cross_circle_new: strange n (%d)\n", n); return NULL; } count = (int *) malloc(sizeof(int) * 4); if (count == NULL) { fprintf(stderr, "last_boss_cross_circle_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] color (for delete_enemy_shot) * [1] radius * [2] shoot timer * [3] n */ count[0] = 6; if (n == 0) count[1] = 500; else count[1] = 2; count[2] = 0; count[3] = n; /* ATTR_ENEMY_SHOT is only to clear it when the player is killed */ new = tenm_object_new("L cross circle", ATTR_ENEMY_SHOT, 0, 0, (double) (WINDOW_WIDTH / 2), (double) (WINDOW_HEIGHT / 4), 4, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&last_boss_cross_circle_act), (int (*)(tenm_object *, int)) (&last_boss_cross_circle_draw)); if (new == NULL) { fprintf(stderr, "last_boss_cross_circle_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int last_boss_cross_circle_act(tenm_object *my, const tenm_object *player) { double distance_2; /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; if (my->count[3] == 0) { my->count[1] -= 2; if (my->count[1] <= 0) return 1; } else { my->count[1] += 2; if (my->count[1] > 500) return 1; } distance_2 = (player->x - my->x) * (player->x - my->x); distance_2 += (player->y - my->y) * (player->y - my->y); if (my->count[2] > 0) { (my->count[2])--; } else { if ((distance_2 > (double) ((my->count[1] - 6) * (my->count[1] - 6))) && (distance_2 < (double) ((my->count[1] + 6) * (my->count[1] + 6)))) { tenm_table_add(last_boss_cross_new(player->x, player->y, 0)); my->count[2] = 5; } } return 0; } static int last_boss_cross_circle_draw(tenm_object *my, int priority) { tenm_color color; int status = 0; /* sanity check */ if (my == NULL) return 0; if (priority != 0) return 0; color = tenm_map_color(158, 158, 158); if (my->count[1] <= 0) return 1; if (tenm_draw_circle((int) (my->x), (int) (my->y), my->count[1], 1, color) != 0) status = 1; return status; } static tenm_object * last_boss_cross_new(double x, double y, int n) { tenm_object *new = NULL; int *count = NULL; /* sanity check */ if ((n < 0) || (n > 1)) { fprintf(stderr, "last_boss_cross_new: strange n (%d)\n", n); return NULL; } count = (int *) malloc(sizeof(int) * 2); if (count == NULL) { fprintf(stderr, "last_boss_cross_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] color (for delete_enemy_shot) * [1] shoot timer */ count[0] = 3; count[1] = 12; /* ATTR_ENEMY_SHOT is only to clear it when the player is killed */ new = tenm_object_new("L cross", ATTR_ENEMY_SHOT, 0, 0, x, y, 2, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&last_boss_cross_act), (int (*)(tenm_object *, int)) (&last_boss_cross_draw)); if (new == NULL) { fprintf(stderr, "last_boss_cross_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int last_boss_cross_act(tenm_object *my, const tenm_object *player) { /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; my->count[1] += 12; if (my->count[1] > 120) { tenm_table_add(laser_point_new(my->x - ((double) my->count[1]), my->y, 9.0, my->x, my->y, 25.0, 2)); tenm_table_add(laser_point_new(my->x + ((double) my->count[1]), my->y, 9.0, my->x, my->y, 25.0, 2)); tenm_table_add(laser_point_new(my->x, my->y - ((double) my->count[1]), 9.0, my->x, my->y, 25.0, 2)); tenm_table_add(laser_point_new(my->x, my->y + ((double) my->count[1]), 9.0, my->x, my->y, 25.0, 2)); return 1; } return 0; } static int last_boss_cross_draw(tenm_object *my, int priority) { tenm_color color; int status = 0; /* sanity check */ if (my == NULL) return 0; if (priority != 0) return 0; color = tenm_map_color(99, 143, 158); if (my->count[1] <= 0) return 1; if (tenm_draw_line(((int) (my->x)) - my->count[1], (int) (my->y), ((int) (my->x)) + my->count[1], (int) (my->y), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x), ((int) (my->y)) - my->count[1], (int) (my->x), ((int) (my->y)) + my->count[1], 1, color) != 0) status = 1; return status; } dangen-0.5/spqr/last-boss.h0000644000175000017500000000035110276702741016470 0ustar00ooharaoohara00000000000000/* $Id: last-boss.h,v 1.1 2003/07/13 14:53:15 oohara Exp $ */ #ifndef __PHOTON_B_LAST_BOSS_H__ #define __PHOTON_B_LAST_BOSS_H__ #include "tenm_object.h" tenm_object *last_boss_new(void); #endif /* not __PHOTON_B_LAST_BOSS_H__ */ dangen-0.5/spqr/mankanshoku.c0000644000175000017500000005061210276702741017100 0ustar00ooharaoohara00000000000000/* $Id: mankanshoku.c,v 1.95 2005/01/06 06:16:42 oohara Exp $ */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "normal-enemy.h" #include "score.h" #include "wall-8.h" #include "silver-chimera.h" #include "warning.h" #include "mankanshoku.h" static int mankanshoku_move(tenm_object *my, double turn_per_frame); static int mankanshoku_hit(tenm_object *my, tenm_object *your); static void mankanshoku_next(tenm_object *my); static int mankanshoku_act(tenm_object *my, const tenm_object *player); static int mankanshoku_draw(tenm_object *my, int priority); static int mankanshoku_green(const tenm_object *my); tenm_object * mankanshoku_new(void) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = (double) (WINDOW_WIDTH / 2); double y = -255.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "mankanshoku_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(8, x + 60.0, y - 15.0, x + 60.0, y + 15.0, x + 50.0, y + 25.0, x - 50.0, y + 25.0, x - 60.0, y + 15.0, x - 60.0, y - 15.0, x - 50.0, y - 25.0, x + 50.0, y - 25.0); if (p[0] == NULL) { fprintf(stderr, "mankanshoku_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 7); if (count == NULL) { fprintf(stderr, "mankanshoku_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 3); if (count_d == NULL) { fprintf(stderr, "mankanshoku_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] life mode * [3] life timer * [4] the time when we escaped / were killed * [5] add enemy mode * [6] add enemy timer */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 0; count[4] = 0; count[5] = (rand() % 2) * 3; count[6] = 0; count_d[0] = 0.0; count_d[1] = 7.5; new = tenm_object_new("Mankanshoku", ATTR_ENEMY | ATTR_OBSTACLE, ATTR_PLAYER_SHOT, 750, x, y, 7, count, 3, count_d, 1, p, (int (*)(tenm_object *, double)) (&mankanshoku_move), (int (*)(tenm_object *, tenm_object *)) (&mankanshoku_hit), (int (*)(tenm_object *, const tenm_object *)) (&mankanshoku_act), (int (*)(tenm_object *, int)) (&mankanshoku_draw)); if (new == NULL) { fprintf(stderr, "mankanshoku_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int mankanshoku_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "mankanshoku_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "mankanshoku_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } if (my->count[2] != 0) return 0; dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); if ((my->count[3] >= 2344) && (my->y > ((double) WINDOW_HEIGHT) + 120.0)) mankanshoku_next(my); return 0; } static int mankanshoku_hit(tenm_object *my, tenm_object *your) { int n; /* sanity check */ if (my == NULL) { fprintf(stderr, "mankanshoku_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "mankanshoku_hit: your is NULL\n"); return 0; } if (my->count[2] != 0) return 0; if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; deal_damage(my, your, 0); if (mankanshoku_green(my)) add_chain(my, your); my->count[1] = 41; if (my->hit_point <= 0) { add_score(100); if (mankanshoku_green(my)) n = 8; else n = 7; tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 1, 1000, n, 8.0, 6)); tenm_table_add(fragment_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 30.0, 30, n, 5.0, 0.0, 20)); mankanshoku_next(my); return 0; } return 0; } static void mankanshoku_next(tenm_object *my) { /* sanity check */ if (my == NULL) return; /* no explosion here --- this is called when we escape * as well as we are killed */ my->count[2] = 1; my->count[4] = my->count[3]; if (my->count[4] < 1082) my->count[4] = 1082; my->count[1] = 0; /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ tenm_mass_delete(my->mass); my->mass = NULL; } static int mankanshoku_act(tenm_object *my, const tenm_object *player) { int i; int t; int theta1; int theta2; int temp; double speed; double dx; double dy; double result[2]; double v[2]; double x; /* sanity check */ if (my == NULL) { fprintf(stderr, "mankanshoku_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; (my->count[3])++; /* dead / escaped */ if (my->count[2] == 1) { if (my->count[3] == my->count[4] + 160) tenm_table_add(warning_new()); if (my->count[3] == my->count[4] + 290) { tenm_table_add(silver_chimera_new()); return 1; } } /* move */ if (my->count[3] < 75) my->count_d[1] = 7.5 - ((double) (my->count[3])) * 0.1; else if (my->count[3] < 1032) my->count_d[1] = 0.0; else if (my->count[3] < 1082) my->count_d[1] = ((double) (my->count[3] - 1032)) * 0.1; else if (my->count[3] < 1187) my->count_d[1] = 5.0 - ((double) (my->count[3] - 1082)) * 0.1; else if (my->count[3] < 2344) my->count_d[1] = 0.0; else my->count_d[1] = 7.5; /* add wall */ if ((my->count[3] >= 1133) && (my->count[3] < 9999) && ((my->count[2] == 0) || (my->count[3] < my->count[4] + 72)) && ((my->count[3] - 1133) % 24 == 0)) { tenm_table_add(wall_8_new(30.0, -29.0, 0, my->count[3] + 2458)); tenm_table_add(wall_8_new(((double) WINDOW_WIDTH) - 30.0, -29.0, 0, my->count[3] + 2458)); } t = my->count[3] - 1187; if (t < 0) return 0; /* chase the player */ if (player->x < 220.0) x = 120.0; else if (player->x < 420.0) x = 320.0; else x = 520.0; if ((my->x + 10.0 > x) && (my->x - 10.0 < x)) my->count_d[0] = x - my->x; else if (my->x < x) my->count_d[0] = 10.0; else my->count_d[0] = -10.0; if (my->x + my->count_d[0] < 120.0) my->count_d[0] = 120.0 - my->x; if (my->x + my->count_d[0] > 520.0) my->count_d[0] = 520.0 - my->x; if (t >= 1058) my->count_d[0] = 0.0; /* add normal enemy */ if (my->count[5] >= 0) { (my->count[6])++; if ((my->count[2] != 0) && (my->count[6] < 48)) { my->count[5] = -1; } else if ((my->count[6] >= 48) && (my->count[6] <= 60) && (my->count[6] % 6 == 0)) { switch (my->count[5]) { case 0: x = 120.0 + ((double) (my->count[6] - 56)) * 3.0; break; case 1: x = 320.0 - ((double) (my->count[6] - 48)) * 3.0; break; case 2: x = 320.0 + ((double) (my->count[6] - 48)) * 3.0; break; case 3: x = 520.0 - ((double) (my->count[6] - 56)) * 3.0; break; default: fprintf(stderr, "mankanshoku_act: undefined my->count[5] (add enemy) " "(%d)\n", my->count[5]); x = ((double) (WINDOW_WIDTH / 2)); break; } if (my->count[6] == 48) temp = 37; else temp = 9999; tenm_table_add(normal_enemy_new(x, -19.0, BALL_SOLDIER, ENEMY_TYPE_WEAK, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 0.0, 7.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 21, temp, 34, 0, 0, 1, /* shoot 1 */ 9999, temp, 55 % temp, 0, 1, 1)); } if (my->count[6] >= 60) { switch (my->count[5]) { case 0: case 3: my->count[5] = 1 + rand() % 2; break; case 1: my->count[5] = 0; break; case 2: my->count[5] = 3; break; default: fprintf(stderr, "mankanshoku_act: undefined my->count[5] " "(mode change) (%d)\n", my->count[5]); my->count[5] = 1; break; } if ((t >= 840) || (my->count[2] != 0)) my->count[5] = -1; my->count[6] = 0; } } /* shoot */ if (my->count[2] != 0) return 0; if (t < 907) { if (t % 121 == 0) { tenm_table_add(laser_angle_new(my->x - 50.0, my->y, 6.5, 125, 25.0, 2)); tenm_table_add(laser_angle_new(my->x - 50.0, my->y, 6.5, 146, 25.0, 2)); tenm_table_add(laser_angle_new(my->x - 50.0, my->y, 6.5, 167, 25.0, 2)); tenm_table_add(laser_angle_new(my->x + 50.0, my->y, 6.5, 55, 25.0, 2)); tenm_table_add(laser_angle_new(my->x + 50.0, my->y, 6.5, 34, 25.0, 2)); tenm_table_add(laser_angle_new(my->x + 50.0, my->y, 6.5, 13, 25.0, 2)); } if (t % 121 == 11) { tenm_table_add(laser_angle_new(my->x - 50.0, my->y, 6.5, 95, 25.0, 2)); tenm_table_add(laser_angle_new(my->x - 50.0, my->y, 7.5, 116, 25.0, 2)); tenm_table_add(laser_angle_new(my->x - 50.0, my->y, 8.5, 137, 25.0, 2)); tenm_table_add(laser_angle_new(my->x + 50.0, my->y, 6.5, 85, 25.0, 2)); tenm_table_add(laser_angle_new(my->x + 50.0, my->y, 7.5, 64, 25.0, 2)); tenm_table_add(laser_angle_new(my->x + 50.0, my->y, 8.5, 43, 25.0, 2)); } if (t % 121 == 22) { tenm_table_add(laser_angle_new(my->x - 50.0, my->y, 6.5, 65, 25.0, 2)); tenm_table_add(laser_angle_new(my->x - 50.0, my->y, 8.5, 86, 25.0, 2)); tenm_table_add(laser_angle_new(my->x - 50.0, my->y, 10.5, 107, 25.0, 2)); tenm_table_add(laser_angle_new(my->x + 50.0, my->y, 6.5, 115, 25.0, 2)); tenm_table_add(laser_angle_new(my->x + 50.0, my->y, 8.5, 94, 25.0, 2)); tenm_table_add(laser_angle_new(my->x + 50.0, my->y, 10.5, 73, 25.0, 2)); } if ((t % 121 == 55) || (t % 121 == 88)) { speed = 6.0; if (t % 121 == 55) theta1 = 45; else theta1 = 77; theta2 = 113; dx = speed * tenm_cos(theta1); dy = speed * tenm_sin(theta1); v[0] = speed * tenm_cos(180 - theta2) * tenm_cos(theta1 - theta2); v[1] = speed * tenm_cos(180 - theta2) * tenm_sin(theta1 - theta2); for (i = 0; i < 6; i++) { result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, i * 30); tenm_table_add(normal_shot_new(my->x - 50.0, my->y, dx + result[0], dy + result[1], 1, -2, 0)); tenm_table_add(normal_shot_new(my->x + 50.0, my->y, -(dx + result[0]), dy + result[1], 1, -2, 0)); } } } else if ((t >= 989) && (t < 1127)) { speed = 7.0; if (t % 46 == 0) { tenm_table_add(laser_point_new(my->x + 120.0 * tenm_cos(-15), my->y + 120.0 * tenm_sin(-15), speed, player->x, player->y - 150.0, 25.0, 0)); tenm_table_add(laser_point_new(my->x + 120.0 * tenm_cos(-165), my->y + 120.0 * tenm_sin(-165), speed, player->x, player->y - 150.0, 25.0, 0)); tenm_table_add(laser_point_new(my->x + 120.0 * tenm_cos(-45), my->y + 120.0 * tenm_sin(-45), speed, player->x, player->y - 75.0, 25.0, 0)); tenm_table_add(laser_point_new(my->x + 120.0 * tenm_cos(-135), my->y + 120.0 * tenm_sin(-135), speed, player->x, player->y - 75.0, 25.0, 0)); tenm_table_add(laser_point_new(my->x + 120.0 * tenm_cos(-75), my->y + 120.0 * tenm_sin(-75), speed, player->x, player->y, 25.0, 0)); tenm_table_add(laser_point_new(my->x + 120.0 * tenm_cos(-105), my->y + 120.0 * tenm_sin(-105), speed, player->x, player->y, 25.0, 0)); } if (t % 46 == 23) { tenm_table_add(laser_point_new(my->x + 120.0 * tenm_cos(-15), my->y + 120.0 * tenm_sin(-15), speed, player->x, player->y, 25.0, 0)); tenm_table_add(laser_point_new(my->x + 120.0 * tenm_cos(-165), my->y + 120.0 * tenm_sin(-165), speed, player->x, player->y, 25.0, 0)); tenm_table_add(laser_point_new(my->x + 120.0 * tenm_cos(-45), my->y + 120.0 * tenm_sin(-45), speed, player->x, player->y - 75.0, 25.0, 0)); tenm_table_add(laser_point_new(my->x + 120.0 * tenm_cos(-135), my->y + 120.0 * tenm_sin(-135), speed, player->x, player->y - 75.0, 25.0, 0)); tenm_table_add(laser_point_new(my->x + 120.0 * tenm_cos(-75), my->y + 120.0 * tenm_sin(-75), speed, player->x, player->y - 150.0, 25.0, 0)); tenm_table_add(laser_point_new(my->x + 120.0 * tenm_cos(-105), my->y + 120.0 * tenm_sin(-105), speed, player->x, player->y - 150.0, 25.0, 0)); } } return 0; } static int mankanshoku_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; int i; /* sanity check */ if (my == NULL) { fprintf(stderr, "mankanshoku_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; if (my->count[2] != 0) return 0; /* decoration */ if (mankanshoku_green(my)) { if (my->count[1] >= 40) color = tenm_map_color(181, 190, 92); else color = tenm_map_color(157, 182, 123); } else { if (my->count[1] >= 40) color = tenm_map_color(200, 164, 92); else color = tenm_map_color(182, 147, 123); } for (i = -15; i >= -165; i -= 30) if (tenm_draw_line(((int) (my->x + 80.0 * tenm_cos(i))), ((int) (my->y + 80.0 * tenm_sin(i))), ((int) (my->x + 120.0 * tenm_cos(i))), ((int) (my->y + 120.0 * tenm_sin(i))), 1, color) != 0) status = 1; /* body */ if (mankanshoku_green(my)) { if (my->count[1] >= 40) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 40) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (tenm_draw_line(((int) (my->x + 60.0)), ((int) (my->y - 15.0)), ((int) (my->x + 60.0)), ((int) (my->y + 15.0)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + 60.0)), ((int) (my->y + 15.0)), ((int) (my->x + 50.0)), ((int) (my->y + 25.0)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + 50.0)), ((int) (my->y + 25.0)), ((int) (my->x - 50.0)), ((int) (my->y + 25.0)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - 50.0)), ((int) (my->y + 25.0)), ((int) (my->x - 60.0)), ((int) (my->y + 15.0)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - 60.0)), ((int) (my->y + 15.0)), ((int) (my->x - 60.0)), ((int) (my->y - 15.0)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - 60.0)), ((int) (my->y - 15.0)), ((int) (my->x - 50.0)), ((int) (my->y - 25.0)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - 50.0)), ((int) (my->y - 25.0)), ((int) (my->x + 50.0)), ((int) (my->y - 25.0)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + 50.0)), ((int) (my->y - 25.0)), ((int) (my->x + 60.0)), ((int) (my->y - 15.0)), 3, color) != 0) status = 1; /* hit point stat */ if ((priority == 0) && (my->count[1] > 0)) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 10, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "mankanshoku_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int mankanshoku_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if ((my->count[3] >= 1192) && (my->count[3] < 2314)) return 1; return 0; } dangen-0.5/spqr/mankanshoku.h0000644000175000017500000000035510276702741017104 0ustar00ooharaoohara00000000000000/* $Id: mankanshoku.h,v 1.1 2004/11/04 11:47:47 oohara Exp $ */ #ifndef __DANGEN_MANKANSHOKU_H__ #define __DANGEN_MANKANSHOKU_H__ #include "tenm_object.h" tenm_object *mankanshoku_new(void); #endif /* not __DANGEN_MANKANSHOKU_H__ */ dangen-0.5/spqr/negation-engine.c0000644000175000017500000004462510276702741017637 0ustar00ooharaoohara00000000000000/* $Id: negation-engine.c,v 1.122 2004/09/30 17:11:04 oohara Exp $ */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "tenm_table.h" #include "laser.h" #include "tenm_math.h" #include "normal-enemy.h" #include "negation-engine.h" #define NEAR_ZERO 0.0001 static int negation_engine_act(tenm_object *my, const tenm_object *player); static tenm_object *negation_engine_triangle_new(double x, double y, double size, int theta_body); static int negation_engine_triangle_move(tenm_object *my, double turn_per_frame); static int negation_engine_triangle_act(tenm_object *my, const tenm_object *player); static int negation_engine_triangle_draw(tenm_object *my, int priority); tenm_object * negation_engine_new(void) { tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; count = (int *) malloc(sizeof(int) * 5); if (count == NULL) { fprintf(stderr, "negation_engine_new: malloc(count) failed\n"); return NULL; } count_d = (double *) malloc(sizeof(double) * 4); if (count_d == NULL) { fprintf(stderr, "negation_engine_new: malloc(count_d) failed\n"); free(count); return NULL; } /* list of count * [0] timer * [1] more 1 counter * [2] more 2 counter * [2] more 3 counter */ /* list of count_d */ count[0] = -1; count[1] = 1; count[2] = 0; count[3] = 0; new = tenm_object_new("negation engine", 0, 0, 1, 0.0, 0.0, 5, count, 4, count_d, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&negation_engine_act), (int (*)(tenm_object *, int)) NULL); if (new == NULL) { fprintf(stderr, "negation_engine_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); return NULL; } return new; } static int negation_engine_act(tenm_object *my, const tenm_object *player) { int temp; int time_shoot; /* sanity check */ if (my == NULL) { fprintf(stderr, "negation_engine_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[0])++; if (my->count[0] == 0) { tenm_table_add(negation_engine_triangle_new(220.0, -490.0, 212.0, 15)); tenm_table_add(negation_engine_triangle_new(420.0, -150.0, 212.0, 15)); tenm_table_add(negation_engine_triangle_new(420.0, -820.0, 212.0, 15)); } if ((my->count[0] >= 100) && (my->count[0] <= 3000) && (my->count[0] % 25 == 0)) { tenm_table_add(normal_enemy_new(659.0, 71.4730 + 0.1 * ((double) (my->count[0] - 50)), BALL_SOLDIER, 0, 0, my->table_index, 1, -1, 0, 2, 2, /* move 0 */ 182, -1.9319 + 0.0, 0.5176 + 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, 0.5176 + 0.0, -1.9319 + 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 210, 120, 0, 50, 0, 1, /* shoot 1 */ 9999, 120, 30, 50, 1, 0)); } if ((my->count[0] >= 1685) && (my->count[0] <= 3885) && (my->count[0] % 25 == 10) && (my->count[1] >= 2) && ((my->count[0] <= 2385) || (my->count[0] % 150 >= 85))) { my->count[1] -= 2; tenm_table_add(normal_enemy_new(107.5703 + 0.1 * ((double) (my->count[0] - 1635)) * 0.26795, -19.0703, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, -0.5176 + 0.0, 1.9319 + 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 90, 110, 0, 50, 0, 1, /* shoot 1 */ 9999, 110, 0, 50, 1, 0)); } if ((my->count[0] > 2385) && (my->count[0] <= 6335) && (my->count[0] % 25 == 10) && ((my->count[0] % 150 < 85) || (my->count[0] >= 3910))) { temp = (int) (0.1 * ((double) (my->count[0] - 1635)) / 1.9319); if (temp < 1) temp = 1; if (my->count[0] < 3910) time_shoot = 110; else if (my->count[0] < 5600) time_shoot = 105; else time_shoot = 100; tenm_table_add(normal_enemy_new(107.5703 + 0.1 * ((double) (my->count[0] - 1635)) * 0.26795, -19.0703, BALL_SOLDIER, 0, 0, my->table_index, 2, -1, 0, 2, 2, /* move 0 */ temp, -0.5176 + 0.0, 1.9319 + 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, 1.9319 + 0.0, -0.5176 + 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ temp + 10, time_shoot, 0, 50, 0, 1, /* shoot 1 */ 9999, time_shoot, (temp + 10) % time_shoot, 50, 1, 0)); } if ((my->count[0] >= 4100) && (my->count[0] < 5600) && (my->count[0] % 25 == 0) && (my->count[2] >= 2)) { my->count[2] -= 2; temp = (int) ((499.0 - 301.4178 - 0.1 * ((double) (my->count[0] - 4100))) / 1.9319); if (temp < 1) temp = 1; tenm_table_add(normal_enemy_new(325.9060 + 0.1 * ((double) (my->count[0] - 4100)) * 0.26795, 499.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 2, 1, /* move 0 */ temp, 0.5176 + 0.0, -1.9319 + 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, 1.4142 + 0.0, 1.4142 + 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 9999, 20, 0, 50, 1, 0)); } if ((my->count[0] >= 6100) && (my->count[0] <= 9800) && (my->count[0] % 25 == 0)) { temp = 60 + (my->count[0] - 6100) / 50; if (temp < 1) temp = 1; tenm_table_add(normal_enemy_new(659.0, 6.4730 + 0.1 * ((double) (my->count[0] - 6100)), BALL_SOLDIER, 0, 0, my->table_index, 3, -1, 0, 2, 3, /* move 0 */ 182, -1.9319 + 0.0, 0.5176 + 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, 0.5176 + 0.0, -1.9319 + 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ temp, 60, 0, 50, 0, 1, /* shoot 1 */ 100, 60, temp % 60, 50, 1, 2, /* shoot 2 */ 9999, 100, (temp + 100) % 60, 50, 0, 2)); } if ((my->count[0] >= 6460) && (my->count[0] <= 9999) && (my->count[0] % 25 == 10) && (my->count[3] >= 1)) { (my->count[3])--; tenm_table_add(normal_enemy_new(107.5703 + 0.1 * ((double) (my->count[0] - 1635)) * 0.26795, -19.0703, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, -0.5176 + 0.0, 1.9319 + 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 100, 60, 0, 50, 0, 1, /* shoot 1 */ 9999, 60, 40, 50, 1, 0)); } return 0; } static tenm_object * negation_engine_triangle_new(double x, double y, double size, int theta_body) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; /* sanity check */ if (size < NEAR_ZERO) { fprintf(stderr, "negation_engine_triangle_new: size is non-potisive " "(%f)\n", size); return NULL; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "negation_engine_triangle_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(3, x + 0.5 * size * tenm_cos(theta_body), y + 0.5 * size * tenm_sin(theta_body), x + 0.5 * size * tenm_cos(theta_body + 120), y + 0.5 * size * tenm_sin(theta_body + 120), x + 0.5 * size * tenm_cos(theta_body + 240), y + 0.5 * size * tenm_sin(theta_body + 240)); if (p[0] == NULL) { fprintf(stderr, "negation_engine_triangle_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 5); if (count == NULL) { fprintf(stderr, "negation_engine_triangle_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 4); if (count_d == NULL) { fprintf(stderr, "negation_engine_triangle_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] timer * [1] body theta * [2] hand theta */ /* list of count_d * [0] speed x * [1] speed y * [2] size */ count[0] = 0; count[1] = theta_body; count[2] = 0; count_d[0] = 0.0; count_d[1] = 4.0; count_d[2] = size; new = tenm_object_new("negation engine triangle", ATTR_ENEMY | ATTR_OPAQUE, 0, 1, x, y, 5, count, 4, count_d, 1, p, (int (*)(tenm_object *, double)) (&negation_engine_triangle_move), (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&negation_engine_triangle_act), (int (*)(tenm_object *, int)) (&negation_engine_triangle_draw)); if (new == NULL) { fprintf(stderr, "negation_engine_triangle_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int negation_engine_triangle_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "negation_engine_triangle_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "negation_engine_triangle_move: strange turn_per_frame " "(%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int negation_engine_triangle_act(tenm_object *my, const tenm_object *player) { int t; int i; int theta; int phi; double length; /* sanity check */ if (my == NULL) { fprintf(stderr, "negation_engine_triangle_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[0])++; if (my->count[0] >= 10790) return 1; /* speed change */ if (my->count[0] == 50) { my->count_d[0] = 0.0; my->count_d[1] = 0.1; } if (my->count[0] == 10490) { my->count_d[0] = 0.0; my->count_d[1] = 2.0; } /* shoot */ t = my->count[0] - 50; if (t < 0) return 0; (my->count[2])++; if ((t >= 121) && (t % 11 == 0)) { for (i = 0; i < 360; i += 120) { theta = my->count[1] + i; phi = my->count[1] + i - 150 + my->count[2] % 120; length = my->count_d[2] * tenm_sqrt(3); length *= tenm_sin(120 - my->count[2] % 120) / tenm_sin(60); tenm_table_add(laser_angle_new(my->x + my->count_d[2] * tenm_cos(theta) + length * tenm_cos(phi), my->y + my->count_d[2] * tenm_sin(theta) + length * tenm_sin(phi), 5.0, t * 2, 25.0, 5)); } } if (t % 13 == 0) { for (i = 0; i < 360; i += 120) { tenm_table_add(laser_angle_new(my->x, my->y, 5.0, t * (-1) + i, 25.0, 4)); } } return 0; } static int negation_engine_triangle_draw(tenm_object *my, int priority) { int i; int theta; int phi; double length; int status = 0; tenm_color color; /* sanity check */ if (my == NULL) { fprintf(stderr, "negation_engine_triangle_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; color = tenm_map_color(182, 123, 162); /* decoration */ for (i = 0; i < 360; i += 120) { theta = my->count[1] + i; if (tenm_draw_line((int) (my->x + my->count_d[2] * tenm_cos(theta) * 0.75), (int) (my->y + my->count_d[2] * tenm_sin(theta) * 0.75), (int) (my->x), (int) (my->y), 1, color) != 0) status = 1; } /* hand */ color = tenm_map_color(182, 123, 162); for (i = 0; i < 360; i += 120) { theta = my->count[1] + i; if (tenm_draw_line((int) (my->x + my->count_d[2] * tenm_cos(theta)), (int) (my->y + my->count_d[2] * tenm_sin(theta)), (int) (my->x + my->count_d[2] * tenm_cos(theta + 120)), (int) (my->y + my->count_d[2] * tenm_sin(theta + 120)), 1, color) != 0) status = 1; } for (i = 0; i < 360; i += 120) { theta = my->count[1] + i; phi = my->count[1] + i - 150 + my->count[2] % 120; length = my->count_d[2] * tenm_sqrt(3); length *= tenm_sin(120 - my->count[2] % 120) / tenm_sin(60); color = tenm_map_color(95, 13, 68); if (tenm_draw_line((int) (my->x + my->count_d[2] * tenm_cos(theta) + length * tenm_cos(phi)), (int) (my->y + my->count_d[2] * tenm_sin(theta) + length * tenm_sin(phi)), (int) (my->x + my->count_d[2] * tenm_cos(theta + 120) + length * tenm_cos(phi + 120)), (int) (my->y + my->count_d[2] * tenm_sin(theta + 120) + length * tenm_sin(phi + 120)), 1, color) != 0) status = 1; color = tenm_map_color(175, 0, 239); if (tenm_draw_circle((int) (my->x + my->count_d[2] * tenm_cos(theta) + length * tenm_cos(phi)), (int) (my->y + my->count_d[2] * tenm_sin(theta) + length * tenm_sin(phi)), 5, 1, color) != 0) status = 1; } color = tenm_map_color(95, 13, 68); /* body */ for (i = 0; i < 360; i += 120) { theta = my->count[1] + i; if (tenm_draw_line((int) (my->x + 0.5 * my->count_d[2] * tenm_cos(theta)), (int) (my->y + 0.5 * my->count_d[2] * tenm_sin(theta)), (int) (my->x + 0.5 * my->count_d[2] * tenm_cos(theta + 120)), (int) (my->y + 0.5 * my->count_d[2] * tenm_sin(theta + 120)), 5, color) != 0) status = 1; } return status; } dangen-0.5/spqr/negation-engine.h0000644000175000017500000000040110276702741017624 0ustar00ooharaoohara00000000000000/* $Id: negation-engine.h,v 1.4 2004/08/20 13:22:37 oohara Exp $ */ #ifndef __DANGEN_NEGATION_ENGINE_H__ #define __DANGEN_NEGATION_ENGINE_H__ #include "tenm_object.h" tenm_object *negation_engine_new(void); #endif /* not __DANGEN_NEGATION_ENGINE_H__ */ dangen-0.5/spqr/net-can-howl.c0000644000175000017500000022671411625004614017056 0ustar00ooharaoohara00000000000000/* $Id: net-can-howl.c,v 1.431 2004/10/13 23:56:06 oohara Exp $ */ /* [very hard] Senators */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "normal-enemy.h" #include "score.h" #include "stage-clear.h" #include "net-can-howl.h" #define NEAR_ZERO 0.0001 static int net_can_howl_core_move(tenm_object *my, double turn_per_frame); static int net_can_howl_core_hit(tenm_object *my, tenm_object *your); static void net_can_howl_core_second_form(tenm_object *my); static void net_can_howl_core_explode(tenm_object *my); static int net_can_howl_core_act(tenm_object *my, const tenm_object *player); static int net_can_howl_core_cannon(tenm_object *my, const tenm_object *player); static int net_can_howl_core_draw(tenm_object *my, int priority); static int net_can_howl_core_draw_wraith(double x, double y, double length, int theta, int theta_z, int green); static int net_can_howl_core_green(const tenm_object *my); static tenm_object *net_can_howl_black_hole_new(double x, double y); static int net_can_howl_black_hole_act(tenm_object *my, const tenm_object *player); static int net_can_howl_black_hole_draw(tenm_object *my, int priority); static tenm_object *net_can_howl_seeker_new(int t, int n); static int net_can_howl_seeker_act(tenm_object *my, const tenm_object *player); static int net_can_howl_seeker_draw(tenm_object *my, int priority); static tenm_object *senator_new(int table_index, int what); static int senator_move(tenm_object *my, double turn_per_frame); static int senator_hit(tenm_object *my, tenm_object *your); static void senator_explode(tenm_object *my); static int senator_act(tenm_object *my, const tenm_object *player); static int senator_draw(tenm_object *my, int priority); static int senator_green(const tenm_object *my); static int core_signal_second_form(tenm_object *my, int n); static int core_signal_kill_senator(tenm_object *my, int n); static int senator_signal(tenm_object *my, int n); static int net_can_howl_position(double *result, int what, int t_0, int t_1); static tenm_object *voter_new(int what, int t); static int voter_move(tenm_object *my, double turn_per_frame); static int voter_hit(tenm_object *my, tenm_object *your); static int voter_act(tenm_object *my, const tenm_object *player); static int voter_draw(tenm_object *my, int priority); static int voter_green(const tenm_object *my); static double voter_parabola_formation(double a_1, double b_1, double a_2, double b_2, double s, double x); static tenm_object *net_can_howl_more_1_new(void); static int net_can_howl_more_1_act(tenm_object *my, const tenm_object *player); tenm_object * net_can_howl_core_new(void) { int i; tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = 0.0; double y = 0.0; double hand_x = 0.0; double hand_y = 0.0; x = (double) (WINDOW_WIDTH / 2); y = (double) (WINDOW_HEIGHT / 2); hand_x = 30.0; hand_y = 0.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "net_can_howl_core_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(4, x + hand_x - hand_y * 0.5, y + hand_y + hand_x * 0.5, x - hand_x - hand_y * 0.5, y - hand_y + hand_x * 0.5, x - hand_x + hand_y * 0.5, y - hand_y - hand_x * 0.5, x + hand_x + hand_y * 0.5, y + hand_y - hand_x * 0.5); if (p[0] == NULL) { fprintf(stderr, "net_can_howl_core_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 18); if (count == NULL) { fprintf(stderr, "net_can_howl_core_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 6); if (count_d == NULL) { fprintf(stderr, "net_can_howl_core_new: malloc(count_d) failed\n"); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] move timer * [3] main attack mode * [4] main attack timer * [5] sub attack mode * [6] sub attack timer * [7] nway attack timer * [8] life mode * [9] number of senators dead * [10 -- 16] senators index * [17] "was green when killed" flag */ count[0] = 0; count[1] = 0; count[2] = -1; count[3] = 1; count[4] = 0; count[5] = 0; count[6] = 0; count[7] = 0; count[8] = 0; count[9] = 0; for (i = 10; i <= 16; i++) count[i] = -1; count[17] = 0; /* list of count_d * [0] speed x * [1] speed y * [2 -- 5] sub attack manager */ count_d[0] = (((double) (WINDOW_WIDTH / 2)) - x) / 360.0; count_d[1] = (((double) (WINDOW_HEIGHT / 4)) - y) / 360.0; for (i = 2; i <= 5; i++) count_d[i] = 0.0; new = tenm_object_new("net can howl core", 0, 0, 100, x, y, 18, count, 6, count_d, 1, p, (int (*)(tenm_object *, double)) (&net_can_howl_core_move), (int (*)(tenm_object *, tenm_object *)) (&net_can_howl_core_hit), (int (*)(tenm_object *, const tenm_object *)) (&net_can_howl_core_act), (int (*)(tenm_object *, int)) (&net_can_howl_core_draw)); if (new == NULL) { fprintf(stderr, "new_can_howl_core_new: tenm_object_new failed\n"); free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int net_can_howl_core_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) return 0; if (turn_per_frame <= 0.5) return 0; dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int net_can_howl_core_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) return 0; if (your == NULL) return 0; if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if ((my->count[8] != 1) && (my->count[8] != 3)) return 0; deal_damage(my, your, 0); if (net_can_howl_core_green(my)) add_chain(my, your); my->count[1] = 2; if (my->hit_point <= 0) { set_background(1); if (my->count[8] == 1) { add_score(20000); net_can_howl_core_second_form(my); return 0; } add_score(80000); net_can_howl_core_explode(my); return 0; } return 0; } static void net_can_howl_core_second_form(tenm_object *my) { int i; int n; /* sanity check */ if (my == NULL) return; if (my->count[8] != 1) return; my->count_d[0] = 0.0; my->count_d[1] = 0.0; tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy), 0); if (net_can_howl_core_green(my)) { my->count[17] = 1; n = 8; } else { my->count[17] = 0; n = 7; } tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 50.0, 20, n, 10.0, 0.0, 20)); tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 1000, n, 10.0, 6)); my->hit_point = 2012; my->count[8] = 2; my->count[2] = -1; my->count[1] = 0; for (i = 0; i < 7; i++) if (my->count[10 + i] >= 0) tenm_table_apply(my->count[10 + i], (int (*)(tenm_object *, int)) (&core_signal_second_form), 0); } static void net_can_howl_core_explode(tenm_object *my) { int i; int n; /* sanity check */ if (my == NULL) return; if (my->count[8] != 3) return; my->count_d[0] = 0.0; my->count_d[1] = 0.0; tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy), 0); if (net_can_howl_core_green(my)) { my->count[17] = 1; n = 8; } else { my->count[17] = 0; n = 7; } tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 20.0, 200, n, 6.0, 0.0, 20)); tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 5000, n, 10.0, 6)); for (i = 0; i < 7; i++) if (my->count[10 + i] >= 0) tenm_table_apply(my->count[10 + i], (int (*)(tenm_object *, int)) core_signal_kill_senator, 0); my->count[8] = 4; my->count[2] = -1; my->count[1] = 0; /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ tenm_mass_delete(my->mass); my->mass = NULL; } static int net_can_howl_core_act(tenm_object *my, const tenm_object *player) { int i; double x; double y; double hand_x; double hand_y; double v[2]; double result[2]; int theta; /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; /* move/add-enemy timer */ (my->count[2])++; /* encounter*/ if (my->count[8] == 0) { if (my->count[2] == 360) { my->attr = ATTR_BOSS | ATTR_OPAQUE; my->hit_mask = ATTR_PLAYER_SHOT; } if ((my->count[2] >= 30) && (my->count[2] <= 210) && (my->count[2] % 30 == 0)) { i = (my->count[2] / 30) - 1; my->count[10 + i] = tenm_table_add(senator_new(my->table_index, i + 1)); if (my->count[10 + i] < 0) { fprintf(stderr, "net_can_howl_core_act: cannnot create senator " "(%d)\n", i); } } if (my->count[2] >= 370) { (my->count[4])++; net_can_howl_core_cannon(my, player); if ((my->count[2] >= 530) && (my->count[4] > 160)) { my->count[3] = 5; my->count[4] = 0; my->count[8] = 1; my->count[2] = -1; } } } /* dead */ if (my->count[8] == 4) { if (my->count[17] != 0) i = 8; else i = 7; if ((my->count[2] >= 30) && (my->count[2] <= 75) && (my->count[2] % 15 == 0)) { theta = rand() % 360; x = my->x + ((double) (my->count[2] * 3)) * tenm_cos(theta); y = my->y + ((double) (my->count[2] * 3)) * tenm_sin(theta); tenm_table_add(fragment_new(x, y, 0.0, 0.0, 30.0, 50, i, 10.0, 0.0, 20)); } if (my->count[2] >= 120) { tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 5000, i, 10.0, 9)); tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 2, 1000, i, 7.5, 12)); tenm_table_add(stage_clear_new(100)); return 1; } } /* self-destruction */ if ((my->count[8] == 1) && (my->count[2] >= 2760)) { set_background(2); clear_chain(); net_can_howl_core_second_form(my); return 0; } if ((my->count[8] == 3) && (my->count[2] >= 8030)) { set_background(2); clear_chain(); net_can_howl_core_explode(my); return 0; } /* speed change */ if (my->count[8] == 0) { if (my->count[2] == 360) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } } else if (my->count[8] == 1) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } else if (my->count[8] == 2) { if (my->count[2] == 30) { my->attr = 0; my->hit_mask = 0; my->count[17] = 0; result[0] = 0.0; result[1] = 0.0; net_can_howl_position(result, 0, 0, 0); my->count_d[0] = (result[0] - my->x) / 120.0; my->count_d[1] = (result[1] - my->y) / 120.0; } if (my->count[2] == 150) { my->attr = ATTR_BOSS | ATTR_OPAQUE; my->hit_mask = ATTR_PLAYER_SHOT; my->count_d[0] = 0.0; my->count_d[1] = 0.0; } } else if (my->count[8] == 3) { result[0] = 0.0; result[1] = 0.0; net_can_howl_position(result, 0, 0, my->count[2] + 1); my->count_d[0] = result[0] - my->x; my->count_d[1] = result[1] - my->y; } else if (my->count[8] == 4) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } /* shape change */ if (my->count[8] == 3) { x = result[0]; y = result[1]; result[0] = 0.0; result[1] = 0.0; net_can_howl_position(result, 8, 0, my->count[2] + 1); hand_x = result[0] - x; hand_y = result[1] - y; } else { x = my->x; y = my->y; hand_x = 30.0; hand_y = 0.0; } if (my->mass != NULL) { (((tenm_polygon *)(my->mass->p[0]))->v[0])->x = x + hand_x - hand_y * 0.5; (((tenm_polygon *)(my->mass->p[0]))->v[0])->y = y + hand_y + hand_x * 0.5; (((tenm_polygon *)(my->mass->p[0]))->v[1])->x = x - hand_x - hand_y * 0.5; (((tenm_polygon *)(my->mass->p[0]))->v[1])->y = y - hand_y + hand_x * 0.5; (((tenm_polygon *)(my->mass->p[0]))->v[2])->x = x - hand_x + hand_y * 0.5; (((tenm_polygon *)(my->mass->p[0]))->v[2])->y = y - hand_y - hand_x * 0.5; (((tenm_polygon *)(my->mass->p[0]))->v[3])->x = x + hand_x + hand_y * 0.5; (((tenm_polygon *)(my->mass->p[0]))->v[3])->y = y + hand_y - hand_x * 0.5; } if ((my->count[8] == 2) && (my->count[2] >= 180)) { my->count[8] = 3; my->count[2] = -1; my->count[17] = 0; return 0; } /* add normal enemy */ if ((my->count[8] == 1) && (my->count[2] >= 200) && (my->count[2] < 2000)) { if ((my->count[2] % 200 == 0) || (my->count[2] % 200 == 10)) { tenm_table_add(voter_new(10, my->count[2] % 200)); tenm_table_add(voter_new(11, my->count[2] % 200)); } if ((my->count[2] % 200 == 80) || (my->count[2] % 200 == 90)) { tenm_table_add(voter_new(9, my->count[2] % 200 - 80)); } if ((my->count[2] % 200 == 100) || (my->count[2] % 200 == 110)) { tenm_table_add(voter_new(13, my->count[2] % 200 - 100)); tenm_table_add(voter_new(14, my->count[2] % 200 - 100)); } if ((my->count[2] % 200 == 180) || (my->count[2] % 200 == 190)) { tenm_table_add(voter_new(12, my->count[2] % 200 - 180)); } } if ((my->count[8] == 0) && (my->count[2] == 0)) tenm_table_add(net_can_howl_more_1_new()); if ((my->count[8] == 1) && (my->count[2] == 2160)) tenm_table_add(net_can_howl_more_1_new()); if (my->count[8] == 3) { if (((my->count[2] >= 0) && (my->count[2] < 1000)) || ((my->count[2] >= 4000) && (my->count[2] < 5000))) { if ((my->count[2] % 200 == 0) || (my->count[2] % 200 == 10)) tenm_table_add(voter_new(15, my->count[2])); else if ((my->count[2] % 200 == 40) || (my->count[2] % 200 == 50)) tenm_table_add(voter_new(16, my->count[2])); else if ((my->count[2] % 200 == 120) || (my->count[2] % 200 == 130)) tenm_table_add(voter_new(18, my->count[2])); else if ((my->count[2] % 200 == 160) || (my->count[2] % 200 == 170)) tenm_table_add(voter_new(17, my->count[2])); } else if (((my->count[2] >= 1800) && (my->count[2] < 2800)) || ((my->count[2] >= 5800) && (my->count[2] < 6800))) { if ((my->count[2] % 200 == 0) || (my->count[2] % 200 == 10)) tenm_table_add(voter_new(19, my->count[2])); else if ((my->count[2] % 200 == 50) || (my->count[2] % 200 == 60)) tenm_table_add(voter_new(20, my->count[2])); else if ((my->count[2] % 200 == 100) || (my->count[2] % 200 == 110)) tenm_table_add(voter_new(21, my->count[2])); else if ((my->count[2] % 200 == 150) || (my->count[2] % 200 == 160)) tenm_table_add(voter_new(22, my->count[2])); } } /* no attack if it is not 2nd form */ if (my->count[8] != 3) return 0; /* main attack */ (my->count[4])++; switch(my->count[3]) { case 1: if ((my->count[9] == 3) || (my->count[9] == 7)) { if (my->mass == NULL) { my->count[4] = 0; break; } if ((my->count[4] >= 50) && (my->count[4] <= 58)) { v[0] = (((tenm_polygon *)(my->mass->p[0]))->v[1])->x - (((tenm_polygon *)(my->mass->p[0]))->v[3])->x; v[1] = (((tenm_polygon *)(my->mass->p[0]))->v[1])->y - (((tenm_polygon *)(my->mass->p[0]))->v[3])->y; v[0] *= 6.0; v[1] *= 6.0; result[0] = v[0]; result[1] = v[1]; theta = (my->count[4] - 50) * (my->count[4] - 50) * 3; vector_rotate(result, v, -theta); tenm_table_add(laser_new(my->x, my->y, my->count_d[0], my->count_d[1], result[0], result[1], 3, 1, 0)); } } if (my->count[4] >= 75) { my->count[3] = 3; my->count[4] = 0; } break; case 3: if ((my->count[9] == 4) || (my->count[9] == 7)) { if (my->mass == NULL) { my->count[4] = 0; break; } net_can_howl_core_cannon(my, player); } if (my->count[4] >= 159) { my->count[3] = 5; my->count[4] = 0; } break; case 5: if (my->count[9] >= 6) { if (my->count[4] >= 150) { tenm_table_add(net_can_howl_seeker_new(my->count[2], 5)); } } if (my->count[4] >= 150) { my->count[3] = 1; my->count[4] = 0; } break; default: break; } /* sub attack */ (my->count[6])++; switch(my->count[5]) { case 0: case 1: if (((my->count[9] >= 2) && (my->count[5] == 0)) || ((my->count[9] >= 3) && (my->count[5] == 1))) { if (my->count[6] == 50) { my->count_d[2] = player->x; my->count_d[3] = player->y; } else if (my->count[6] >= 70) { my->count_d[4] = my->x; my->count_d[5] = my->y; tenm_table_add(laser_point_new(my->x, my->y, 25.0, my->count_d[2], my->count_d[3], 50.0, 3)); } } if (my->count[6] >= 70) { (my->count[5])++; if (my->count[5] > 5) my->count[5] = 0; my->count[6] = 0; } break; case 2: case 3: case 5: if (my->count[9] >= 7) { if (my->count[6] >= 100) { x = (double) (rand() % WINDOW_WIDTH); y = (double) (rand() % WINDOW_HEIGHT); tenm_table_add(net_can_howl_black_hole_new(x, y)); } } if (my->count[6] >= 100) { (my->count[5])++; if (my->count[5] > 5) my->count[5] = 0; my->count[6] = 0; } break; case 4: if (my->count[9] >= 5) { if (my->count[6] >= 70) { tenm_table_add(laser_point_new(my->count_d[4], my->count_d[5], 25.0, my->count_d[2], my->count_d[3], 50.0, 5)); } } if (my->count[6] >= 70) { (my->count[5])++; if (my->count[5] > 5) my->count[5] = 0; my->count[6] = 0; } break; default: break; } /* nway attack */ (my->count[7])++; if ((((my->count[9] == 1) || (my->count[9] == 6)) && (my->count[7] == 60)) || ((my->count[9] == 2) && (my->count[7] == 75)) || ((my->count[9] == 3) && (my->count[7] == 90)) || ((my->count[9] == 4) && (my->count[7] == 105)) || (((my->count[9] == 5) || (my->count[9] == 6)) && (my->count[7] == 120)) || ((my->count[9] >= 7) && (my->count[7] >= 60) && (my->count[7] <= 120) && (my->count[7] % 15 == 0))) { v[0] = player->x - my->x; v[1] = player->y - my->y; result[0] = v[0]; result[1] = v[1]; theta = -10 - 10 * ((my->count[7] - 60) / 15); vector_rotate(result, v, -theta); for (i = 0; i < 2 * ((my->count[7] - 60) / 15) + 3; i++) { vector_rotate(result, v, theta + 10 * i); tenm_table_add(laser_point_new(my->x, my->y, 7.0, my->x + result[0], my->y + result[1], 25.0, 5)); } } if (my->count[7] >= 120) my->count[7] = 0; return 0; } /* return 1 if shooting is done, 0 if not */ static int net_can_howl_core_cannon(tenm_object *my, const tenm_object *player) { double a_x; double a_y; double b_x; double b_y; double v[2]; int i; double s; double x; double y; double result[2]; int theta; /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; if (my->mass == NULL) { return 0; } if ((my->count[4] >= 120) && (my->count[4] < 140) && (my->count[4] % 2 == 0)) { a_x = (((tenm_polygon *)(my->mass->p[0]))->v[0])->x; a_y = (((tenm_polygon *)(my->mass->p[0]))->v[0])->y; b_x = (((tenm_polygon *)(my->mass->p[0]))->v[1])->x; b_y = (((tenm_polygon *)(my->mass->p[0]))->v[1])->y; v[0] = (((tenm_polygon *)(my->mass->p[0]))->v[0])->x - (((tenm_polygon *)(my->mass->p[0]))->v[3])->x; v[1] = (((tenm_polygon *)(my->mass->p[0]))->v[0])->y - (((tenm_polygon *)(my->mass->p[0]))->v[3])->y; for (i = 0; i < 2; i++) { if (i == 0) s = (double) (my->count[4] % 8) / 2; else s = 7 - (double) (my->count[4] % 8) / 2; x = (a_x * (7.0 - s) + b_x * s) / 7.0; y = (a_y * (7.0 - s) + b_y * s) / 7.0; result[0] = v[0]; result[1] = v[1]; theta = 15 - (my->count[4] - 120); if (theta < -15) theta = -15; if (i != 0) theta *= -1; vector_rotate(result, v, -theta); tenm_table_add(laser_point_new(x, y, 25.0, x + result[0], y + result[1], 30.0, 2)); } } if (my->count[4] >= 159) { return 1; } return 0; } static int net_can_howl_core_draw(tenm_object *my, int priority) { int i; double a_x; double a_y; double b_x; double b_y; double dx; double dy; double length; double v[2]; double result[2]; int theta; tenm_color color; char temp[32]; int status = 0; /* sanity check */ if (my == NULL) return 0; /* wraith form */ if ((my->count[8] == 0) && (my->count[2] >= 0) && (my->count[2] < 360) && (priority == 0)) { length = 30.0 + ((double) ((360 - my->count[2]) * 2)); net_can_howl_core_draw_wraith(my->x, my->y, length, my->count[2] * (-1), 90 + my->count[2] * (-1), 0); } if ((my->count[8] == 2) && (my->count[2] >= 30) && (my->count[2] < 150) && (priority == 0)) { if (my->count[2] < 90) length = 30.0 + ((double) ((my->count[2] - 30) * 3)); else length = 30.0 + ((double) ((150 - my->count[2]) * 3)); net_can_howl_core_draw_wraith(my->x, my->y, length, (my->count[2] - 30) * 3, 90 + (my->count[2] - 30) * 3, 0); } if ((my->count[8] == 4) && (my->count[2] >= 0) && (my->count[2] < 120) && (priority == -1)) { if (my->count[2] <= 90) length = 30.0 + ((double) ((my->count[2]) * 4)); else length = ((double) ((120 - my->count[2]) * 13)); if (length < NEAR_ZERO) length = 1.0; net_can_howl_core_draw_wraith(my->x, my->y, length, my->count[2] * (-6), 90 + my->count[2] * (-3), my->count[17]); } /* decoration */ if (priority == 0) { /* arrow */ if ((my->count[8] == 3) && ((my->count[5] == 0) || (my->count[5] == 1)) && (my->count[6] >= 50) && (my->count[6] < 70) && (((my->count[9] >= 2) && (my->count[5] == 0)) || ((my->count[9] >= 3) && (my->count[5] == 1)))) { color = tenm_map_color(99, 128, 158); if (tenm_draw_circle((int) (my->x), (int) (my->y), 15 + (my->count[6] - 50), 1, color) != 0) status = 1; dx = my->count_d[2] - my->x; dy = my->count_d[3] - my->y; length = tenm_sqrt((int) (dx * dx + dy * dy)); if (length < NEAR_ZERO) length = 1.0; if (tenm_draw_line((int) (my->x), (int) (my->y), (int) (my->x + 50.0 * dx / length), (int) (my->y + 50.0 * dy / length), 1, color)) status = 1; } /* warp arrow */ if ((my->count[8] == 3) && (my->count[5] == 4) && (my->count[6] >= 50) && (my->count[6] < 70) && (my->count[9] >= 5)) { color = tenm_map_color(142, 99, 158); if (tenm_draw_circle((int) (my->count_d[4]), (int) (my->count_d[5]), 15 + (my->count[6] - 50), 1, color) != 0) status = 1; dx = my->count_d[2] - my->count_d[4]; dy = my->count_d[3] - my->count_d[5]; length = tenm_sqrt((int) (dx * dx + dy * dy)); if (length < NEAR_ZERO) length = 1.0; if (tenm_draw_line((int) (my->count_d[4]), (int) (my->count_d[5]), (int) (my->count_d[4] + 50.0 * dx / length), (int) (my->count_d[5] + 50.0 * dy / length), 1, color)) status = 1; } /* blade */ if ((my->count[8] == 3) && (my->mass != NULL) && (my->count[3] == 1) && (my->count[4] >= 1) && (my->count[4] < 45) && ((my->count[9] == 3) || (my->count[9] == 7))) { v[0] = (((tenm_polygon *)(my->mass->p[0]))->v[1])->x - (((tenm_polygon *)(my->mass->p[0]))->v[3])->x; v[1] = (((tenm_polygon *)(my->mass->p[0]))->v[1])->y - (((tenm_polygon *)(my->mass->p[0]))->v[3])->y; v[0] *= 6.0; v[1] *= 6.0; for (i = 0; i <= my->count[4] / 5; i++) { if (i == my->count[4] / 5) color = tenm_map_color(99, 128, 158); else color = tenm_map_color(158, 158, 158); result[0] = v[0]; result[1] = v[1]; theta = i * i * 3; vector_rotate(result, v, -theta); if (tenm_draw_line((int) (my->x), (int) (my->y), (int) (my->x + result[0]), (int) (my->y + result[1]), 1, color)) status = 1; } } /* main cannon */ if (((my->count[8] == 0) || (my->count[8] == 3)) && (my->mass != NULL) && (((my->count[3] == 3) && ((my->count[9] == 4) || (my->count[9] == 7))) || (my->count[8] == 0)) && (my->count[4] >= 1) && (my->count[4] < 140)) { v[0] = (((tenm_polygon *)(my->mass->p[0]))->v[0])->x - (((tenm_polygon *)(my->mass->p[0]))->v[3])->x; v[1] = (((tenm_polygon *)(my->mass->p[0]))->v[0])->y - (((tenm_polygon *)(my->mass->p[0]))->v[3])->y; v[0] *= 27.0; v[1] *= 27.0; a_x = (((tenm_polygon *)(my->mass->p[0]))->v[0])->x; a_y = (((tenm_polygon *)(my->mass->p[0]))->v[0])->y; b_x = (((tenm_polygon *)(my->mass->p[0]))->v[1])->x; b_y = (((tenm_polygon *)(my->mass->p[0]))->v[1])->y; if (my->count[4] < 35) theta = 15 + 90; else if (my->count[4] < 80) theta = 15 + (80 - my->count[4]) * 2; else theta = 15; if (my->count[4] < 80) color = tenm_map_color(158, 158, 158); else color = tenm_map_color(99, 143, 158); result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, -theta); if (tenm_draw_line((int) (a_x), (int) (a_y), (int) (a_x + result[0]), (int) (a_y + result[1]), 1, color)) status = 1; vector_rotate(result, v, theta); if (tenm_draw_line((int) (b_x), (int) (b_y), (int) (b_x + result[0]), (int) (b_y + result[1]), 1, color)) status = 1; } } /* body */ if (priority == 0) { if ((my->count[8] == 1) || (my->count[8] == 3) || ((my->count[8] == 0) && (my->count[2] > 360)) || ((my->count[8] == 2) && ((my->count[2] < 30) || (my->count[2] > 150)))) { if (net_can_howl_core_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 1) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (my->mass != NULL) { for (i = 0; i < 4; i++) { a_x = (int) ((((tenm_polygon *)(my->mass->p[0]))->v[i % 4])->x); a_y = (int) ((((tenm_polygon *)(my->mass->p[0]))->v[i % 4])->y); b_x = (int) ((((tenm_polygon *)(my->mass->p[0]))->v[(i+1) % 4])->x); b_y = (int) ((((tenm_polygon *)(my->mass->p[0]))->v[(i+1) % 4])->y); if (tenm_draw_line(a_x, a_y, b_x, b_y, 3, color) != 0) status = 1; } } } } /* hit point stat */ if (((my->count[8] == 1) || (my->count[8] == 3)) && (priority == 0)) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 5, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "net_can_howl_core_draw: draw_string failed\n"); status = 1; } } return status; } static int net_can_howl_core_draw_wraith(double x, double y, double length, int theta, int theta_z, int green) { int i; double a_x; double a_y; double b_x; double b_y; tenm_color color; int status = 0; /* sanity check */ if (length < NEAR_ZERO) return 0; if (green != 0) color = tenm_map_color(157, 182, 123); else color = tenm_map_color(182, 147, 123); for (i = 0; i < 360; i += 90) { a_x = tenm_cos(theta + i) - tenm_sin(theta + i); a_y = (tenm_sin(theta + i) + tenm_cos(theta + i)) * tenm_cos(theta_z) - 0.5 * tenm_sin(theta_z); b_x = tenm_cos(theta + i + 90) - tenm_sin(theta+ i + 90); b_y = (tenm_sin(theta + i + 90) + tenm_cos(theta + i + 90)) * tenm_cos(theta_z) - 0.5 * tenm_sin(theta_z); a_x *= length; a_y *= length; b_x *= length; b_y *= length; a_x += x; a_y += y; b_x += x; b_y += y; if (tenm_draw_line((int) a_x, (int) a_y, (int) b_x, (int) b_y, 1, color) != 0) status = 1; } for (i = 0; i < 360; i += 90) { a_x = tenm_cos(-(theta + i)) - tenm_sin(-(theta + i)); a_y = (tenm_sin(-(theta + i)) + tenm_cos(-(theta + i))) * tenm_cos(theta_z) + 0.5 * tenm_sin(theta_z); b_x = tenm_cos(-(theta + i + 90)) - tenm_sin(-(theta+ i + 90)); b_y = (tenm_sin(-(theta + i + 90)) + tenm_cos(-(theta + i + 90))) * tenm_cos(theta_z) + 0.5 * tenm_sin(theta_z); a_x *= length; a_y *= length; b_x *= length; b_y *= length; a_x += x; a_y += y; b_x += x; b_y += y; if (tenm_draw_line((int) a_x, (int) a_y, (int) b_x, (int) b_y, 1, color) != 0) status = 1; } for (i = 0; i < 360; i += 90) { a_x = tenm_cos(theta + i) - tenm_sin(theta + i); a_y = (tenm_sin(theta + i) + tenm_cos(theta + i)) * tenm_cos(theta_z) - 0.5 * tenm_sin(theta_z); b_x = tenm_cos(-(theta + i + 90)) - tenm_sin(-(theta+ i + 90)); b_y = (tenm_sin(-(theta + i + 90)) + tenm_cos(-(theta + i + 90))) * tenm_cos(theta_z) + 0.5 * tenm_sin(theta_z); a_x *= length; a_y *= length; b_x *= length; b_y *= length; a_x += x; a_y += y; b_x += x; b_y += y; if (tenm_draw_line((int) a_x, (int) a_y, (int) b_x, (int) b_y, 1, color) != 0) status = 1; } return status; } /* return 1 (true) or 0 (false) */ static int net_can_howl_core_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if (my->count[8] == 1) { if ((my->count[2] >= 2630) && (my->count[2] < 2730)) return 1; } else if (my->count[8] == 2) { if (my->count[17] != 0) return 1; } else if (my->count[8] == 3) { if ((my->count[9] >= 7) && (my->count[2] < 8000)) return 1; } return 0; } static tenm_object * net_can_howl_black_hole_new(double x, double y) { tenm_object *new = NULL; int *count = NULL; count = (int *) malloc(sizeof(int) * 3); if (count == NULL) { fprintf(stderr, "net_can_howl_black_hole_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] color (for delete_enemy_shot) * [1] shoot timer * [2] shoot theta */ count[0] = 6; count[1] = 1; count[2] = 0; /* ATTR_ENEMY_SHOT is only to clear it when the player is killed */ new = tenm_object_new("net can howl black-hole", ATTR_ENEMY_SHOT, 0, 0, x, y, 3, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&net_can_howl_black_hole_act), (int (*)(tenm_object *, int)) (&net_can_howl_black_hole_draw)); if (new == NULL) { fprintf(stderr, "net_can_howl_black_hole_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int net_can_howl_black_hole_act(tenm_object *my, const tenm_object *player) { /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; (my->count[1])++; if ((my->count[1] >= 30) && (my->count[1] <= 75)) { if (my->count[1] % 5 == 0) { my->count[2] = rand() % 360; tenm_table_add(normal_shot_new(my->x + 816.0 * tenm_cos(my->count[2]), my->y + 816.0 * tenm_sin(my->count[2]), -8.0 * tenm_cos(my->count[2]), -8.0 * tenm_sin(my->count[2]), 4, 102, 102)); } } if (my->count[1] >= 80) return 1; return 0; } static int net_can_howl_black_hole_draw(tenm_object *my, int priority) { int r; double r_d; tenm_color color; int status = 0; /* sanity check */ if (my == NULL) return 0; if (priority != 0) return 0; color = tenm_map_color(158, 158, 158); if (my->count[1] <= 20) r = my->count[1] * 5; else if (my->count[1] <= 30) r = 100; else r = 100 - (my->count[1] - 30) * 2; if (r < 1) r = 1; if (tenm_draw_circle((int) (my->x), (int) (my->y), r, 1, color) != 0) status = 1; if ((my->count[1] >= 30) && (my->count[1] <= 75)) { r_d = (double) ((r / 2) + 50 * (4 - (my->count[1] % 5))); if (r_d < 1.0) r_d = 1.0; if (tenm_draw_line((int) (my->x + r_d * tenm_cos(my->count[2])), (int) (my->y + r_d * tenm_sin(my->count[2])), (int) (my->x + (r_d + 150.0) * tenm_cos(my->count[2])), (int) (my->y + (r_d + 150.0) * tenm_sin(my->count[2])), 1, color) != 0) status = 1; } return status; } static tenm_object * net_can_howl_seeker_new(int t, int n) { int i; int suffix; int suffix_d; double x; double y; double result[2]; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; result[0] = 0.0; result[1] = 0.0; net_can_howl_position(result, 0, 0, t); x = result[0]; y = result[1]; count = (int *) malloc(sizeof(int) * (6 + n)); if (count == NULL) { fprintf(stderr, "net_can_howl_seeker_new: malloc(count) failed\n"); return NULL; } count_d = (double *) malloc(sizeof(double) * (n * 2)); if (count_d == NULL) { fprintf(stderr, "net_can_howl_seeker_new: malloc(count_d) failed\n"); free(count); return NULL; } /* list of count * [0] color (for delete_enemy_shot) * [1] shoot timer * [2] total number of markers * [3] number of laser fired * [4] activated marker * [5] core tracking timer * [6 -- ] "marker used" flag */ count[0] = 6; count[1] = 30; count[2] = n; count[3] = 0; count[4] = -1; count[5] = t; for (i = 0; i < n; i++) { suffix = i + 6; count[suffix + 0] = 0; } /* list of count_d * [0 --] marker (x, y) */ for (i = 0; i < n; i++) { suffix_d = i * 2; count_d[suffix_d + 0] = (double) (rand() % WINDOW_WIDTH); count_d[suffix_d + 1] = (double) (rand() % WINDOW_HEIGHT); } /* ATTR_ENEMY_SHOT is only to clear it when the player is killed */ new = tenm_object_new("net can howl seeker", ATTR_ENEMY_SHOT, 0, 0, x, y, 6 + n, count, n * 2, count_d, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&net_can_howl_seeker_act), (int (*)(tenm_object *, int)) (&net_can_howl_seeker_draw)); if (new == NULL) { fprintf(stderr, "net_can_howl_seeker_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); return NULL; } return new; } static int net_can_howl_seeker_act(tenm_object *my, const tenm_object *player) { int i; double x; double y; double source_x; double source_y; double target_x; double target_y; double dx; double dy; double length; double length_max; int target_n; int suffix; int suffix_d; int life; double result[2]; /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; (my->count[5])++; /* to please delete_enemy_shot) */ result[0] = 0.0; result[1] = 0.0; net_can_howl_position(result, 0, 0, my->count[5]); my->x = result[0]; my->y = result[1]; (my->count[1])--; if (my->count[1] <= 0) { if ((my->count[3] == 0) || (my->count[4] < 0)) { source_x = my->x; source_y = my->y; } else { suffix_d = my->count[4] * 2; source_x = my->count_d[suffix_d + 0]; source_y = my->count_d[suffix_d + 1]; } target_x = player->x; target_y = player->y; target_n = -1; if (my->count[3] >= my->count[2]) { tenm_table_add(laser_point_new(source_x, source_y, 25.0, player->x, player->y, 25.0, 3)); return 1; } length_max = -1.0; for (i = 0; i < my->count[2]; i++) { suffix = i + 6; suffix_d = i * 2; if (my->count[suffix + 0] != 0) continue; x = my->count_d[suffix_d + 0]; y = my->count_d[suffix_d + 1]; dx = x - source_x; dy = y - source_y; length = dx * dx + dy * dy; if (length > length_max) { target_x = x; target_y = y; target_n = i; length_max = length; } } dx = target_x - source_x; dy = target_y - source_y; length = tenm_sqrt((int) (dx * dx + dy * dy)); if (length < NEAR_ZERO) length = 1.0; life = (int) (length / 25.0); if (life <= 0) life = 1; tenm_table_add(laser_new(source_x, source_y, 25.0 * dx / length, 25.0 * dy / length, 25.0 * dx / length, 25.0 * dy / length, 3, life, 0)); my->count[1] = life + 10; (my->count[3])++; my->count[4] = target_n; if (target_n >= 0) { suffix = target_n + 6; my->count[suffix + 0] = 1; } if (my->count[3] > my->count[2]) return 1; } return 0; } static int net_can_howl_seeker_draw(tenm_object *my, int priority) { int i; int suffix; int suffix_d; int theta; int x; int y; int dx; tenm_color color; int status = 0; /* sanity check */ if (my == NULL) return 0; if (priority != 0) return 0; for (i = 0; i < my->count[2]; i++) { suffix = i + 6; suffix_d = i * 2; if ((my->count[suffix + 0] != 0) && (my->count[4] != i)) continue; if ((my->count[4] == i) && (my->count[1] < 10)) color = tenm_map_color(0, 111, 223); else color = tenm_map_color(158, 158, 158); theta = (my->count[5] * 3) % 360 + i * 360 / my->count[2]; x = (int) (my->count_d[suffix_d + 0]); y = (int) (my->count_d[suffix_d + 1]); dx = (int) (25.0 * tenm_cos(theta)); if (tenm_draw_line(x, y + 25, x + dx, y, 1, color) != 0) status = 1; if (tenm_draw_line(x, y - 25, x + dx, y, 1, color) != 0) status = 1; if (tenm_draw_line(x, y + 25, x - dx, y, 1, color) != 0) status = 1; if (tenm_draw_line(x, y - 25, x - dx, y, 1, color) != 0) status = 1; } return status; } static tenm_object * senator_new(int table_index, int what) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = 0.0; double y = 0.0; double target_x; double target_y; /* sanity check */ if (table_index < 0) { fprintf(stderr, "senator_new: strange table_index (%d)\n", table_index); return NULL; } if ((what < 1) || (what > 7)) { fprintf(stderr, "senator_new: strange what (%d)\n", what); return NULL; } if (what % 2 == 0) { x = -29.0; y = (double) (WINDOW_HEIGHT / 4); } else { x = ((double) (WINDOW_WIDTH)) + 29.0; y = (double) (WINDOW_HEIGHT / 4); } target_x = ((double) (WINDOW_WIDTH / 2)) + ((double) (WINDOW_WIDTH / 2)) * tenm_cos(-90 + 360 * (what - 1) / 7); target_y = ((double) (WINDOW_HEIGHT / 4)) + ((double) (WINDOW_HEIGHT / 4)) * tenm_sin(-90 + 360 * (what - 1) / 7); p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "senator_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_circle_new(x, y, 30.0); if (p[0] == NULL) { fprintf(stderr, "senator_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 8); if (count == NULL) { fprintf(stderr, "senator_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 6); if (count_d == NULL) { fprintf(stderr, "senator_new: malloc(count_d) failed\n"); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] move timer * [3] what * [4] shoot timer * [5] shoot manager * [6] core index * [7] life mode */ count[0] = 0; count[1] = 0; count[2] = 330 - what * 30; count[3] = what; count[4] = -100; if (what == 7) count[5] = 400; else count[5] = 0; count[6] = table_index; count[7] = 0; /* list of count_d * [0] speed x * [1] speed y * [2 -- 3] shoot manager * [4 -- 5] decoration manager */ count_d[0] = (target_x - x) / ((double) (count[2])); count_d[1] = (target_y - y) / ((double) (count[2])); count_d[2] = 0.0; count_d[3] = 0.0; count_d[4] = 0.0; count_d[5] = 0.0; new = tenm_object_new("Senator", ATTR_BOSS, ATTR_PLAYER_SHOT, 400, x, y, 8, count, 6, count_d, 1, p, (int (*)(tenm_object *, double)) (&senator_move), (int (*)(tenm_object *, tenm_object *)) (&senator_hit), (int (*)(tenm_object *, const tenm_object *)) (&senator_act), (int (*)(tenm_object *, int)) (&senator_draw)); if (new == NULL) { fprintf(stderr, "senator_new: tenm_object_new failed\n"); free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int senator_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) return 0; if (turn_per_frame <= 0.5) return 0; dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int senator_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) return 0; if (your == NULL) return 0; if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if ((my->count[7] != 1) && (my->count[7] != 3)) return 0; deal_damage(my, your, 0); if (senator_green(my)) add_chain(my, your); my->count[1] = 41; if (my->hit_point <= 0) { senator_explode(my); add_score(15000); tenm_table_apply(my->count[6], (int (*)(tenm_object *, int)) (&senator_signal), my->table_index); return 1; } return 0; } static void senator_explode(tenm_object *my) { int n; /* sanity check */ if (my == NULL) return; if (senator_green(my)) n = 8; else n = 7; tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 1, 1000, n, 8.0, 6)); tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 2, 300, n, 5.0, 8)); /* no signal here --- this can be called at the core self-destruction */ } static int senator_act(tenm_object *my, const tenm_object *player) { int i; int theta; double temp[2]; double result[2]; /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; /* decoration */ my->count_d[4] = player->x; my->count_d[5] = player->y; /* speed change */ if (my->count[7] == 0) (my->count[2])--; else (my->count[2])++; if (my->count[7] == 0) { if (my->count[2] == 0) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[2] < -200) { my->count[2] = -1; my->count[7] = 1; } } else if ((my->count[7] == 1) || (my->count[7] == 3)) { if (my->count[7] == 3) { result[0] = 0.0; result[1] = 0.0; net_can_howl_position(result, my->count[3], 0, my->count[2] + 1); } else { theta = -90 + 360 * (my->count[3] - 1) / 7 + (8 - my->count[3]) * (my->count[2] + 1) / 2; result[0] = ((double) (WINDOW_WIDTH / 2)) + ((double) (WINDOW_WIDTH / 2)) * tenm_cos(theta); result[1] = ((double) (WINDOW_HEIGHT / 4)) + ((double) (WINDOW_HEIGHT / 4)) * tenm_sin(theta); } my->count_d[0] = result[0] - my->x; my->count_d[1] = result[1] - my->y; } else if (my->count[7] == 2) { if (my->count[2] == 0) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } else if (my->count[2] == 30) { result[0] = 0.0; result[1] = 0.0; net_can_howl_position(result, my->count[3], 0, 0); my->count_d[0] = (result[0] - my->x) / 120.0; my->count_d[1] = (result[1] - my->y) / 120.0; } else if (my->count[2] == 150) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } } if ((my->count[7] == 2) && (my->count[2] >= 180)) { my->count[7] = 3; my->count[2] = -1; my->count[4] = -100; return 0; } if ((my->count[7] != 1) && (my->count[7] != 3)) return 0; /* shoot */ (my->count[4])++; switch(my->count[3]) { case 1: if (my->count[4] == 50) { my->count_d[2] = player->x; my->count_d[3] = player->y; tenm_table_add(normal_shot_point_new(my->x, my->y, 9.0, my->count_d[2], my->count_d[3], 1)); } else if (my->count[4] == 55) { temp[0] = my->count_d[2] - my->x; temp[1] = my->count_d[3] - my->y; result[0] = 0.0; result[1] = 0.0; vector_rotate(result, temp, 5); tenm_table_add(normal_shot_point_new(my->x, my->y, 9.0, my->x + result[0], my->y + result[1], 1)); vector_rotate(result, temp, -5); tenm_table_add(normal_shot_point_new(my->x, my->y, 9.0, my->x + result[0], my->y + result[1], 1)); } else if (my->count[4] >= 60) { tenm_table_add(normal_shot_point_new(my->x, my->y, 9.0, my->count_d[2], my->count_d[3], 1)); my->count[4] = 0; } break; case 2: if (my->count[4] == 48) { my->count[5] = rand() % 360; for (i = 0; i < 360; i += 24) tenm_table_add(normal_shot_angle_new(my->x, my->y, 5.0, my->count[5] + i, 0)); } else if (my->count[4] >= 96) { for (i = 0; i < 360; i += 24) tenm_table_add(normal_shot_angle_new(my->x, my->y, 5.0, my->count[5] + 12 + i, 0)); my->count[4] = 0; } break; case 3: if (my->count[4] >= 20) { tenm_table_add(normal_shot_point_new(my->x, my->y, 4.0 + ((double) (rand() % 8)) / 4.0, player->x + (double) (-50 + rand() % 101), player->y + (double) (-50 + rand() % 101), 1)); my->count[4] = 0; } break; case 4: if (my->count[4] == 64) { my->count[5] = rand() % 360; for (i = 0; i < 360; i += 60) { tenm_table_add(normal_shot_angle_new(my->x, my->y, 5.5, my->count[5] + i, 0)); tenm_table_add(normal_shot_angle_new(my->x, my->y, 5.5, my->count[5] + 10 + i, 0)); } } else if (my->count[4] >= 74) { for (i = 0; i < 360; i += 60) { tenm_table_add(normal_shot_angle_new(my->x, my->y, 6.5, my->count[5] + 30 + i, 0)); tenm_table_add(normal_shot_angle_new(my->x, my->y, 6.5, my->count[5] + 30 + 10 + i, 0)); } my->count[4] = 0; } break; case 5: if (my->count[4] == 55) { my->count_d[2] = player->x; my->count_d[3] = player->y; temp[0] = my->count_d[2] - my->x; temp[1] = my->count_d[3] - my->y; result[0] = 0.0; result[1] = 0.0; vector_rotate(result, temp, 21); tenm_table_add(normal_shot_point_new(my->x, my->y, 9.0, my->x + result[0], my->y + result[1], 1)); vector_rotate(result, temp, -21); tenm_table_add(normal_shot_point_new(my->x, my->y, 9.0, my->x + result[0], my->y + result[1], 1)); } else if (my->count[4] == 60) { temp[0] = my->count_d[2] - my->x; temp[1] = my->count_d[3] - my->y; result[0] = 0.0; result[1] = 0.0; vector_rotate(result, temp, 13); tenm_table_add(normal_shot_point_new(my->x, my->y, 8.0, my->x + result[0], my->y + result[1], 1)); vector_rotate(result, temp, -13); tenm_table_add(normal_shot_point_new(my->x, my->y, 8.0, my->x + result[0], my->y + result[1], 1)); } else if (my->count[4] >= 65) { temp[0] = my->count_d[2] - my->x; temp[1] = my->count_d[3] - my->y; result[0] = 0.0; result[1] = 0.0; vector_rotate(result, temp, 5); tenm_table_add(normal_shot_point_new(my->x, my->y, 7.0, my->x + result[0], my->y + result[1], 1)); vector_rotate(result, temp, -5); tenm_table_add(normal_shot_point_new(my->x, my->y, 7.0, my->x + result[0], my->y + result[1], 1)); my->count[4] = 0; } break; case 6: if (my->count[4] >= 7) { tenm_table_add(normal_shot_angle_new(my->x, my->y, 3.0 + ((double) (rand() % 8)) / 4.0, rand() % 360, 0)); my->count[4] = 0; } break; case 7: if (my->count[5] > my->hit_point) { tenm_table_add(normal_shot_point_new(my->x, my->y, 6.0 + ((double)(rand() % 48)) /16.0, player->x + (double) (-25 + rand() % 51), player->y + (double) (-25 + rand() % 51), 5)); (my->count[5]) -= 5; } break; default: break; } return 0; } static int senator_draw(tenm_object *my, int priority) { double dx; double dy; double length; tenm_color color; char temp[32]; int status = 0; /* sanity check */ if (my == NULL) return 0; if (priority != 0) return 0; /* decoration */ if (senator_green(my)) { if (my->count[1] >= 40) color = tenm_map_color(181, 190, 92); else color = tenm_map_color(157, 182, 123); } else { if (my->count[1] >= 40) color = tenm_map_color(200, 164, 92); else color = tenm_map_color(182, 147, 123); } dx = my->count_d[4] - my->x; dy = my->count_d[5] - my->y; length = tenm_sqrt((int) (dx * dx + dy * dy)); if (length < NEAR_ZERO) length = 1.0; if (tenm_draw_circle((int) (my->x + 10.0 * dx / length), (int) (my->y + 10.0 * dy / length), 15, 1, color) != 0) status = 1; /* body */ if (senator_green(my)) { if (my->count[1] >= 40) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 40) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (tenm_draw_circle((int) (my->x), (int) (my->y), 30, 3, color) != 0) status = 1; /* hit point stat */ if (my->count[1] > 0) { sprintf(temp, "%d", my->hit_point); if (draw_string((int) my->x, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "senator_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int senator_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if (my->count[7] == 1) { if (my->count[2] < 2730) return 1; } if (my->count[7] == 3) { if (my->count[2] < 8000) return 1; } return 0; } static int core_signal_second_form(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "Senator") != 0) return 0; my->count[7] = 2; my->count[2] = -1; my->count[4] = -100; my->count_d[0] = 0.0; my->count_d[1] = 0.0; return 0; } static int core_signal_kill_senator(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "Senator") != 0) return 0; /* the explosion should be brown because this is self-destruction */ my->count[7] = 4; senator_explode(my); return 1; } static int senator_signal(tenm_object *my, int n) { int i; /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "net can howl core") != 0) return 0; /* reset attack timer */ my->count[4] = 0; my->count[6] = 0; my->count[7] = 0; /* notify death of senator */ (my->count[9])++; for (i = 0; i < 7; i++) if (my->count[10 + i] == n) my->count[10 + i] = -1; return 0; } /* set result (arg 1) to the position of what (arg 2) * result (arg 1) must be double[2] (you must allocate enough memory * before calling this function) * return 0 on success, 1 on error */ /* list of what * 0: core origin * 1 -- 7: senator * 8: core left hand * 9 -- 14: voter (1st form) * 15 -- 22: voter (2nd form) */ static int net_can_howl_position(double *result, int what, int t_0, int t_1) { double origin_x; double origin_y; double core_x; double core_y; double x; double y; double temp[2]; double temp_r[2]; int theta; int t; /* sanity check */ if (result == NULL) { fprintf(stderr, "net_can_howl_position: result is NULL\n"); return 1; } if ((what < 0) || (what > 22)) { fprintf(stderr, "net_can_howl_position: strange what (%d)\n", what); return 1; } if (t_0 < 0) { fprintf(stderr, "net_can_howl_position: t_0 is negative (%d)\n", t_0); return 1; } if (t_1 < 0) { fprintf(stderr, "net_can_howl_position: t_1 is negative (%d)\n", t_1); return 1; } t = t_1 - t_0; if (t < 0) { fprintf(stderr, "net_can_howl_position: t is negative (%d)\n", t); return 1; } origin_x = (double) (WINDOW_WIDTH / 2); origin_y = (double) (WINDOW_HEIGHT / 2); core_x = (double) (WINDOW_WIDTH / 2); core_y = 19.0; if ((t >= 1100) && (t < 1400)) core_y += (double) (t - 1100); else if ((t >= 1400) && (t < 1700)) core_y += (double) (600 - (t - 1100)); if ((t >= 2900) && (t < 3121)) core_y += (double) (t - 2900); else if ((t >= 3121) && (t < 3700)) core_y += 221.0; else if ((t >= 3700) && (t < 3921)) core_y += (double) (221 - (t - 3700)); if ((t >= 5100) && (t < 5400)) core_y += (double) (t - 5100); else if ((t >= 5400) && (t < 5700)) core_y += (double) (600 - (t - 5100)); if ((t >= 6900) && (t < 7121)) core_y += (double) (t - 6900); else if ((t >= 7121) && (t < 7700)) core_y += 221.0; else if ((t >= 7700) && (t < 7921)) core_y += (double) (221 - (t - 7700)); if (what == 0) { x = core_x; y = core_y; } else if ((what >= 1) && (what <= 6)) { theta = -90 + 60 * (what - 1); if (what % 2 == 0) { theta -= 56; theta += t / 2; } else { theta -= t / 2; } x = core_x + 120.0 * tenm_cos(-150 + what * 60) + 240.0 * tenm_cos(theta); y = core_y + 120.0 * tenm_sin(-150 + what * 60) + 240.0 * tenm_sin(theta); } else if (what == 7) { theta = -90 + t / 2; x = core_x + 90.0 * tenm_cos(theta); y = core_y + 90.0 * tenm_sin(theta); } else if (what == 8) { x = core_x + 30.0; y = core_y; } else if ((what == 9) || (what == 12)) { x = ((double) WINDOW_WIDTH) + 20.0 - ((double) t) * 4.0; y = voter_parabola_formation((double) (WINDOW_WIDTH / 2), (double) (WINDOW_HEIGHT / 3), (double) (WINDOW_WIDTH * 3 / 4), (double) (WINDOW_HEIGHT * 2 / 3), -1.0125, x); if (what == 12) x = ((double) (WINDOW_WIDTH)) - x; } else if ((what == 10) || (what == 13)) { x = -20.0 + ((double) t) * 4.0; y = voter_parabola_formation((double) (WINDOW_WIDTH / 2), (double) (WINDOW_HEIGHT / 3), (double) (WINDOW_WIDTH * 3 / 4), (double) (WINDOW_HEIGHT * 2 / 3), -1.0025, x); if (what == 13) x = ((double) (WINDOW_WIDTH)) - x; } else if ((what == 11) || (what == 14)) { x = -20.0 + ((double) t) * 4.0; y = voter_parabola_formation((double) (WINDOW_WIDTH / 2), (double) (WINDOW_HEIGHT / 3), (double) (WINDOW_WIDTH * 3 / 4), (double) (WINDOW_HEIGHT * 2 / 3), -0.9975, x); if (what == 14) x = ((double) (WINDOW_WIDTH)) - x; } else if ((what == 15) || (what == 16) || (what == 17) || (what == 18)) { if (t < 96) { x = (double) (WINDOW_WIDTH / 2) - 60.0; y = -160.0 - 20.0 + ((double) t) * 5.0; } else if (t < 156) { x = (double) (WINDOW_WIDTH / 2) - 60.0 + ((double) (t - 96)) * 4.0; y = 300.0 - ((double) (t - 96)) * 3.0; } else { x = 500.0; y = 120.0 + ((double) (t - 156)) * 5.0; } if ((what == 17) || (what == 18)) x -= 60.0; if ((what == 16) || (what == 18)) x = ((double) (WINDOW_WIDTH)) - x; } else if ((what >= 19) && (what <= 22)) { x = -420.0 + ((double) t) * 4.0; y = 60.0 - x * x / 240.0; if ((what == 19) || (what == 21)) { theta = 30; } else { x *= -1.0; theta = 180 + 30; } if ((what == 21) || (what == 22)) { x *= -1.0; theta *= -1; } temp[0] = x; temp[1] = y; temp_r[0] = temp[0]; temp_r[1] = temp[1]; vector_rotate(temp_r, temp, theta); x = temp_r[0] + 320.0; y = temp_r[1] + 240.0; } else { fprintf(stderr, "net_can_howl_position: should not reach here\n"); x = 0.0; y = 0.0; } temp[0] = x - origin_x; temp[1] = y - origin_y; temp_r[0] = temp[0]; temp_r[1] = temp[1]; if ((what < 9) || (what > 14)) { if (t_1 > 4200) vector_rotate(temp_r, temp, (t_1 - 4200) / 2); } x = temp_r[0]; y = temp_r[1]; result[0] = origin_x + x; result[1] = origin_y + y; return 0; } static tenm_object * voter_new(int what, int t) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = 0.0; double y = 0.0; double result[2]; result[0] = 0.0; result[1] = 0.0; if ((what >= 9) && (what <= 14)) net_can_howl_position(result, what, 0, 0); else net_can_howl_position(result, what, t, t); x = result[0]; y = result[1]; /* x = ((double) (WINDOW_WIDTH / 2)) + ((double) (WINDOW_WIDTH / 2)) * tenm_cos(-90 + 360 * (what - 1) / 7); y = ((double) (WINDOW_HEIGHT / 4)) + ((double) (WINDOW_HEIGHT / 4)) * tenm_sin(-90 + 360 * (what - 1) / 7); */ p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "voter_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_circle_new(x, y, 20.0); if (p[0] == NULL) { fprintf(stderr, "voter_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 6); if (count == NULL) { fprintf(stderr, "voter_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "voter_new: malloc(count_d) failed\n"); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] move timer * [3] what * [4] shoot timer * [5] t_0 (for net_can_howl_position()) */ count[0] = 0; count[1] = 0; count[2] = -1; count[3] = what; if ((what >= 9) && (what <= 14)) { count[4] = t; count[5] = 0; } else { count[4] = 0; count[5] = t; } /* list of count_d * [0] speed x * [1] speed y */ count_d[0] = 0.0; count_d[1] = 0.0; new = tenm_object_new("Voter", ATTR_ENEMY, ATTR_PLAYER_SHOT, 1, x, y, 6, count, 2, count_d, 1, p, (int (*)(tenm_object *, double)) (&voter_move), (int (*)(tenm_object *, tenm_object *)) (&voter_hit), (int (*)(tenm_object *, const tenm_object *)) (&voter_act), (int (*)(tenm_object *, int)) (&voter_draw)); if (new == NULL) { fprintf(stderr, "voter_new: tenm_object_new failed\n"); free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int voter_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) return 0; if (turn_per_frame <= 0.5) return 0; dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int voter_hit(tenm_object *my, tenm_object *your) { int n; /* sanity check */ if (my == NULL) return 0; if (your == NULL) return 0; if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; deal_damage(my, your, 0); if (voter_green(my)) add_chain(my, your); my->count[1] = 41; if (my->hit_point <= 0) { if (voter_green(my)) n = 8; else n = 7; tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] / 2.0, my->count_d[1]/ 2.0, 2, 20, n, 3.0, 8)); add_score(2); return 1; } return 0; } static int voter_act(tenm_object *my, const tenm_object *player) { double result[2]; /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; /* speed change */ (my->count[2])++; result[0] = 0.0; result[1] = 0.0; net_can_howl_position(result, my->count[3], my->count[5], my->count[5] + my->count[2] + 1); my->count_d[0] = result[0] - my->x; my->count_d[1] = result[1] - my->y; /* escape */ if ((my->count[3] == 9) || (my->count[3] == 12)) { if (my->count[2] > 97) return 1; } else if ((my->count[3] == 10) || (my->count[3] == 13) || (my->count[3] == 11) || (my->count[3] == 14)) { if (my->count[2] > 170) return 1; } else if ((my->count[3] >= 15) && (my->count[3] <= 18)) { if (my->count[2] > 264) return 1; } else if ((my->count[3] >= 19) && (my->count[3] <= 22)) { if (my->count[2] > 210) return 1; } /* shoot */ (my->count[4])++; if ((((my->count[3] == 11) || (my->count[3] == 14)) && (my->count[4] == 120)) || (((my->count[3] >= 15) && (my->count[3] <= 22)) && (my->count[4] % 60 == 0))) tenm_table_add(normal_shot_point_new(my->x, my->y, 4.0, player->x, player->y, 3)); return 0; } static int voter_draw(tenm_object *my, int priority) { tenm_color color; char temp[32]; int status = 0; /* sanity check */ if (my == NULL) return 0; if (priority != 0) return 0; /* body */ if (voter_green(my)) { if (my->count[1] >= 40) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 40) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (tenm_draw_circle((int) (my->x), (int) (my->y), 20, 3, color) != 0) { fprintf(stderr, "voter_draw: tenm_draw_circle failed\n"); status = 1; } if (tenm_draw_line(((int) (my->x)) + 20, (int) (my->y), (int) (my->x), ((int) (my->y) + 20), 3, color) != 0) { fprintf(stderr, "voter_draw: tenm_draw_line failed\n"); status = 1; } /* hit point stat */ if (my->count[1] > 0) { sprintf(temp, "%d", my->hit_point); if (draw_string((int) my->x, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "voter_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int voter_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if (my->count == NULL) return 0; if ((my->count[3] == 9) || (my->count[3] == 12)) { if ((my->count[4] >= 40) && (my->count[4] <= 60)) { return 1; } } else if (((my->count[3] == 10) || (my->count[3] == 11) || (my->count[3] == 13) || (my->count[3] == 14))) { if ((my->count[4] >= 120) && (my->count[4] <= 140)) { return 1; } } else if ((my->count[3] >= 15) && (my->count[3] <= 18)) { if (my->count[2] > 76) return 1; } else if ((my->count[3] >= 19) && (my->count[3] <= 22)) { if (my->count[2] > 75) return 1; } return 0; } /* return y coordinate of the point (x, y) that is on the parabola * that passes (a_1, b_1) and (a_2, b_2) */ static double voter_parabola_formation(double a_1, double b_1, double a_2, double b_2, double s, double x) { double y = 0.0; /* sanity check */ if ((s - (-1.0) > -NEAR_ZERO) && (s - (-1.0) < NEAR_ZERO)) return 0.0; if ((a_1 - a_2 > -NEAR_ZERO) && (a_1 - a_2 < NEAR_ZERO)) return 0.0; y = (s + 1.0) * (x - a_1) * (x - a_2); y += x * (b_2 - b_1) / (a_2 - a_1); y += (a_2 * b_1 - a_1 * b_2) / (a_2 - a_1); return y; } static tenm_object * net_can_howl_more_1_new(void) { tenm_object *new = NULL; int *count = NULL; count = (int *) malloc(sizeof(int) * 3); if (count == NULL) { fprintf(stderr, "net_can_howl_more_1_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] mode * [1] timer * [2] number of ball dead */ count[0] = 0; count[1] = 0; count[2] = 0; /* ATTR_ENEMY is here only to delete it when the boss is dead */ new = tenm_object_new("net can howl more 1", ATTR_ENEMY, 0, 1, 0.0, 0.0, 3, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&net_can_howl_more_1_act), (int (*)(tenm_object *, int)) NULL); if (new == NULL) { fprintf(stderr, "net_can_howl_more_1_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int net_can_howl_more_1_act(tenm_object *my, const tenm_object *player) { int i; int j; double x; double y; double dx; double dy; /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; if (my->count[0] == 0) { if ((my->count[1] >= 80) && (my->count[1] < 140) && (my->count[1] % 5 == 0)) { x = (double) (40 * ((my->count[1] - 70) / 5)); dx = 0.5; for (i = 0; i < 2; i++) { tenm_table_add(normal_enemy_new(x, -19.0, BALL_SOLDIER, 0, 0, my->table_index, 2, -1, 0, 1, 1, /* move 0 */ 1000, dx, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 1000, 1000, 0, 0, 1, 0)); x = ((double) (WINDOW_WIDTH)) - x; dx *= -1.0; } } if ((my->count[1] < 270) && (my->count[2] >= 24)) { my->count[0] = 1; } if (my->count[1] > 350) return 1; } else if (my->count[0] == 1) { if (my->count[1] == 300) { x = -19.0; y = 80.0; dx = 4.0; dy = 2.0; for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) { tenm_table_add(normal_enemy_new(x, y, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 3, /* move 0 */ 1000, dx, dy, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 80, 1000, 0, 0, 0, 1, /* shoot 1 */ 20, 1000, 0, 0, 1, 2, /* shoot 2 */ 1000, 1000, 0, 0, 0, 2)); x = ((double) (WINDOW_WIDTH)) - x; dx *= -1.0; } y = ((double) (WINDOW_HEIGHT)) - y; dy *= -1.0; } } if (my->count[1] == 330) { x = -19.0; y = 80.0; dx = 6.0; dy = 3.0; for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) { tenm_table_add(normal_enemy_new(x, y, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 3, /* move 0 */ 1000, dx, dy, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 50, 1000, 0, 0, 0, 1, /* shoot 1 */ 20, 1000, 0, 0, 1, 2, /* shoot 2 */ 1000, 1000, 0, 0, 0, 2)); x = ((double) (WINDOW_WIDTH)) - x; dx *= -1.0; } y = ((double) (WINDOW_HEIGHT)) - y; dy *= -1.0; } } if (my->count[1] == 345) { x = -19.0; y = 80.0; dx = 8.0; dy = 4.0; for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) { tenm_table_add(normal_enemy_new(x, y, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 3, /* move 0 */ 1000, dx, dy, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 35, 1000, 0, 0, 0, 1, /* shoot 1 */ 20, 1000, 0, 0, 1, 2, /* shoot 2 */ 1000, 1000, 0, 0, 0, 2)); x = ((double) (WINDOW_WIDTH)) - x; dx *= -1.0; } y = ((double) (WINDOW_HEIGHT)) - y; dy *= -1.0; } } if (my->count[1] > 360) return 1; } (my->count[1])++; return 0; } dangen-0.5/spqr/net-can-howl.h0000644000175000017500000000037110276702741017057 0ustar00ooharaoohara00000000000000/* $Id: net-can-howl.h,v 1.11 2003/09/24 02:52:08 oohara Exp $ */ #ifndef __DANGEN_NET_CAN_HOWL_H__ #define __DANGEN_NET_CAN_HOWL_H__ #include "tenm_object.h" tenm_object *net_can_howl_core_new(void); #endif /* not __DANGEN_NET_CAN_HOWL_H__ */ dangen-0.5/spqr/nexus.c0000644000175000017500000012457710276702741015737 0ustar00ooharaoohara00000000000000/* $Id: nexus.c,v 1.132 2005/01/01 16:41:00 oohara Exp $ */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "normal-enemy.h" #include "score.h" #include "warning.h" #include "tadashi.h" #include "nexus.h" static int nexus_move(tenm_object *my, double turn_per_frame); static int nexus_hit(tenm_object *my, tenm_object *your); static int nexus_signal_kill_hatch(tenm_object *my, int n); static int nexus_signal_kill_attacker(tenm_object *my, int n); static int nexus_signal_kill_head(tenm_object *my, int n); static int nexus_act(tenm_object *my, const tenm_object *player); static int nexus_draw(tenm_object *my, int priority); static int nexus_green(const tenm_object *my); static tenm_object *nexus_hatch_new(int what); static int nexus_hatch_move(tenm_object *my, double turn_per_frame); static int nexus_hatch_act(tenm_object *my, const tenm_object *player); static int nexus_hatch_open_time(int what, int side); static int nexus_hatch_draw(tenm_object *my, int priority); static tenm_object *nexus_attacker_new(void); static int nexus_attacker_move(tenm_object *my, double turn_per_frame); static int nexus_attacker_act(tenm_object *my, const tenm_object *player); static int nexus_attacker_draw(tenm_object *my, int priority); static tenm_object *nexus_head_new(void); static int nexus_head_move(tenm_object *my, double turn_per_frame); static int nexus_head_act(tenm_object *my, const tenm_object *player); static int nexus_head_draw(tenm_object *my, int priority); tenm_object * nexus_new(void) { int i; tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = (double) (WINDOW_WIDTH / 2); double y = -29.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "nexus_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 30.0, y - 30.0, x + 30.0, y + 30.0, x - 30.0, y + 30.0, x - 30.0, y - 30.0); if (p[0] == NULL) { fprintf(stderr, "nexus_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 10); if (count == NULL) { fprintf(stderr, "nexus_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 3); if (count_d == NULL) { fprintf(stderr, "nexus_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] life mode * [3] life timer * [4] "was green when killed" flag * [5 -- 7] hatch index * [8] attacker index * [9] head index */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 0; count[4] = 0; for (i = 5; i <= 9; i++) count[i] = -1; count_d[0] = 0.0; count_d[1] = 1.0; new = tenm_object_new("Nexus", ATTR_ENEMY, ATTR_PLAYER_SHOT, 1000, x, y, 10, count, 3, count_d, 1, p, (int (*)(tenm_object *, double)) (&nexus_move), (int (*)(tenm_object *, tenm_object *)) (&nexus_hit), (int (*)(tenm_object *, const tenm_object *)) (&nexus_act), (int (*)(tenm_object *, int)) (&nexus_draw)); if (new == NULL) { fprintf(stderr, "nexus_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int nexus_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "nexus_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "nexus_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int nexus_hit(tenm_object *my, tenm_object *your) { int i; /* sanity check */ if (my == NULL) { fprintf(stderr, "nexus_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "nexus_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if (my->count[2] != 0) return 0; deal_damage(my, your, 0); if (nexus_green(my)) add_chain(my, your); my->count[1] = 41; if (my->hit_point <= 0) { add_score(80); if (nexus_green(my)) i = 8; else i = 7; tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 1, 1000, i, 8.0, 6)); tenm_table_add(fragment_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 30.0, 30, i, 5.0, 0.0, 20)); for (i = 0; i < 3; i++) { if (my->count[5 + i] >= 0) tenm_table_apply(my->count[5 + i], (int (*)(tenm_object *, int)) nexus_signal_kill_hatch, 0); } if (my->count[8] >= 0) tenm_table_apply(my->count[8], (int (*)(tenm_object *, int)) nexus_signal_kill_attacker, 0); if (my->count[9] >= 0) tenm_table_apply(my->count[9], (int (*)(tenm_object *, int)) nexus_signal_kill_head, 0); my->count[2] = 1; my->count[3] = 0; /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ tenm_mass_delete(my->mass); my->mass = NULL; return 0; } return 0; } static int nexus_signal_kill_hatch(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "Nexus hatch") != 0) return 0; tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 1, 1000, 9, 8.0, 6)); tenm_table_add(fragment_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 30.0, 30, 9, 5.0, 0.0, 20)); return 1; } static int nexus_signal_kill_attacker(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "Nexus attacker") != 0) return 0; tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 1, 1000, 9, 8.0, 6)); tenm_table_add(fragment_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 30.0, 30, 9, 5.0, 0.0, 20)); return 1; } static int nexus_signal_kill_head(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "Nexus head") != 0) return 0; tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 1, 1000, 9, 8.0, 6)); tenm_table_add(fragment_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 30.0, 30, 9, 5.0, 0.0, 20)); return 1; } static int nexus_act(tenm_object *my, const tenm_object *player) { int i; int what; int t_shoot; double v[2]; double result[2]; /* sanity check */ if (my == NULL) { fprintf(stderr, "nexus_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; (my->count[3])++; /* add boss */ if (my->count[2] == 1) { if (my->count[3] == 200) tenm_table_add(warning_new()); if (my->count[3] == 330) { tenm_table_add(tadashi_new()); return 1; } return 0; } /* escaped */ if ((my->count[2] == 0) && (my->count[3] >= 2400)) { my->count[2] = 1; my->count[3] = 170; /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ tenm_mass_delete(my->mass); my->mass = NULL; return 0; } if (my->count[3] == 1) { for (i = 0; i < 3; i++) my->count[5 + i] = tenm_table_add(nexus_hatch_new(i)); my->count[8] = tenm_table_add(nexus_attacker_new()); my->count[9] = tenm_table_add(nexus_head_new()); } /* speed change */ if (my->count[3] == 359) my->count_d[1] = -6.0 + 1.0; if (my->count[3] == 409) my->count_d[1] = 1.0; if ((my->count[3] >= 709) && (my->count[3] < 1739)) { switch ((my->count[3] - 709) % 360) { case 0: my->count_d[1] = -6.0 + 1.0; break; case 60: my->count_d[1] = 1.0; break; default: break; } } if (my->count[3] == 1739) my->count_d[1] = -6.0 + 1.0; if (my->count[3] == 1789) my->count_d[1] = 1.0; if (my->count[3] == 1950) my->count_d[1] = 0.5; if (my->count[3] == 2230) my->count_d[1] = 1.0; /* add normal enemy */ if ((my->count[3] >= 10) && (my->count[3] < 42) && ((my->count[3] - 10) % 8 == 0)) { if (my->count[3] == 10) t_shoot = 23; else t_shoot = 9999; tenm_table_add(normal_enemy_new(-19.0, 100.0 + (double) (my->count[3] - 10), BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 3, 2, /* move 0 */ 48, 5.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 31, 0.0, 1.0, 0.0, 0.0, 221.0, 210.0 + (double) (my->count[3] - 10), 0.0, 0.5, 2, /* move 2 */ 9999, -5.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 48, t_shoot, 0, 0, 0, 1, /* shoot 1 */ 9999, t_shoot, 48 % t_shoot, 0, 1, 1)); tenm_table_add(normal_enemy_new(((double) (WINDOW_WIDTH)) + 19.0, 100.0 + (double) (my->count[3] - 10), BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 3, 2, /* move 0 */ 48, -5.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 31, 0.0, 1.0, 0.0, 0.0, ((double) (WINDOW_WIDTH)) - 221.0, 210.0 + (double) (my->count[3] - 10), 0.0, -0.5, 2, /* move 2 */ 9999, 5.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 48, t_shoot, 0, 0, 0, 1, /* shoot 1 */ 9999, t_shoot, 48 % t_shoot, 0, 1, 1)); } if ((my->count[3] >= 850) && (my->count[3] < 914) && ((my->count[3] - 850) % 8 == 0)) { if ((my->count[3] - 850) % 16 == 0) t_shoot = 23; else t_shoot = 9999; tenm_table_add(normal_enemy_new(-19.0, 140.0 + (double) (my->count[3] - 769), BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 5.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 55, t_shoot, 0, 0, 0, 1, /* shoot 1 */ 9999, t_shoot, 55 % t_shoot, 0, 1, 1)); } if ((my->count[3] >= 1000) && (my->count[3] <= 1032) && ((my->count[3] - 1000) % 8 == 0)) { if (my->count[3] == 1000) { what = BRICK; t_shoot = 37; } else { what = BALL_SOLDIER; t_shoot = 9999; } tenm_table_add(normal_enemy_new(32.0, -19.0, what, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 5.0 + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, t_shoot, 0, 0, 1, 0)); } if ((my->count[3] >= 1050) && (my->count[3] <= 1082) && ((my->count[3] - 1050) % 8 == 0)) { if (my->count[3] == 1050) { what = BRICK; t_shoot = 37; } else { what = BALL_SOLDIER; t_shoot = 9999; } tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) - 32.0, -19.0, what, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 5.0 + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, t_shoot, 0, 0, 1, 0)); } if ((my->count[3] >= 1439) && (my->count[3] < 1559) && ((my->count[3] - 1439) % 8 == 0)) { if ((my->count[3] - 1439) % 24 == 0) t_shoot = 31; else t_shoot = 9999; tenm_table_add(normal_enemy_new(-19.0, 140.0 + (double) (my->count[3] - 1489), BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 5.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 70, t_shoot, 0, 0, 0, 1, /* shoot 1 */ 9999, t_shoot, 70 % t_shoot, 0, 1, 1)); } if ((my->count[3] >= 1489) && (my->count[3] < 1609) && ((my->count[3] - 1489) % 8 == 0)) { if ((my->count[3] - 1489) % 24 == 0) t_shoot = 31; else t_shoot = 9999; tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) + 19.0, 20.0 + (double) (my->count[3] - 1489), BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, -5.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 35, t_shoot, 0, 0, 1, 1, /* shoot 1 */ 9999, t_shoot, 35 % t_shoot, 0, 0, 1)); } if ((my->count[3] >= 1870) && (my->count[3] < 1932) && ((my->count[3] - 1870) % 8 == 0)) { if ((my->count[3] - 1870) % 24 == 0) t_shoot = 31; else t_shoot = 9999; tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) + 19.0, 260.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 2, 3, /* move 0 */ 60, -3.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 0 */ 9999, -5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 65, t_shoot, 0, 0, 0, 1, /* shoot 1 */ 40, 9999, 0, 0, 1, 2, /* shoot 2 */ 9999, 9999, 0, 0, 0, 2)); tenm_table_add(normal_enemy_new(-19.0, 260.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 2, 3, /* move 0 */ 60, 3.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 0 */ 9999, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 65, t_shoot, 0, 0, 0, 1, /* shoot 1 */ 40, 9999, 0, 0, 1, 2, /* shoot 2 */ 9999, 9999, 0, 0, 0, 2)); } /* shoot */ if (my->count[3] < 2200) { if (my->count[3] % 130 == 0) { for (i = 0; i < 360; i += 90) { tenm_table_add(laser_angle_new(my->x, my->y, 6.0, 45 + i, 25.0, 2)); tenm_table_add(laser_angle_new(my->x, my->y, 3.5, 45 + i, 25.0, 2)); } for (i = 0; i < 360; i += 180) { tenm_table_add(laser_angle_new(my->x, my->y, 3.0, -25 + i, 25.0, 2)); tenm_table_add(laser_angle_new(my->x, my->y, 3.0, 25 + i, 25.0, 2)); } } if (my->count[3] % 43 == 0) { for (i = -1; i <= 1; i += 2) { v[0] = player->x - my->x; v[1] = player->y - my->y; result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, i * 5); tenm_table_add(laser_point_new(my->x, my->y, 4.5, my->x + result[0], my->y + result[1], 25.0, 1)); } } } return 0; } static int nexus_draw(tenm_object *my, int priority) { int i; double y; int status = 0; tenm_color color; char temp[32]; /* sanity check */ if (my == NULL) { fprintf(stderr, "nexus_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; if (my->count[2] != 0) return 0; /* shaft */ color = tenm_map_color(95, 13, 68); for (i = 0; i < 4; i++) { y = -29.0 + ((double) (my->count[3])) - 210.0 - 360.0 * ((double) i); if (tenm_draw_line((int) (my->x + 30.0), (int) (y), (int) (my->x + 30.0), (int) (y - 180.0), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 30.0), (int) (y), (int) (my->x - 30.0), (int) (y - 180.0), 1, color) != 0) status = 1; } /* body */ if (nexus_green(my)) { if (my->count[1] >= 40) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 40) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (tenm_draw_line((int) (my->x + 30.0), (int) (my->y - 30.0), (int) (my->x + 30.0), (int) (my->y + 30.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 30.0), (int) (my->y + 30.0), (int) (my->x - 30.0), (int) (my->y + 30.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 30.0), (int) (my->y + 30.0), (int) (my->x - 30.0), (int) (my->y - 30.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 30.0), (int) (my->y - 30.0), (int) (my->x + 30.0), (int) (my->y - 30.0), 3, color) != 0) status = 1; /* hit point stat */ if (my->count[1] >= 1) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 10, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "nexus_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int nexus_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if ((my->count[2] == 0) && (my->count[3] >= 359) && (my->count[3] < 2200)) return 1; return 0; } static tenm_object * nexus_hatch_new(int what) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = (double) (WINDOW_WIDTH / 2); double y; /* sanity check */ if ((what < 0) || (what > 2)) { fprintf(stderr, "nexus_hatch_new: strange what (%d)\n", what); return NULL; } y = -28.0 - 120.0 - 360.0 * ((double) what); if (what == 2) y -= 360.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "nexus_hatch_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 90.0, y - 90.0, x + 90.0, y + 90.0, x - 90.0, y + 90.0, x - 90.0, y - 90.0); if (p[0] == NULL) { fprintf(stderr, "nexus_hatch_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 6); if (count == NULL) { fprintf(stderr, "nexus_hatch_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 3); if (count_d == NULL) { fprintf(stderr, "nexus_hatch_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] life timer * [1] what */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = 1; count[1] = what; count_d[0] = 0.0; count_d[1] = 1.0; new = tenm_object_new("Nexus hatch", ATTR_ENEMY, 0, 1, x, y, 6, count, 3, count_d, 1, p, (int (*)(tenm_object *, double)) (&nexus_hatch_move), (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&nexus_hatch_act), (int (*)(tenm_object *, int)) (&nexus_hatch_draw)); if (new == NULL) { fprintf(stderr, "nexus_hatch_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int nexus_hatch_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "nexus_hatch_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "nexus_hatch_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int nexus_hatch_act(tenm_object *my, const tenm_object *player) { int i; int t; double dy; int t_shoot; /* sanity check */ if (my == NULL) { fprintf(stderr, "nexus_hatch_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[0])++; /* escaped */ if (my->count[0] > 2400) return 1; /* speed change */ if (my->count[0] == 1950) my->count_d[1] = 0.5; if (my->count[0] == 2230) my->count_d[1] = 1.0; /* open hatch */ for (i = -1; i <= 1; i += 2) { t = my->count[0] - nexus_hatch_open_time(my->count[1], i); if ((t >= 40) && (t < 72) && ((t - 40) % 8 == 0)) { if (player->y < my->y - 20.0) dy = -5.0; else dy = 5.0; if (t == 40) t_shoot = 23; else t_shoot = 9999; tenm_table_add(normal_enemy_new(my->x + 60.0 * ((double) i), my->y, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 2, 1, /* move 0 */ 40, 5.0 * ((double) i), 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, 0.0, dy + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 9999, t_shoot, 17, 0, 1, 0)); } } return 0; } static int nexus_hatch_open_time(int what, int side) { /* sanity check */ if ((what < 0) || (what > 2)) { fprintf(stderr, "nexus_hatch_open_time: strange what (%d)\n", what); return 0; } if ((side != -1) && (side != 1)) { fprintf(stderr, "nexus_hatch_open_time: strange side (%d)\n", side); return 0; } if (side == -1) { switch (what) { case 0: return 200; break; case 1: return 600; break; case 2: return 1200; break; default: fprintf(stderr, "nexus_hatch_open_time: undefined what (%d)\n", what); return 0; break; } } else { switch (what) { case 0: return 400; break; case 1: return 500; break; case 2: return 1300; break; default: fprintf(stderr, "nexus_hatch_open_time: undefined what (%d)\n", what); return 0; break; } } fprintf(stderr, "nexus_hatch_open_time: fall off\n"); return 0; } static int nexus_hatch_draw(tenm_object *my, int priority) { int i; int t; int theta; double c; int status = 0; tenm_color color; /* sanity check */ if (my == NULL) { fprintf(stderr, "nexus_hatch_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; /* decoration */ color = tenm_map_color(182, 123, 162); if (tenm_draw_line((int) (my->x + 30.0), (int) (my->y - 90.0), (int) (my->x + 30.0), (int) (my->y + 90.0), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 30.0), (int) (my->y - 90.0), (int) (my->x - 30.0), (int) (my->y + 90.0), 1, color) != 0) status = 1; /* hatch */ color = tenm_map_color(95, 13, 68); for (i = -1; i <= 1; i += 2) { if (tenm_draw_circle((int) (my->x + 60.0 * ((double) i)), (int) (my->y), 20, 1, color) != 0) status = 1; t = my->count[0] - nexus_hatch_open_time(my->count[1], i); if (t < 0) theta = -45; else if (t < 30) theta = -45 + t * 3; else theta = 45; if (i == 1) theta = 180 - theta; c = 30.0 * tenm_sqrt(2); if (tenm_draw_line((int) (my->x + 90.0 * ((double) i)), (int) (my->y - 30.0), (int) (my->x + 90.0 * ((double) i) + c * tenm_cos(180 + theta)), (int) (my->y - 30.0 + c * tenm_sin(180 + theta)), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 90.0 * ((double) i)), (int) (my->y + 30.0), (int) (my->x + 90.0 * ((double) i) + c * tenm_cos(180 - theta)), (int) (my->y + 30.0 + c * tenm_sin(180 - theta)), 1, color) != 0) status = 1; } /* body */ if (tenm_draw_line((int) (my->x + 90.0), (int) (my->y - 90.0), (int) (my->x + 90.0), (int) (my->y + 90.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 90.0), (int) (my->y + 90.0), (int) (my->x - 90.0), (int) (my->y + 90.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 90.0), (int) (my->y + 90.0), (int) (my->x - 90.0), (int) (my->y - 90.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 90.0), (int) (my->y - 90.0), (int) (my->x + 90.0), (int) (my->y - 90.0), 3, color) != 0) status = 1; return status; } static tenm_object * nexus_attacker_new(void) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = (double) (WINDOW_WIDTH / 2); double y = -28.0 - 120.0 - 360.0 * 2.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "nexus_attacker_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 90.0, y - 90.0, x + 90.0, y + 90.0, x - 90.0, y + 90.0, x - 90.0, y - 90.0); if (p[0] == NULL) { fprintf(stderr, "nexus_attacker_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 6); if (count == NULL) { fprintf(stderr, "nexus_attacker_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 3); if (count_d == NULL) { fprintf(stderr, "nexus_attacker_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] life timer */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = 1; count_d[0] = 0.0; count_d[1] = 1.0; new = tenm_object_new("Nexus attacker", ATTR_ENEMY, 0, 1, x, y, 6, count, 3, count_d, 1, p, (int (*)(tenm_object *, double)) (&nexus_attacker_move), (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&nexus_attacker_act), (int (*)(tenm_object *, int)) (&nexus_attacker_draw)); if (new == NULL) { fprintf(stderr, "nexus_attacker_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int nexus_attacker_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "nexus_attacker_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "nexus_attacker_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int nexus_attacker_act(tenm_object *my, const tenm_object *player) { int i; int theta; /* sanity check */ if (my == NULL) { fprintf(stderr, "nexus_attacker_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[0])++; /* escaped */ if (my->count[0] > 2400) return 1; /* speed change */ if (my->count[0] == 1950) my->count_d[1] = 0.5; if (my->count[0] == 2230) my->count_d[1] = 1.0; /* shoot */ if (my->count[0] % 37 == 0) { if (my->count[0] % 74 == 0) theta = 10; else theta = -10; for (i = -1; i <= 1; i++) { tenm_table_add(laser_angle_new(my->x - 90.0, my->y + 90.0 * ((double) i), 2.5, 180 + theta, 25.0, 0)); tenm_table_add(laser_angle_new(my->x + 90.0, my->y + 90.0 * ((double) i), 2.5, -theta, 25.0, 0)); } } return 0; } static int nexus_attacker_draw(tenm_object *my, int priority) { int i; int j; int status = 0; tenm_color color; /* sanity check */ if (my == NULL) { fprintf(stderr, "nexus_attacker_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; /* decoration */ color = tenm_map_color(182, 123, 162); for (i = -1; i <= 1; i++) { for (j = -10; j <= 10; j += 20) { if (tenm_draw_line((int) (my->x - 90.0), (int) (my->y + 90.0 * ((double) i)), (int) (my->x - 90.0 + 25.0 * tenm_cos(180 + j)), (int) (my->y + 90.0 * ((double) i) + 25.0 * tenm_sin(180 + j)), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 90.0), (int) (my->y + 90.0 * ((double) i)), (int) (my->x + 90.0 + 25.0 * tenm_cos(j)), (int) (my->y + 90.0 * ((double) i) + 25.0 * tenm_sin(j)), 1, color) != 0) status = 1; } } if (tenm_draw_line((int) (my->x + 40.0), (int) (my->y), (int) (my->x + 80.0), (int) (my->y), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 40.0), (int) (my->y), (int) (my->x - 80.0), (int) (my->y), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 30.0), (int) (my->y - 90.0), (int) (my->x + 30.0), (int) (my->y + 90.0), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 30.0), (int) (my->y - 90.0), (int) (my->x - 30.0), (int) (my->y + 90.0), 1, color) != 0) status = 1; /* body */ color = tenm_map_color(95, 13, 68); if (tenm_draw_line((int) (my->x + 90.0), (int) (my->y - 90.0), (int) (my->x + 90.0), (int) (my->y + 90.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 90.0), (int) (my->y + 90.0), (int) (my->x - 90.0), (int) (my->y + 90.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 90.0), (int) (my->y + 90.0), (int) (my->x - 90.0), (int) (my->y - 90.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 90.0), (int) (my->y - 90.0), (int) (my->x + 90.0), (int) (my->y - 90.0), 3, color) != 0) status = 1; return status; } static tenm_object * nexus_head_new(void) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = (double) (WINDOW_WIDTH / 2); double y = -28.0 - 120.0 - 360.0 * 4.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "nexus_head_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 90.0, y - 90.0, x + 90.0, y + 90.0, x - 90.0, y + 90.0, x - 90.0, y - 90.0); if (p[0] == NULL) { fprintf(stderr, "nexus_head_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 6); if (count == NULL) { fprintf(stderr, "nexus_head_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 3); if (count_d == NULL) { fprintf(stderr, "nexus_head_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] life timer */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = 1; count_d[0] = 0.0; count_d[1] = 1.0; new = tenm_object_new("Nexus head", ATTR_ENEMY, 0, 1, x, y, 6, count, 3, count_d, 1, p, (int (*)(tenm_object *, double)) (&nexus_head_move), (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&nexus_head_act), (int (*)(tenm_object *, int)) (&nexus_head_draw)); if (new == NULL) { fprintf(stderr, "nexus_head_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int nexus_head_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "nexus_head_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "nexus_head_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int nexus_head_act(tenm_object *my, const tenm_object *player) { int i; double v[2]; double result[2]; double a[2]; /* sanity check */ if (my == NULL) { fprintf(stderr, "nexus_head_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[0])++; /* escaped */ if (my->count[0] > 2400) return 1; /* speed change */ if (my->count[0] == 1950) my->count_d[1] = 0.5; if (my->count[0] == 2230) my->count_d[1] = 1.0; /* shoot */ if ((my->count[0] < 2200) && (my->count[0] % 23 == 0)) { v[0] = 0.0; v[1] = -180.0; a[0] = player->x - my->x; a[1] = player->y - my->y; result[0] = v[0]; result[1] = v[1]; vector_rotate_bounded(result, v, a, 20); tenm_table_add(laser_point_new(my->x, my->y, 7.0, my->x + result[0], my->y + result[1], 25.0, 4)); v[0] = result[0]; v[1] = result[1]; for (i = -1; i <= 1; i += 2) { result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, i * 7); tenm_table_add(laser_point_new(my->x, my->y, 5.5, my->x + result[0], my->y + result[1], 25.0, 4)); } } return 0; } static int nexus_head_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; /* sanity check */ if (my == NULL) { fprintf(stderr, "nexus_head_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; /* decoration */ color = tenm_map_color(182, 123, 162); if (tenm_draw_line((int) (my->x), (int) (my->y), (int) (my->x + 180.0 * tenm_cos(-63)), (int) (my->y + 180.0 * tenm_sin(-63)), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x), (int) (my->y), (int) (my->x + 180.0 * tenm_cos(-117)), (int) (my->y + 180.0 * tenm_sin(-117)), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 180.0 * tenm_cos(-63)), (int) (my->y + 180.0 * tenm_sin(-63)), (int) (my->x + 180.0 * tenm_cos(-117)), (int) (my->y + 180.0 * tenm_sin(-117)), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 30.0), (int) (my->y - 90.0), (int) (my->x + 30.0), (int) (my->y + 90.0), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 30.0), (int) (my->y - 90.0), (int) (my->x - 30.0), (int) (my->y + 90.0), 1, color) != 0) status = 1; /* body */ color = tenm_map_color(95, 13, 68); if (tenm_draw_line((int) (my->x + 90.0), (int) (my->y - 90.0), (int) (my->x + 90.0), (int) (my->y + 90.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 90.0), (int) (my->y + 90.0), (int) (my->x - 90.0), (int) (my->y + 90.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 90.0), (int) (my->y + 90.0), (int) (my->x - 90.0), (int) (my->y - 90.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 90.0), (int) (my->y - 90.0), (int) (my->x + 90.0), (int) (my->y - 90.0), 3, color) != 0) status = 1; return status; } dangen-0.5/spqr/nexus.h0000644000175000017500000000031710276702741015725 0ustar00ooharaoohara00000000000000/* $Id: nexus.h,v 1.5 2004/12/23 13:32:08 oohara Exp $ */ #ifndef __DANGEN_NEXUS_H__ #define __DANGEN_NEXUS_H__ #include "tenm_object.h" tenm_object *nexus_new(void); #endif /* not __DANGEN_NEXUS_H__ */ dangen-0.5/spqr/normal-enemy.c0000644000175000017500000010135610276702741017166 0ustar00ooharaoohara00000000000000/* $Id: normal-enemy.c,v 1.183 2005/07/07 05:19:21 oohara Exp $ */ #include /* malloc, rand */ #include /* strlen */ #include /* for normal_enemy_new */ #include #include "tenm_object.h" #include "tenm_primitive.h" #include "const.h" #include "tenm_graphic.h" #include "tenm_table.h" #include "explosion.h" #include "fragment.h" #include "chain.h" #include "score.h" #include "normal-shot.h" #include "util.h" #include "tenm_math.h" #include "laser.h" /* deal_damage */ #include "player-shot.h" #include "normal-enemy.h" #define COUNT_MODE_BEGIN 19 #define COUNT_D_MODE_BEGIN 10 #define MOVE_DATA_SIZE 2 #define MOVE_DATA_SIZE_D 8 #define SHOOT_DATA_SIZE 6 #define SHOOT_DATA_SIZE_D 0 #define NEAR_ZERO 0.0001 static int normal_enemy_hit_point(int what); static int normal_enemy_move(tenm_object *my, double turn_per_frame); static int normal_enemy_hit(tenm_object *my, tenm_object *your); static int normal_enemy_explode(const tenm_object *my, int killed); static void normal_enemy_do_signal(const tenm_object *my, int signal_index, int signal_suffix); static int normal_enemy_signal(tenm_object *my, int n); static int normal_enemy_act(tenm_object *my, const tenm_object *player); static int normal_enemy_draw(tenm_object *my, int priority); /* ... is one or more of * (int t_move, double dx, double dy, double ddx, double ddy, * double center_x, double center_y, double speed_r, double speed_theta, * int next_mode_move) * followed by one or more of * (int t_shoot, int time_shoot, int time_shoot_initial, * int randomness, int green_attack, int next_mode_shoot) * if speed_theta is very large, you may want to use smaller speed_r * to cope with the dr error */ tenm_object * normal_enemy_new(double x, double y, int what, int type, int time_no_escape, int signal_index_killed, int signal_suffix_killed, int signal_index_escaped, int signal_suffix_escaped, int number_mode_move, int number_mode_shoot, ...) { va_list ap; tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; const char *name = NULL; int n_p = 1; int i; int j; int n; int n_d; int attr = ATTR_ENEMY; int hit_mask = ATTR_PLAYER_SHOT; int suffix; int suffix_d; int hit_point = -1; /* for rotate move */ double r_x; double r_y; double r_length; double dr_x; double dr_y; double temp; double r_x_temp; double r_y_temp; double r_length_temp; /* sanity check */ if (time_no_escape < 0) return NULL; if (number_mode_move <= 0) return NULL; if (number_mode_shoot <= 0) return NULL; switch (what) { case BALL_SOLDIER: name = "ball soldier"; break; case BALL_CAPTAIN: name = "ball captain"; break; case BRICK: name = "brick"; break; case SQUARE: name = "square"; break; case TRIANGLE: name = "triangle"; break; default: fprintf(stderr, "normal_enemy_new: strange what when setting name " "(%d)\n", what); return NULL; break; } hit_point = normal_enemy_hit_point(what); if (hit_point < 0) { fprintf(stderr, "normal_enemy_new: normal_enemy_hit_point failed\n"); return NULL; } switch (what) { case BALL_SOLDIER: n_p = 1; break; case BALL_CAPTAIN: n_p = 1; break; case BRICK: n_p = 1; break; case SQUARE: n_p = 1; break; case TRIANGLE: n_p = 1; break; default: fprintf(stderr, "normal_enemy_new: strange what when setting n_p " "(%d)\n", what); return NULL; break; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * n_p); if (p == NULL) { fprintf(stderr, "normal_enemy_new: malloc(p) failed\n"); return NULL; } switch (what) { case BALL_SOLDIER: p[0] = (tenm_primitive *) tenm_circle_new(x, y, 20.0); break; case BALL_CAPTAIN: p[0] = (tenm_primitive *) tenm_circle_new(x, y, 25.0); break; case BRICK: p[0] = (tenm_primitive *) tenm_polygon_new(4, x - 32.0, y - 24.0, x - 32.0, y + 24.0, x + 32.0, y + 24.0, x + 32.0, y - 24.0); break; case SQUARE: p[0] = (tenm_primitive *) tenm_polygon_new(4, x - 25.0, y - 25.0, x - 25.0, y + 25.0, x + 25.0, y + 25.0, x + 25.0, y - 25.0); break; case TRIANGLE: p[0] = (tenm_primitive *) tenm_polygon_new(3, x, y - 43.3, x + 50.0, y + 43.3, x - 50.0, y + 43.3); break; default: fprintf(stderr, "normal_enemy_new: strange what when setting p " "(%d)\n", what); return NULL; break; } for (i = 0; i < n_p; i++) if (p[i] == NULL) { fprintf(stderr, "normal_enemy_new: cannot set p[%d]\n", i); /* we need to check from 0 to n_p to delete everything */ for (j = 0; j < n_p; j++) if (p[j] != NULL) (p[j])->delete(p[j]); free(p); return NULL; } n = COUNT_MODE_BEGIN + MOVE_DATA_SIZE * number_mode_move + SHOOT_DATA_SIZE * number_mode_shoot; count = (int *) malloc(sizeof(int) * n); if (count == NULL) { fprintf(stderr, "normal_enemy_new: malloc(count) failed\n"); for (j = 0; j < n_p; j++) if (p[j] != NULL) (p[j])->delete(p[j]); free(p); return NULL; } n_d = COUNT_D_MODE_BEGIN + MOVE_DATA_SIZE_D * number_mode_move + SHOOT_DATA_SIZE_D * number_mode_shoot; count_d = (double *) malloc(sizeof(double) * n_d); if (count_d == NULL) { fprintf(stderr, "normal_enemy_new: malloc(count_d) failed\n"); free(count); for (j = 0; j < n_p; j++) if (p[j] != NULL) (p[j])->delete(p[j]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] shoot timer (shoot if [1] >= [2]) * [2] shoot interval (fixed in each mode) * [3] no escape time * [4] move mode timer * [5] current mode_move * [6] total number of mode_move * [7] shoot mode timer * [8] current mode_shoot * [9] total number of mode_shoot * [10] shoot randomness * [11] what * [12] type * [13] "killed" signal index (-1 if disabled) * [14] "killed" signal suffix * [15] "escaped" signal index (-1 if disabled) * [16] "escaped" signal suffix * [17] "damaged" flag * [18] green attack flag * [19 --] mode data ((t_move, next_mode_move), (t_shoot, time_shoot, * time_shoot_initial, randomness, next_mode_shoot)) */ /* list of count_d * [0] dx * [1] dy * [2] ddx * [3] ddy * [4] center x * [5] center y * [6] center dx * [7] center dy * [8] speed_r * [9] speed_theta (0.0 means no rotate move) * [10 --] mode data ((dx, dy, ddx, ddy, * center_x, center_y, speed_r, speed_theta), ()) */ va_start(ap, number_mode_shoot); for (i = 0; i < number_mode_move; i++) { suffix = COUNT_MODE_BEGIN + MOVE_DATA_SIZE * i; suffix_d = COUNT_D_MODE_BEGIN + MOVE_DATA_SIZE_D * i; /* t_move */ count[suffix + 0] = va_arg(ap, int); if (count[suffix + 0] <= 0) { fprintf(stderr, "normal_enemy_new: strange t_move (%d) in mode %d\n", count[suffix + 0], i); free(count_d); free(count); for (j = 0; j < n_p; j++) if (p[j] != NULL) (p[j])->delete(p[j]); free(p); va_end(ap); return NULL; } /* dx */ count_d[suffix_d + 0] = va_arg(ap, double); /* dy */ count_d[suffix_d + 1] = va_arg(ap, double); /* ddx */ count_d[suffix_d + 2] = va_arg(ap, double); /* ddy */ count_d[suffix_d + 3] = va_arg(ap, double); /* center_x */ count_d[suffix_d + 4] = va_arg(ap, double); /* center_y */ count_d[suffix_d + 5] = va_arg(ap, double); /* speed_r */ count_d[suffix_d + 6] = va_arg(ap, double); /* speed_theta * negative speed_theta is OK --- it means counterclockwise */ count_d[suffix_d + 7] = va_arg(ap, double); /* next_mode_move */ count[suffix + 1] = va_arg(ap, int); } for (i = 0; i < number_mode_shoot; i++) { suffix = COUNT_MODE_BEGIN + MOVE_DATA_SIZE * number_mode_move + SHOOT_DATA_SIZE * i; /* there is no double data for shoot mode */ /* t_shoot */ count[suffix + 0] = va_arg(ap, int); if (count[suffix + 0] <= 0) { fprintf(stderr, "normal_enemy_new: strange t_shoot (%d) in mode %d\n", count[suffix + 0], i); free(count_d); free(count); for (j = 0; j < n_p; j++) if (p[j] != NULL) (p[j])->delete(p[j]); free(p); va_end(ap); return NULL; } /* time_shoot */ count[suffix + 1] = va_arg(ap, int); if (count[suffix + 1] <= 0) { fprintf(stderr, "normal_enemy_new: strange time_shoot (%d) in mode %d\n", count[suffix + 1], i); free(count_d); free(count); for (j = 0; j < n_p; j++) if (p[j] != NULL) (p[j])->delete(p[j]); free(p); va_end(ap); return NULL; } /* time_shoot_initial * negative time_shoot_initial is OK --- it means additional wait * before the first shoot */ count[suffix + 2] = va_arg(ap, int); /* randomness */ count[suffix + 3] = va_arg(ap, int); if (count[suffix + 3] < 0) { fprintf(stderr, "normal_enemy_new: strange randomness (%d) in mode %d\n", count[suffix + 3], i); free(count_d); free(count); for (j = 0; j < n_p; j++) if (p[j] != NULL) (p[j])->delete(p[j]); free(p); va_end(ap); return NULL; } /* green_attack */ count[suffix + 4] = va_arg(ap, int); /* next_mode_shoot */ count[suffix + 5] = va_arg(ap, int); } va_end(ap); count[0] = 0; count[1] = count[COUNT_MODE_BEGIN + MOVE_DATA_SIZE * number_mode_move + 2]; count[2] = count[COUNT_MODE_BEGIN + MOVE_DATA_SIZE * number_mode_move + 1]; count[3] = time_no_escape; count[4] = count[COUNT_MODE_BEGIN + 0]; count[5] = 0; count[6] = number_mode_move; count[7] = count[COUNT_MODE_BEGIN + MOVE_DATA_SIZE * number_mode_move + 0]; count[8] = 0; count[9] = number_mode_shoot; count[10] = count[COUNT_MODE_BEGIN + MOVE_DATA_SIZE * number_mode_move + 3]; count[11] = what; count[12] = type; count[13] = signal_index_killed; count[14] = signal_suffix_killed; count[15] = signal_index_escaped; count[16] = signal_suffix_escaped; count[17] = 0; count[18] = count[COUNT_MODE_BEGIN + MOVE_DATA_SIZE * number_mode_move + 4]; /* count_d[0] and count_d[1] are set below */ count_d[2] = count_d[COUNT_D_MODE_BEGIN + 2]; count_d[3] = count_d[COUNT_D_MODE_BEGIN + 3]; count_d[4] = count_d[COUNT_D_MODE_BEGIN + 4]; count_d[5] = count_d[COUNT_D_MODE_BEGIN + 5]; count_d[6] = count_d[COUNT_D_MODE_BEGIN + 0]; count_d[7] = count_d[COUNT_D_MODE_BEGIN + 1]; count_d[8] = count_d[COUNT_D_MODE_BEGIN + 6]; count_d[9] = count_d[COUNT_D_MODE_BEGIN + 7]; if ((count_d[9] >= -0.01) && (count_d[9] <= 0.01)) { /* no rotate */ count_d[0] = count_d[6]; count_d[1] = count_d[7]; } else { r_x = x - count_d[4]; r_y = y - count_d[5]; r_length = tenm_sqrt((int) (r_x * r_x + r_y * r_y)); if (r_length < NEAR_ZERO) r_length = 1.0; r_x /= r_length; r_y /= r_length; dr_x = -r_y; dr_y = r_x; temp = r_length / 5.0; /* dr should not modify the radius */ r_x_temp = x + count_d[9] * dr_x * temp - count_d[4]; r_y_temp = y + count_d[9] * dr_y * temp - count_d[5]; r_length_temp = tenm_sqrt((int) (r_x_temp * r_x_temp + r_y_temp * r_y_temp)); if (r_length_temp < NEAR_ZERO) r_length_temp = 1.0; count_d[8] -= r_length_temp - r_length; count_d[0] = count_d[6] + count_d[8] * r_x + count_d[9] * dr_x * temp; count_d[1] = count_d[7] + count_d[8] * r_y + count_d[9] * dr_y * temp; } attr = ATTR_ENEMY; if (type & ENEMY_TYPE_OBSTACLE) attr |= ATTR_OBSTACLE; hit_mask = ATTR_PLAYER_SHOT; if (type & ENEMY_TYPE_WEAK) hit_mask |= ATTR_OBSTACLE; new = tenm_object_new(name, attr, hit_mask, hit_point, x, y, n, count, n_d, count_d, n_p, p, (int (*)(tenm_object *, double)) (&normal_enemy_move), (int (*)(tenm_object *, tenm_object *)) (&normal_enemy_hit), (int (*)(tenm_object *, const tenm_object *)) (&normal_enemy_act), (int (*)(tenm_object *, int)) (&normal_enemy_draw)); if (new == NULL) { fprintf(stderr, "normal_enemy_new: tenm_object_new failed\n"); free(count_d); free(count); for (j = 0; j < n_p; j++) if (p[j] != NULL) (p[j])->delete(p[j]); free(p); return NULL; } return new; } /* return positive value on success, negative value on error */ static int normal_enemy_hit_point(int what) { switch (what) { case BALL_SOLDIER: return 1; break; case BALL_CAPTAIN: return 20; break; case BRICK: return 25; break; case SQUARE: return 25; break; case TRIANGLE: return 130; break; default: fprintf(stderr, "normal_enemy_hit_point: strange what (%d)\n", what); return -1; break; } /* should not reach here */ fprintf(stderr, "normal_enemy_hit_point: switch(what) fell off\n"); return -1; } static int normal_enemy_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) return 0; if (turn_per_frame <= 0.5) return 0; dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; tenm_move_mass(my->mass, dx_temp, dy_temp); if ((my->count[3] <= 0) && (!in_window_object(my))) { /* escaped */ normal_enemy_do_signal(my, my->count[15], my->count[16]); return 1; } return 0; } static int normal_enemy_hit(tenm_object *my, tenm_object *your) { int score = 0; int hit_point; /* sanity check */ if (my == NULL) return 0; if (your == NULL) return 0; if (your->attr & ATTR_OBSTACLE) { normal_enemy_explode(my, 0); /* count as "escaped "*/ normal_enemy_do_signal(my, my->count[15], my->count[16]); return 1; } /* if the enemy has no time_no_escape, we don't need to check * in_window_object() again because it is done in the last move */ if ((my->count[3] > 0) && (!in_window_object(my))) return 0; if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; hit_point = normal_enemy_hit_point(my->count[11]); if (hit_point < 0) { fprintf(stderr, "normal_enemy_hit: normal_enemy_hit_point failed\n"); return 0; } switch (my->count[11]) { case BALL_SOLDIER: score = 2; break; case BALL_CAPTAIN: score = 3; break; case BRICK: score = 5; break; case SQUARE: score = 7; break; case TRIANGLE: score = 13; break; default: fprintf(stderr, "normal_enemy_explode: strange what when setting score " "(%d)\n", my->count[11]); score = 0; break; } deal_damage(my, your, 0); if (my->count[18] != 0) add_chain(my, your); my->count[17] = 41; if (my->hit_point <= 0) { normal_enemy_explode(my, 1); add_score(score); /* "killed" */ normal_enemy_do_signal(my, my->count[13], my->count[14]); return 1; } return 0; } static int normal_enemy_explode(const tenm_object *my, int killed) { int n; /* sanity check */ if (my == NULL) return 0; if (my->count[18] != 0) n = 8; else n = 7; if (!killed) n = 7; switch (my->count[11]) { case BALL_SOLDIER: tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] / 2.0, my->count_d[1]/ 2.0, 2, 20, n, 3.0, 8)); break; case BALL_CAPTAIN: tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] / 2.0, my->count_d[1]/ 2.0, 2, 30, n, 4.0, 8)); break; case BRICK: tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] / 2.0, my->count_d[1]/ 2.0, 1, 20, n, 3.0, 8)); tenm_table_add(fragment_new(my->x, my->y, my->count_d[0] / 2.0, my->count_d[1] / 2.0, 20.0, 10, n, 3.0, 0.0, 8)); break; case SQUARE: tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] / 2.0, my->count_d[1]/ 2.0, 1, 20, n, 3.0, 8)); tenm_table_add(fragment_new(my->x, my->y, my->count_d[0] / 2.0, my->count_d[1] / 2.0, 20.0, 10, n, 3.0, 0.0, 8)); break; case TRIANGLE: tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] / 2.0, my->count_d[1]/ 2.0, 1, 200, n, 5.0, 8)); tenm_table_add(fragment_new(my->x, my->y, my->count_d[0] / 2.0, my->count_d[1] / 2.0, 20.0, 20, n, 4.0, 0.0, 8)); break; default: fprintf(stderr, "normal_enemy_explode: strange what when setting p " "(%d)\n", my->count[11]); return 1; break; } return 0; } static void normal_enemy_do_signal(const tenm_object *my, int signal_index, int signal_suffix) { /* sanity check */ if (my == NULL) return; if (signal_index < 0) return; if (signal_suffix < 0) return; tenm_table_apply(signal_index, (int (*)(tenm_object *, int)) (&normal_enemy_signal), signal_suffix); } static int normal_enemy_signal(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if ((n < 0) || (n >= my->n)) return 0; (my->count[n])++; return 0; } static int normal_enemy_act(tenm_object *my, const tenm_object *player) { double x_temp; double y_temp; int suffix; int suffix_d; int next_mode; /* for rotate move */ double r_x; double r_y; double r_length; double dr_x; double dr_y; double temp; double r_x_temp; double r_y_temp; double r_length_temp; /* for "square" attack */ double result[2]; double v[2]; double a[2]; /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* no escape time count down */ if (my->count[3] > 0) (my->count[3])--; /* hit point stat count down */ if (my->count[17] > 0) (my->count[17])--; /* speed change */ my->count_d[6] += my->count_d[2]; my->count_d[7] += my->count_d[3]; /* rotate center move */ my->count_d[4] += my->count_d[6]; my->count_d[5] += my->count_d[7]; /* rotate move */ if ((my->count_d[9] >= -0.01) && (my->count_d[9] <= 0.01)) { /* no rotate */ my->count_d[0] = my->count_d[6]; my->count_d[1] = my->count_d[7]; } else { r_x = my->x - my->count_d[4]; r_y = my->y - my->count_d[5]; r_length = tenm_sqrt((int) (r_x * r_x + r_y * r_y)); if (r_length < NEAR_ZERO) r_length = 1.0; r_x /= r_length; r_y /= r_length; dr_x = -r_y; dr_y = r_x; /* note that my->count_d[8] is already adjusted so that * dr does not change the radius */ temp = r_length / 5.0; my->count_d[0] = my->count_d[6] + my->count_d[8] * r_x + my->count_d[9] * dr_x * temp; my->count_d[1] = my->count_d[7] + my->count_d[8] * r_y + my->count_d[9] * dr_y * temp; } /* shoot */ (my->count[1])++; if (my->count[1] >= my->count[2]) { my->count[1] = 0; if (my->count[10] <= 0) { x_temp = 0.0; y_temp = 0.0; } else { x_temp = (double) ((rand() % (my->count[10] * 2 + 1)) - my->count[10]); y_temp = (double) ((rand() % (my->count[10] * 2 + 1)) - my->count[10]); } switch (my->count[11]) { case BALL_SOLDIER: /* fall off */ case BALL_CAPTAIN: tenm_table_add(normal_shot_point_new(my->x, my->y, 4.0, player->x + x_temp, player->y + y_temp, 3)); break; case BRICK: tenm_table_add(normal_shot_point_new(my->x - 24.0, my->y, 5.5, player->x + x_temp, player->y + y_temp, 3)); tenm_table_add(normal_shot_point_new(my->x + 24.0, my->y, 5.5, player->x + x_temp, player->y + y_temp, 3)); break; case SQUARE: v[0] = 50.0 * tenm_cos(my->count[10]); v[1] = 50.0 * tenm_sin(my->count[10]); a[0] = player->x - my->x; a[1] = player->y - my->y; result[0] = v[0]; result[1] = v[1]; vector_rotate_bounded(result, v, a, 20); tenm_table_add(laser_point_new(my->x, my->y, 5.5, my->x + result[0], my->y + result[1], 25.0, 3)); break; case TRIANGLE: tenm_table_add(laser_point_new(my->x + 25.0, my->y + 10.0, 5.0, my->x + 25.0 - 12.0, my->y + 10.0 + 5.0, 25.0, 3)); tenm_table_add(laser_point_new(my->x + 25.0, my->y + 10.0, 5.0, my->x + 25.0 + 5.0, my->y + 10.0 + 12.0, 25.0, 3)); tenm_table_add(laser_point_new(my->x - 25.0, my->y + 10.0, 5.0, my->x - 25.0 + 12.0, my->y + 10.0 + 5.0, 25.0, 3)); tenm_table_add(laser_point_new(my->x - 25.0, my->y + 10.0, 5.0, my->x - 25.0 - 5.0, my->y + 10.0 + 12.0, 25.0, 3)); tenm_table_add(laser_angle_new(my->x, my->y, 4.0, 45, 25.0, 3)); tenm_table_add(laser_angle_new(my->x, my->y, 4.0, 135, 25.0, 3)); tenm_table_add(laser_angle_new(my->x, my->y, 4.0, 85, 25.0, 3)); tenm_table_add(laser_angle_new(my->x, my->y, 4.0, 95, 25.0, 3)); tenm_table_add(normal_shot_point_new(my->x, my->y - 15.0, 3.0, player->x + x_temp, player->y + y_temp, 3)); tenm_table_add(normal_shot_point_new(my->x, my->y - 15.0, 6.0, player->x + x_temp, player->y + y_temp, 3)); break; default: fprintf(stderr, "normal_enemy_act: strange what when shooting " "(%d)\n", my->count[11]); return 0; break; } } /* move mode change */ (my->count[4])--; if (my->count[4] <= 0) { next_mode = my->count[COUNT_MODE_BEGIN + MOVE_DATA_SIZE * my->count[5] + 1]; if ((next_mode < 0) || (next_mode >= my->count[6])) { /* strange mode, die */ fprintf(stderr, "normal_enemy_act: strange move mode (%d)\n", next_mode); /* count as "escaped" */ normal_enemy_do_signal(my, my->count[15], my->count[16]); return 1; } suffix = COUNT_MODE_BEGIN + MOVE_DATA_SIZE * next_mode; suffix_d = COUNT_D_MODE_BEGIN + MOVE_DATA_SIZE_D * next_mode; my->count[4] = my->count[suffix + 0]; my->count[5] = next_mode; /* my->count_d[0] and my->count_d[0] are set below * to handle rotation correctly */ my->count_d[2] = my->count_d[suffix_d + 2]; my->count_d[3] = my->count_d[suffix_d + 3]; my->count_d[4] = my->count_d[suffix_d + 4]; my->count_d[5] = my->count_d[suffix_d + 5]; my->count_d[6] = my->count_d[suffix_d + 0]; my->count_d[7] = my->count_d[suffix_d + 1]; my->count_d[8] = my->count_d[suffix_d + 6]; my->count_d[9] = my->count_d[suffix_d + 7]; if ((my->count_d[9] >= -0.01) && (my->count_d[9] <= 0.01)) { /* no rotate */ my->count_d[0] = my->count_d[6]; my->count_d[1] = my->count_d[7]; } else { r_x = my->x - my->count_d[4]; r_y = my->y - my->count_d[5]; r_length = tenm_sqrt((int) (r_x * r_x + r_y * r_y)); if (r_length < NEAR_ZERO) r_length = 1.0; r_x /= r_length; r_y /= r_length; dr_x = -r_y; dr_y = r_x; temp = r_length / 5.0; /* dr should not modify the radius */ r_x_temp = my->x + my->count_d[9] * dr_x * temp - my->count_d[4]; r_y_temp = my->y + my->count_d[9] * dr_y * temp - my->count_d[5]; r_length_temp = tenm_sqrt((int) (r_x_temp * r_x_temp + r_y_temp * r_y_temp)); if (r_length_temp < NEAR_ZERO) r_length_temp = 1.0; my->count_d[8] -= r_length_temp - r_length; my->count_d[0] = my->count_d[6] + my->count_d[8] * r_x + my->count_d[9] * dr_x * temp; my->count_d[1] = my->count_d[7] + my->count_d[8] * r_y + my->count_d[9] * dr_y * temp; } } /* shoot mode change */ (my->count[7])--; if (my->count[7] <= 0) { next_mode = my->count[COUNT_MODE_BEGIN + MOVE_DATA_SIZE * my->count[6] + SHOOT_DATA_SIZE * my->count[8] + 5]; if ((next_mode < 0) || (next_mode >= my->count[9])) { fprintf(stderr, "normal_enemy_act: strange shoot mode (%d)\n", next_mode); /* count as "escaped" */ normal_enemy_do_signal(my, my->count[15], my->count[16]); return 1; } suffix = COUNT_MODE_BEGIN + MOVE_DATA_SIZE * my->count[6] + SHOOT_DATA_SIZE * next_mode; my->count[1] = my->count[suffix + 2]; my->count[2] = my->count[suffix + 1]; my->count[7] = my->count[suffix + 0]; my->count[8] = next_mode; my->count[10] = my->count[suffix + 3]; my->count[18] = my->count[suffix + 4]; } return 0; } static int normal_enemy_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; /* sanity check */ if (my == NULL) return 0; if (priority != 0) return 0; /* decoration */ if (my->count[18] != 0) { if (my->count[17] >= 40) color = tenm_map_color(181, 190, 92); else color = tenm_map_color(157, 182, 123); } else { if (my->count[17] >= 40) color = tenm_map_color(200, 164, 92); else color = tenm_map_color(182, 147, 123); } switch (my->count[11]) { case BALL_SOLDIER: break; case BALL_CAPTAIN: break; case BRICK: break; case SQUARE: if (tenm_draw_line((int) (my->x), (int) (my->y), (int) (my->x + 50.0 * tenm_cos(my->count[10] - 20)), (int) (my->y + 50.0 * tenm_sin(my->count[10] - 20)), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x), (int) (my->y), (int) (my->x + 50.0 * tenm_cos(my->count[10] + 20)), (int) (my->y + 50.0 * tenm_sin(my->count[10] + 20)), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 50.0 * tenm_cos(my->count[10] + 20)), (int) (my->y + 50.0 * tenm_sin(my->count[10] + 20)), (int) (my->x + 50.0 * tenm_cos(my->count[10] - 20)), (int) (my->y + 50.0 * tenm_sin(my->count[10] - 20)), 1, color) != 0) status = 1; break; case TRIANGLE: break; default: fprintf(stderr, "normal_enemy_draw: strange what " "(%d)\n", my->count[11]); return 1; break; } /* body */ if (my->count[18] != 0) { if (my->count[17] >= 40) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[17] >= 40) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } switch (my->count[11]) { case BALL_SOLDIER: if (tenm_draw_circle((int) (my->x), (int) (my->y), 20, 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x)) + 20, (int) (my->y), (int) (my->x), ((int) (my->y) + 20), 3, color) != 0) status = 1; break; case BALL_CAPTAIN: if (tenm_draw_circle((int) (my->x), (int) (my->y), 25, 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x)) + 25, (int) (my->y), (int) (my->x), ((int) (my->y) + 25), 3, color) != 0) status = 1; break; case BRICK: if (tenm_draw_line((int) (my->x), (int) (my->y), (int) (my->x - 32.0), (int) (my->y + 24.0), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x), (int) (my->y), (int) (my->x + 32.0), (int) (my->y + 24.0), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 32.0), (int) (my->y - 24.0), (int) (my->x - 32.0), (int) (my->y + 24.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 32.0), (int) (my->y + 24.0), (int) (my->x + 32.0), (int) (my->y + 24.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 32.0), (int) (my->y + 24.0), (int) (my->x + 32.0), (int) (my->y - 24.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 32.0), (int) (my->y - 24.0), (int) (my->x - 32.0), (int) (my->y - 24.0), 3, color) != 0) status = 1; break; case SQUARE: if (tenm_draw_line((int) (my->x - 25.0), (int) (my->y - 25.0), (int) (my->x - 25.0), (int) (my->y + 25.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 25.0), (int) (my->y + 25.0), (int) (my->x + 25.0), (int) (my->y + 25.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 25.0), (int) (my->y + 25.0), (int) (my->x + 25.0), (int) (my->y - 25.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 25.0), (int) (my->y - 25.0), (int) (my->x - 25.0), (int) (my->y - 25.0), 3, color) != 0) status = 1; break; case TRIANGLE: if (tenm_draw_line((int) (my->x), (int) (my->y), (int) (my->x + 25.0), (int) (my->y + 43.3), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x), (int) (my->y), (int) (my->x - 25.0), (int) (my->y + 43.3), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x), (int) (my->y - 43.3), (int) (my->x + 50.0), (int) (my->y + 43.3), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 50.0), (int) (my->y + 43.3), (int) (my->x - 50.0), (int) (my->y + 43.3), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 50.0), (int) (my->y + 43.3), (int) (my->x), (int) (my->y - 43.3), 3, color) != 0) status = 1; break; default: fprintf(stderr, "normal_enemy_draw: strange what " "(%d)\n", my->count[11]); return 1; break; } if (my->count[17] > 0) { sprintf(temp, "%d", my->hit_point); if (draw_string((int) my->x, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "normal_enemy_draw: draw_string failed\n"); status = 1; } } return status; /* the below may be useful for debugging */ color = tenm_map_color(0, 0, 0); if (tenm_draw_mass(my->mass, color) != 0) { fprintf(stderr, "normal_enemy_draw: tenm_draw_mass failed\n"); return 1; } return 0; } dangen-0.5/spqr/normal-enemy.h0000644000175000017500000000165510276702741017174 0ustar00ooharaoohara00000000000000/* $Id: normal-enemy.h,v 1.23 2004/12/01 13:33:32 oohara Exp $ */ #ifndef __DANGEN_NORMAL_ENEMY_H__ #define __DANGEN_NORMAL_ENEMY_H__ /* what */ #define BALL_SOLDIER 1 #define BALL_CAPTAIN 2 #define BRICK 3 #define SQUARE 4 #define TRIANGLE 5 /* type * these values must be one of 2^n */ /* gets hit by ATTR_OBSTACLE */ #define ENEMY_TYPE_WEAK 1 /* counts as ATTR_OBSTACLE as well as ATTR_ENEMY */ #define ENEMY_TYPE_OBSTACLE 2 tenm_object * normal_enemy_new(double x, double y, int what, int type, int time_no_escape, int signal_index_killed, int signal_suffix_killed, int signal_index_escaped, int signal_suffix_escaped, int number_mode_move, int number_mode_shoot, ...); #endif /* not __DANGEN_NORMAL_ENEMY_H__ */ dangen-0.5/spqr/normal-shot.c0000644000175000017500000001612210276702741017022 0ustar00ooharaoohara00000000000000/* $Id: normal-shot.c,v 1.42 2005/06/25 03:44:39 oohara Exp $ */ #include /* malloc, rand */ #include #include "const.h" #include "tenm_object.h" #include "tenm_math.h" #include "tenm_graphic.h" #include "util.h" #include "tenm_primitive.h" #include "normal-shot.h" #define NEAR_ZERO 0.0001 static int normal_shot_move(tenm_object *my, double turn_per_frame); static int normal_shot_hit(tenm_object *my, tenm_object *your); static int normal_shot_act(tenm_object *my, const tenm_object *player); static int normal_shot_draw(tenm_object *my, int priority); /* speed must be positive --- use normal_shot_new() instead if you want * a shot that doesn't move */ tenm_object * normal_shot_angle_new(double x, double y, double speed, int theta, int color) { /* sanity check */ if (speed < NEAR_ZERO) { fprintf(stderr, "normal_shot_angle_new: speed is non-positive (%f)\n", speed); return NULL; } return normal_shot_new(x, y, speed * tenm_cos(theta), speed * tenm_sin(theta), color, -2, 0); } /* speed must be positive --- use normal_shot_new() instead if you want * a shot that doesn't move * if (x, y) and (target_x, target_y) are very close, shoot at a random * direction */ tenm_object * normal_shot_point_new(double x, double y, double speed, double target_x, double target_y, int color) { double dx; double dy; double temp; int temp_theta; /* sanity check */ if (speed < NEAR_ZERO) { fprintf(stderr, "normal_shot_point_new: speed is non-positive (%f)", speed); return NULL; } dx = target_x - x; dy = target_y - y; temp = tenm_sqrt((int) (dx * dx + dy * dy)); if (temp <= NEAR_ZERO) { /* shoot at a random direction */ temp_theta = rand() % 360; dx = tenm_cos(temp_theta); dy = tenm_sin(temp_theta); temp = 1.0; } return normal_shot_new(x, y, speed * dx / temp, speed * dy / temp, color, -2, 0); } /* list of count * [0] color * [1] life * [2] immortal time */ /* list of count_d * [0] speed x * [1] speed y */ /* if life > 0 when created, the shot disappears after _life frames * when immortal > 0, the shot does not disappear even if * it is out of the window */ tenm_object * normal_shot_new(double x, double y, double speed_x, double speed_y, int color, int life, int immortal_time) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; /* sanity check */ if (life == 0) { fprintf(stderr, "normal_shot_new: life is 0\n"); return NULL; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "normal_shot_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_circle_new(x, y, 5.0); if (p[0] == NULL) { fprintf(stderr, "normal_shot_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 3); if (count == NULL) { fprintf(stderr, "normal_shot_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "normal_shot_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } count[0] = color; count[1] = life; count[2] = immortal_time; count_d[0] = speed_x; count_d[1] = speed_y; new = tenm_object_new("normal shot", ATTR_ENEMY_SHOT, ATTR_OPAQUE, 1, x, y, 3, count, 2, count_d, 1, p, (int (*)(tenm_object *, double)) (&normal_shot_move), (int (*)(tenm_object *, tenm_object *)) (&normal_shot_hit), (int (*)(tenm_object *, const tenm_object *)) (&normal_shot_act), (int (*)(tenm_object *, int)) (&normal_shot_draw)); if (new == NULL) { fprintf(stderr, "normal_shot_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int normal_shot_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "normal_shot_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "normal_shot_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; tenm_move_mass(my->mass, dx_temp, dy_temp); if ((my->count[2] <= 0) && (!in_window_object(my))) return 1; return 0; } static int normal_shot_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "normal_shot_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "normal_shot_hit: your is NULL\n"); return 0; } if (your->attr & ATTR_OPAQUE) return 1; return 0; } static int normal_shot_act(tenm_object *my, const tenm_object *player) { /* sanity check */ if (my == NULL) { fprintf(stderr, "normal_shot_act: my is NULL\n"); return 0; } /* player == NULL is OK */ if (my->count[1] > 0) { (my->count[1])--; if (my->count[1] <= 0) return 1; } if (my->count[2] > 0) (my->count[2])--; return 0; } static int normal_shot_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; /* sanity check */ if (my == NULL) { fprintf(stderr, "normal_shot_draw: my is NULL\n"); return 0; } /* return if it is not my turn */ if (priority != 1) return 0; /* value * green (#0, #1): 75 * blue (#2, #3): 87 * purple (#4, #5): 94 */ switch (my->count[0]) { case 0: color = tenm_map_color(49, 191, 0); color = tenm_map_color(0, 223, 55); color = tenm_map_color(0, 191, 47); break; case 1: color = tenm_map_color(0, 223, 55); color = tenm_map_color(0, 191, 127); break; case 2: color = tenm_map_color(0, 191, 255); color = tenm_map_color(0, 167, 223); break; case 3: color = tenm_map_color(0, 127, 255); color = tenm_map_color(0, 111, 223); break; case 4: color = tenm_map_color(70, 0, 223); color = tenm_map_color(75, 0, 239); break; case 5: color = tenm_map_color(163, 0, 223); color = tenm_map_color(175, 0, 239); break; default: fprintf(stderr, "normal_shot_draw: strange my->count[0] (%d)\n", my->count[0]); color = tenm_map_color(0, 0, 0); break; } if (tenm_draw_circle((int) (my->x), (int) (my->y), 5, 2, color) != 0) status = 1; /* maybe useful for debugging */ /* if (tenm_draw_primitive(my->mass->p[0], color) != 0) status = 1; */ return status; } dangen-0.5/spqr/normal-shot.h0000644000175000017500000000125110276702741017024 0ustar00ooharaoohara00000000000000/* $Id: normal-shot.h,v 1.7 2004/07/06 02:50:33 oohara Exp $ */ #ifndef __DANGEN_NORMAL_SHOT_H__ #define __DANGEN_NORMAL_SHOT_H__ #include "tenm_object.h" tenm_object *normal_shot_angle_new(double x, double y, double speed, int theta, int color); tenm_object *normal_shot_point_new(double x, double y, double speed, double target_x, double target_y, int color); tenm_object *normal_shot_new(double x, double y, double speed_x, double speed_y, int color, int life, int immortal_time); #endif /* not __DANGEN_NORMAL_SHOT_H__ */ dangen-0.5/spqr/p-can.c0000644000175000017500000003357511625005030015552 0ustar00ooharaoohara00000000000000/* $Id: p-can.c,v 1.37 2011/08/23 20:14:16 oohara Exp $ */ /* [easiest] P-can */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "stage-clear.h" #include "score.h" #include "p-can.h" static int p_can_move(tenm_object *my, double turn_per_frame); static int p_can_hit(tenm_object *my, tenm_object *your); static void p_can_next(tenm_object *my); static int p_can_act(tenm_object *my, const tenm_object *player); static int p_can_draw(tenm_object *my, int priority); static int p_can_green(const tenm_object *my); tenm_object * p_can_new(void) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = (double) (WINDOW_WIDTH / 2); double y = -49.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "p_can_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 50.0, y - 50.0, x + 50.0, y + 50.0, x - 50.0, y + 50.0, x - 50.0, y - 50.0); if (p[0] == NULL) { fprintf(stderr, "p_can_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 5); if (count == NULL) { fprintf(stderr, "p_can_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 4); if (count_d == NULL) { fprintf(stderr, "p_can_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] life mode * [3] life timer * [4] "was green when killed" flag */ /* list of count_d * [0] speed x * [1] speed y * [2] turret aim x * [3] turret aim y */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 0; count[4] = 0; count_d[0] = 0.0; count_d[1] = (((double) (WINDOW_HEIGHT / 4)) - y) / 90.0; count_d[2] = 40.0; count_d[3] = 0.0; new = tenm_object_new("P-can", ATTR_BOSS, ATTR_PLAYER_SHOT, 400, x, y, 5, count, 4, count_d, 1, p, (int (*)(tenm_object *, double)) (&p_can_move), (int (*)(tenm_object *, tenm_object *)) (&p_can_hit), (int (*)(tenm_object *, const tenm_object *)) (&p_can_act), (int (*)(tenm_object *, int)) (&p_can_draw)); if (new == NULL) { fprintf(stderr, "p_can_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int p_can_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "p_can_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "p_can_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int p_can_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "p_can_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "p_can_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if (my->count[2] != 1) return 0; deal_damage(my, your, 0); if (p_can_green(my)) add_chain(my, your); my->count[1] = 2; if (my->hit_point <= 0) { add_score(1500); set_background(1); p_can_next(my); return 0; } return 0; } static void p_can_next(tenm_object *my) { int n; /* sanity check */ if (my == NULL) { fprintf(stderr, "p_can_next: my is NULL\n"); return; } tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy), 0); /* set "was green" flag before we change the life mode */ if (p_can_green(my)) { n = 8; my->count[4] = 1; } else { n = 7; my->count[4] = 0; } tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 5000, n, 10.0, 6)); my->count[2] = 2; my->count[3] = 0; my->count[1] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.5; /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ tenm_mass_delete(my->mass); my->mass = NULL; } static int p_can_act(tenm_object *my, const tenm_object *player) { int i; int j; int theta; double v[2]; double a[2]; double result[2]; double x; double y; /* sanity check */ if (my == NULL) { fprintf(stderr, "p_can_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; (my->count[3])++; /* encounter */ if (my->count[2] == 0) { if (my->count[3] >= 90) { my->count[2] = 1; my->count[3] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; return 0; } return 0; } /* dead */ if (my->count[2] == 2) { if (p_can_green(my)) i = 8; else i = 7; if ((my->count[3] >= 30) && (my->count[3] <= 75) && (my->count[3] % 15 == 0)) { theta = rand() % 360; tenm_table_add(explosion_new(my->x + 30.0 * tenm_cos(theta), my->y + 30.0 * tenm_sin(theta), 0.0, 0.0, 2, 300, i, 5.0, 8)); } if (my->count[3] > 120) { tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 3000, i, 10.0, 8)); tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 30.0, 100, i, 4.0, 0.0, 16)); tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 50.0, 30, i, 2.5, 0.0, 12)); tenm_table_add(stage_clear_new(100)); return 1; } return 0; } /* self-destruction */ if ((my->count[2] == 1) && (my->count[3] >= 2980)) { set_background(2); clear_chain(); p_can_next(my); return 0; } /* aim at the player */ v[0] = my->count_d[2]; v[1] = my->count_d[3]; if ((my->count[3] >= 1300) && (my->count[3] <= 1360)) { a[0] = -40.0; a[1] = 0.0; } else if ((my->count[3] >= 2700) && (my->count[3] <= 2760)) { a[0] = 40.0; a[1] = 0.0; } else { a[0] = player->x - my->x; a[1] = player->y - my->y; } result[0] = v[0]; result[1] = v[1]; if (((my->count[3] >= 100) && (my->count[3] <= 160)) || ((my->count[3] >= 1300) && (my->count[3] <= 1360)) || ((my->count[3] >= 1500) && (my->count[3] <= 1560)) || ((my->count[3] >= 2700) && (my->count[3] <= 2760))) vector_rotate_bounded(result, v, a, 3); else if (((my->count[3] > 160) && (my->count[3] < 1300)) || ((my->count[3] > 1560) && (my->count[3] <= 2700))) vector_rotate_bounded(result, v, a, 1); else if ((my->count[3] >= 1400) && (my->count[3] < 1490)) vector_rotate(result, v, -2); else if ((my->count[3] >= 2800) && (my->count[3] < 2890)) vector_rotate(result, v, 2); my->count_d[2] = result[0]; my->count_d[3] = result[1]; if (my->count_d[3] < 0.0) { if (my->count_d[2] > 0.0) { my->count_d[2] = 40.0; my->count_d[3] = 0.0; } else { my->count_d[2] = -40.0; my->count_d[3] = 0.0; } } /* shoot */ if (((my->count[3] <= 51) && (my->count[3] % 17 == 0)) || ((my->count[3] >= 160) && (my->count[3] < 1233) && ((my->count[3] - 160) % 37 == 0)) || ((my->count[3] >= 1400) && (my->count[3] < 1490) && ((my->count[3] - 1400) % 13 == 0)) || ((my->count[3] >= 1560) && (my->count[3] < 2633) && ((my->count[3] - 1560) % 37 == 0)) || ((my->count[3] >= 2800) && (my->count[3] < 2890) && ((my->count[3] - 2800) % 13 == 0))) { for (i = -1; i <= 1; i += 2) { for (j = -45; j <= 45; j += 45) { x = my->x + my->count_d[2] + my->count_d[3] * 3.0/4.0 * ((double) i); y = my->y + my->count_d[3] - my->count_d[2] * 3.0/4.0 * ((double) i); v[0] = my->count_d[2]; v[1] = my->count_d[3]; result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, j); tenm_table_add(laser_point_new(x, y, 3.0, x + result[0], y + result[1], 25.0, 2)); } } } if (((my->count[3] >= 160) && (my->count[3] < 1233) && ((my->count[3] - 160) % 29 == 0)) || ((my->count[3] >= 1560) && (my->count[3] < 2633) && ((my->count[3] - 1560) % 29 == 0)) || (my->count[3] == 1370) || (my->count[3] == 2770)) { tenm_table_add(normal_shot_point_new(my->x, my->y, 2.5, player->x, player->y, 4)); } return 0; } static int p_can_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; /* sanity check */ if (my == NULL) { fprintf(stderr, "p_can_draw: my is NULL\n"); return 0; } /* dead enemy has low priority */ if (((my->count[2] <= 1) && (priority != 0)) || ((my->count[2] > 1) && (priority != -1))) return 0; if (p_can_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 1) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } /* turret */ if (tenm_draw_circle((int) (my->x), (int) (my->y), 50, 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + my->count_d[2] + my->count_d[3] * 3.0/4.0), (int) (my->y + my->count_d[3] - my->count_d[2] * 3.0/4.0), (int) (my->x + my->count_d[2] - my->count_d[3] * 3.0/4.0), (int) (my->y + my->count_d[3] + my->count_d[2] * 3.0/4.0), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + my->count_d[2] - my->count_d[3] * 3.0/4.0), (int) (my->y + my->count_d[3] + my->count_d[2] * 3.0/4.0), (int) (my->x - my->count_d[2] - my->count_d[3] * 3.0/4.0), (int) (my->y - my->count_d[3] + my->count_d[2] * 3.0/4.0), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - my->count_d[2] - my->count_d[3] * 3.0/4.0), (int) (my->y - my->count_d[3] + my->count_d[2] * 3.0/4.0), (int) (my->x - my->count_d[2] + my->count_d[3] * 3.0/4.0), (int) (my->y - my->count_d[3] - my->count_d[2] * 3.0/4.0), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - my->count_d[2] + my->count_d[3] * 3.0/4.0), (int) (my->y - my->count_d[3] - my->count_d[2] * 3.0/4.0), (int) (my->x + my->count_d[2] + my->count_d[3] * 3.0/4.0), (int) (my->y + my->count_d[3] - my->count_d[2] * 3.0/4.0), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + my->count_d[2] * 30.0 / 40.0 + my->count_d[3] * 3.0 / 4.0), (int) (my->y + my->count_d[3] * 30.0 / 40.0 - my->count_d[2] * 3.0 / 4.0), (int) (my->x + my->count_d[2] * 30.0 / 40.0 - my->count_d[3] * 3.0 / 4.0), (int) (my->y + my->count_d[3] * 30.0 / 40.0 + my->count_d[2] * 3.0 / 4.0), 1, color) != 0) status = 1; /* body */ if (tenm_draw_line((int) (my->x + 50.0), (int) (my->y - 50.0), (int) (my->x + 50.0), (int) (my->y + 50.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 50.0), (int) (my->y + 50.0), (int) (my->x - 50.0), (int) (my->y + 50.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 50.0), (int) (my->y + 50.0), (int) (my->x - 50.0), (int) (my->y - 50.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 50.0), (int) (my->y - 50.0), (int) (my->x + 50.0), (int) (my->y - 50.0), 3, color) != 0) status = 1; /* hit point stat */ if (my->count[2] == 1) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 10, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "p_can_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int p_can_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if ((my->count[2] == 1) && (my->count[3] >= 1370) && (my->count[3] < 2950)) return 1; if ((my->count[2] == 2) && (my->count[4] != 0)) return 1; return 0; } dangen-0.5/spqr/p-can.h0000644000175000017500000000031710276702741015561 0ustar00ooharaoohara00000000000000/* $Id: p-can.h,v 1.1 2004/08/07 07:58:56 oohara Exp $ */ #ifndef __DANGEN_P_CAN_H__ #define __DANGEN_P_CAN_H__ #include "tenm_object.h" tenm_object *p_can_new(void); #endif /* not __DANGEN_P_CAN_H__ */ dangen-0.5/spqr/perpeki.c0000644000175000017500000013546610276702741016233 0ustar00ooharaoohara00000000000000/* $Id: perpeki.c,v 1.225 2004/10/02 16:31:57 oohara Exp $ */ /* [very hard] Perpeki */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "normal-enemy.h" #include "stage-clear.h" #include "score.h" #include "perpeki.h" #define NEAR_ZERO 0.0001 static int perpeki_move(tenm_object *my, double turn_per_frame); static int perpeki_hit(tenm_object *my, tenm_object *your); static void perpeki_explode(tenm_object *my); static int perpeki_act(tenm_object *my, const tenm_object *player); static void perpeki_normal_shot(tenm_object *my, const tenm_object *player, int what); static int perpeki_green(const tenm_object *my); static int perpeki_draw(tenm_object *my, int priority); static tenm_object *perpeki_chip_new(int what); static int perpeki_chip_act(tenm_object *my, const tenm_object *player); static int perpeki_chip_draw(tenm_object *my, int priority); static tenm_object *perpeki_backdancer_new(int table_index, int what); static int perpeki_backdancer_move(tenm_object *my, double turn_per_frame); static int perpeki_backdancer_hit(tenm_object *my, tenm_object *your); static int perpeki_backdancer_signal(tenm_object *my, int n); static int perpeki_backdancer_act(tenm_object *my, const tenm_object *player); static int perpeki_backdancer_green(const tenm_object *my); static int perpeki_backdancer_draw(tenm_object *my, int priority); tenm_object * perpeki_new(void) { int i; tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = 0.0; double y = 0.0; x = (double) (WINDOW_WIDTH / 2); y = -29.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 3); if (p == NULL) { fprintf(stderr, "perpeki_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 30.0, y + 30.0, x - 30.0, y + 30.0, x - 30.0, y - 30.0, x + 30.0, y - 30.0); if (p[0] == NULL) { fprintf(stderr, "perpeki_new: cannot set p[0]\n"); free(p); return NULL; } p[1] = (tenm_primitive *) tenm_polygon_new(4, x + 10.0, y - 30.0, x + 20.0, y - 30.0, x + 30.0, y - 80.0, x + 20.0, y - 80.0); if (p[1] == NULL) { fprintf(stderr, "perpeki_new: cannot set p[1]\n"); (p[0])->delete(p[0]); free(p); return NULL; } p[2] = (tenm_primitive *) tenm_polygon_new(4, x - 10.0, y - 30.0, x - 20.0, y - 30.0, x - 30.0, y - 70.0, x - 20.0, y - 70.0); if (p[2] == NULL) { fprintf(stderr, "perpeki_new: cannot set p[2]\n"); for (i = 0; i < 2; i++) (p[i])->delete(p[i]); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 18); if (count == NULL) { fprintf(stderr, "perpeki_new: malloc(count) failed\n"); for (i = 0; i < 2; i++) (p[i])->delete(p[i]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 6); if (count_d == NULL) { fprintf(stderr, "perpeki_new: malloc(count_d) failed\n"); if (count != NULL) free(count); for (i = 0; i < 2; i++) (p[i])->delete(p[i]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] normal move direction * [3] evasion type * [4] evasion direction * [5] evasion timer * [6] shoot timer * [7 -- 8] shoot theta * [9] number of backdancers dead * [10] life mode * [11] "was green when killed" flag */ count[0] = 0; count[1] = 0; if (rand() % 2 == 0) count[2] = 1; else count[2] = -1; count[3] = 0; count[4] = 0; count[5] = 0; count[6] = 0; count[7] = 0; count[8] = 0; count[9] = 0; count[10] = 0; count[11] = 0; /* list of count_d * [0] speed x * [1] speed y * [2] evasion move center x * [3] evasion move center y */ count_d[0] = (((double) (WINDOW_WIDTH / 2)) - x) / 120.0; count_d[1] = (((double) (WINDOW_HEIGHT / 3)) - y) / 120.0; count_d[2] = 0.0; count_d[3] = 0.0; new = tenm_object_new("Perpeki", ATTR_BOSS, ATTR_PLAYER_SHOT, 2000, x, y, 18, count, 6, count_d, 3, p, (int (*)(tenm_object *, double)) (&perpeki_move), (int (*)(tenm_object *, tenm_object *)) (&perpeki_hit), (int (*)(tenm_object *, const tenm_object *)) (&perpeki_act), (int (*)(tenm_object *, int)) (&perpeki_draw)); if (new == NULL) { fprintf(stderr, "perpeki_new: tenm_object_new failed\n"); free(count_d); if (count != NULL) free(count); for (i = 0; i < 2; i++) (p[i])->delete(p[i]); free(p); return NULL; } return new; } static int perpeki_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) return 0; if (turn_per_frame <= 0.5) return 0; dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int perpeki_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) return 0; if (your == NULL) return 0; if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if (my->count[10] != 1) return 0; deal_damage(my, your, 0); if (perpeki_green(my)) add_chain(my, your); my->count[1] = 2; if (my->hit_point <= 0) { set_background(1); add_score(100000); perpeki_explode(my); return 0; } return 0; } static void perpeki_explode(tenm_object *my) { int n; /* sanity check */ if (my == NULL) return; /* set "was green" flag before we change the life mode */ if (perpeki_green(my)) { my->count[11] = 1; n = 8; } else { my->count[11] = 0; n = 7; } my->count[0] = 0; my->count[1] = 0; my->count[6] = -1; my->count[10] = 2; my->count_d[0] = 0.0; my->count_d[1] = 0.0; tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy), 0); tenm_table_add(fragment_new(my->x - 20.0, my->y - 50.0, 0.0, 0.0, 30.0, 20, n, 4.0, 0.0, 20)); tenm_table_add(fragment_new(my->x + 20.0, my->y - 50.0, 0.0, 0.0, 30.0, 20, n, 4.0, 0.0, 20)); tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 5000, n, 10.0, 6)); /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ tenm_mass_delete(my->mass); my->mass = NULL; } static int perpeki_act(tenm_object *my, const tenm_object *player) { int i; int theta; double speed; /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; /* encounter */ if (my->count[10] == 0) { (my->count[6])++; if (my->count[6] >= 120) { my->count[6] = -192; my->count[10] = 1; my->count_d[0] = 0.0; my->count_d[1] = 0.0; return 0; } return 0; } /* dead */ if (my->count[10] == 2) { my->count_d[0] = 0.0; my->count_d[1] = 0.5; if (my->count[11] != 0) i = 8; else i = 7; (my->count[6])++; if ((my->count[6] >= 30) && (my->count[6] <= 75) && (my->count[6] % 15 == 0)) { theta = rand() % 360; tenm_table_add(explosion_new(my->x + 30.0 * tenm_cos(theta), my->y + 30.0 * tenm_sin(theta), 0.0, 0.0, 2, 300, i, 5.0, 8)); } if (my->count[6] > 120) { tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 3000, i, 10.0, 8)); tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 30.0, 100, i, 4.0, 0.0, 16)); tenm_table_add(fragment_new(my->x, my->y, 0.0, 0.0, 50.0, 30, i, 2.5, 0.0, 12)); tenm_table_add(stage_clear_new(100)); return 1; } return 0; } /* self-destruction */ if (my->count[6] >= 6366) { set_background(2); perpeki_explode(my); clear_chain(); return 0; } /* normal move */ if (my->x < 50.0) my->count[2] = 1; else if (my->x > ((double) WINDOW_WIDTH) - 50.0) my->count[2] = -1; my->count_d[0] = 2.0 * ((double) (my->count[2])); my->count_d[1] = 0.0; /* evasion begin */ if (my->count[3] == 0) { if ((my->x - 30.0 < player->x) && (my->x + 30.0 > player->x)) { if (rand() % 3 != 0) { my->count[3] = 1; } else { my->count[3] = 2; } if (my->x < 160.0) my->count[4] = 1; else if (my->x > ((double) WINDOW_WIDTH) - 160.0) my->count[4] = -1; else if ((double) (rand() % WINDOW_WIDTH) > my->x) my->count[4] = 1; else my->count[4] = -1; my->count[5] = 0; my->count_d[2] = my->x + 86.6025 * ((double) (my->count[4])); my->count_d[3] = my->y - 50.0; } } /* evasion */ if (my->count[3] != 0) { if (my->count[3] == 1) { if (my->count[5] < 20) { my->count_d[0] = 4.3301 * ((double) (my->count[4])); my->count_d[1] = 2.5; } else if (my->count[5] < 30) { my->count_d[0] = 0.0; my->count_d[1] = -5.0; } else { my->count[3] = 0; my->count[4] = 0; my->count[5] = 0; } } else { if (my->count[5] < 30) { theta = 150 - (my->count[5] + 1) * 4; if (my->count[4] < 0) theta = 180 - theta; my->count_d[0] = my->count_d[2] + 100.0 * tenm_cos(theta); my->count_d[1] = my->count_d[3] + 100.0 * tenm_sin(theta); my->count_d[0] -= my->x; my->count_d[1] -= my->y; } else { my->count[3] = 0; my->count[4] = 0; my->count[5] = 0; } } (my->count[5])++; } /* shoot */ (my->count[6])++; if (((my->count[6] >= 0) && (my->count[6] < 768)) || ((my->count[6] >= 3120) && (my->count[6] < 3888)) || ((my->count[6] >= 6000) && (my->count[6] < 6240))) { perpeki_normal_shot(my, player, 0); if (my->count[9] >= 1) perpeki_normal_shot(my, player, 1); if (my->count[9] >= 2) perpeki_normal_shot(my, player, 2); } if (((my->count[6] >= 864) && (my->count[6] < 2304)) || ((my->count[6] >= 3888) && (my->count[6] < 5184))) { if (my->count[9] >= 1) perpeki_normal_shot(my, player, 1); if (my->count[9] >= 2) perpeki_normal_shot(my, player, 0); } if (((my->count[6] >= 2304) && (my->count[6] < 3072)) || ((my->count[6] >= 5184) && (my->count[6] < 5952))) { switch (my->count[6] % 192) { case 0: for (i = 0; i < 7; i++) tenm_table_add(laser_point_new(my->x, my->y, 1.5 + 1.5 * ((double) i), player->x + 200.0, player->y - 100.0, 25.0, 2)); break; case 12: for (i = 0; i < 7; i++) tenm_table_add(laser_point_new(my->x, my->y, 1.5 + 1.5 * ((double) i), player->x, player->y, 25.0, 2)); break; case 24: for (i = 0; i < 7; i++) tenm_table_add(laser_point_new(my->x, my->y, 1.5 + 1.5 * ((double) i), player->x - 200.0, player->y + 100.0, 25.0, 2)); break; case 72: for (i = 0; i < 7; i++) tenm_table_add(laser_point_new(my->x, my->y, 1.5 + 1.5 * ((double) i), player->x - 400.0, player->y, 25.0, 2)); break; case 96: for (i = 0; i < 7; i++) tenm_table_add(laser_point_new(my->x, my->y, 1.5 + 1.5 * ((double) i), player->x - 150.0, player->y - 100.0, 25.0, 2)); break; case 102: for (i = 0; i < 7; i++) tenm_table_add(laser_point_new(my->x, my->y, 1.5 + 1.5 * ((double) i), player->x, player->y, 25.0, 2)); break; case 108: for (i = 0; i < 7; i++) tenm_table_add(laser_point_new(my->x, my->y, 1.5 + 1.5 * ((double) i), player->x + 150.0, player->y + 100.0, 25.0, 2)); break; case 114: for (i = 0; i < 7; i++) tenm_table_add(laser_point_new(my->x, my->y, 1.5 + 1.5 * ((double) i), player->x + 400.0, player->y, 25.0, 2)); break; default: break; } if (my->count[6] % 192 == 120) my->count[7] = rand() % 360; if (my->count[6] % 192 >= 120) { if (my->count[6] % 2 == 0) speed = 4.0; else speed = 4.5; theta = my->count[7] - ((my->count[6] % 192) - 120) * 5; if (my->count[7] % 2 == 0) theta *= -1; tenm_table_add(laser_angle_new(my->x, my->y, speed, theta, 25.0, 5)); } if (my->count[6] % 192 == 156) my->count[8] = rand() % 360; if (my->count[6] % 192 >= 156) { if (my->count[6] % 2 == 0) speed = 9.0; else speed = 9.5; theta = my->count[8] + ((my->count[6] % 192) - 120) * 10; if (my->count[7] % 2 == 0) theta *= -1; tenm_table_add(laser_angle_new(my->x, my->y, speed, theta, 25.0, 5)); } } /* add backdancer */ if (my->count[6] == -144) { for (i = 0; i < 3; i++) tenm_table_add(perpeki_backdancer_new(my->table_index, i)); } /* add chip */ if (my->count[6] == 900) tenm_table_add(perpeki_chip_new(0)); if (my->count[6] == 1100) tenm_table_add(perpeki_chip_new(1)); if (my->count[6] == 1300) tenm_table_add(perpeki_chip_new(2)); if (my->count[6] == 1500) tenm_table_add(perpeki_chip_new(3)); if (my->count[6] == 1700) tenm_table_add(perpeki_chip_new(4)); if (my->count[6] == 1900) tenm_table_add(perpeki_chip_new(5)); if (my->count[6] == 2100) tenm_table_add(perpeki_chip_new(6)); if (my->count[6] == 3888) tenm_table_add(perpeki_chip_new(7)); if (my->count[6] == 4088) tenm_table_add(perpeki_chip_new(8)); if (my->count[6] == 4288) tenm_table_add(perpeki_chip_new(9)); if (my->count[6] == 4488) tenm_table_add(perpeki_chip_new(10)); if (my->count[6] == 4688) tenm_table_add(perpeki_chip_new(11)); if (my->count[6] == 4888) tenm_table_add(perpeki_chip_new(12)); if (my->count[6] == 5088) tenm_table_add(perpeki_chip_new(13)); return 0; } static void perpeki_normal_shot(tenm_object *my, const tenm_object *player, int what) { int i; int theta; /* sanity check */ if (my == NULL) return; if (player == NULL) return; if (what == 0) { switch (my->count[6] % 48) { case 0: tenm_table_add(normal_shot_point_new(my->x, my->y, 5.5, player->x, player->y, 1)); break; case 9: tenm_table_add(normal_shot_point_new(my->x, my->y, 6.5, player->x + 60.0, player->y, 1)); break; case 18: tenm_table_add(normal_shot_point_new(my->x, my->y, 7.5, player->x - 60.0, player->y, 1)); break; case 30: tenm_table_add(normal_shot_point_new(my->x, my->y, 5.5, player->x, player->y, 1)); break; case 36: tenm_table_add(normal_shot_point_new(my->x, my->y, 6.5, player->x - 60.0, player->y, 1)); break; case 42: tenm_table_add(normal_shot_point_new(my->x, my->y, 7.5, player->x + 60.0, player->y, 1)); break; default: break; } } if (what == 1) { switch (my->count[6] % 48) { case 0: tenm_table_add(normal_shot_angle_new(my->x, my->y, 5.5, 170, 0)); tenm_table_add(normal_shot_angle_new(my->x, my->y, 5.5, 10, 0)); break; case 9: tenm_table_add(normal_shot_angle_new(my->x, my->y, 6.0, 150, 0)); tenm_table_add(normal_shot_angle_new(my->x, my->y, 6.0, 30, 0)); break; case 18: tenm_table_add(normal_shot_angle_new(my->x, my->y, 6.5, 130, 0)); tenm_table_add(normal_shot_angle_new(my->x, my->y, 6.5, 50, 0)); break; case 30: tenm_table_add(normal_shot_angle_new(my->x, my->y, 5.5, 160, 0)); tenm_table_add(normal_shot_angle_new(my->x, my->y, 5.5, 20, 0)); break; case 36: tenm_table_add(normal_shot_angle_new(my->x, my->y, 6.0, 140, 0)); tenm_table_add(normal_shot_angle_new(my->x, my->y, 6.0, 40, 0)); break; case 42: tenm_table_add(normal_shot_angle_new(my->x, my->y, 6.5, 120, 0)); tenm_table_add(normal_shot_angle_new(my->x, my->y, 6.5, 60, 0)); break; default: break; } } if (what == 2) { if (my->count[6] % 48 == 24) { theta = rand() % 360; for (i = 0; i < 360; i += 30) tenm_table_add(normal_shot_new(my->x, my->y, 2.0 * tenm_cos(theta + i), 3.5 + 2.0 * tenm_sin(theta + i), 2, -2, 0)); } if (my->count[6] % 48 == 0) { theta = rand() % 360; for (i = 0; i < 360; i += 30) tenm_table_add(normal_shot_new(my->x, my->y, 4.0 + 2.0 * tenm_cos(theta + i), 0.5 + 2.0 * tenm_sin(theta + i), 2, -2, 0)); theta = rand() % 360; for (i = 0; i < 360; i += 30) tenm_table_add(normal_shot_new(my->x, my->y, -4.0 + 2.0 * tenm_cos(theta + i), 0.5 + 2.0 * tenm_sin(theta + i), 2, -2, 0)); } } } /* return 1 (true) or 0 (false) */ static int perpeki_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if ((my->count[10] == 1) && (my->count[6] >= 6336)) return 0; if (my->count[10] == 2) { if (my->count[11] != 0) return 1; else return 0; } if (my->count[9] >= 2) return 1; if (((my->count[6] >= 864) && (my->count[6] < 2304)) || ((my->count[6] >= 3888) && (my->count[6] < 5184))) return 1; return 0; } static int perpeki_draw(tenm_object *my, int priority) { tenm_color color; char temp[32]; int status = 0; /* sanity check */ if (my == NULL) return 0; if (((my->count[10] != 2) && (priority != 0)) || ((my->count[10] == 2) && (priority != -1))) return 0; /* body */ if (perpeki_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 1) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (tenm_draw_line(((int) (my->x)) + 30, ((int) (my->y)) + 30, ((int) (my->x)) - 30, ((int) (my->y)) + 30, 2, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x)) - 30, ((int) (my->y)) + 30, ((int) (my->x)) - 30, ((int) (my->y)) - 30, 2, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x)) - 30, ((int) (my->y)) - 30, ((int) (my->x)) + 30, ((int) (my->y)) - 30, 2, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x)) + 30, ((int) (my->y)) - 30, ((int) (my->x)) + 30, ((int) (my->y)) + 30, 2, color) != 0) status = 1; if (my->count[10] != 2) { if (tenm_draw_line(((int) (my->x)) + 10, ((int) (my->y)) - 30, ((int) (my->x)) + 20, ((int) (my->y)) - 80, 2, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x)) + 20, ((int) (my->y)) - 30, ((int) (my->x)) + 30, ((int) (my->y)) - 80, 2, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x)) + 20, ((int) (my->y)) - 80, ((int) (my->x)) + 30, ((int) (my->y)) - 80, 2, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x)) - 10, ((int) (my->y)) - 30, ((int) (my->x)) - 30, ((int) (my->y)) - 70, 2, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x)) - 20, ((int) (my->y)) - 30, ((int) (my->x)) - 40, ((int) (my->y)) - 70, 2, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x)) - 30, ((int) (my->y)) - 70, ((int) (my->x)) - 40, ((int) (my->y)) - 70, 2, color) != 0) status = 1; } /* hit point stat */ if (my->count[10] == 1) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 5, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "perpeki_draw: draw_string failed\n"); status = 1; } } return status; } static tenm_object * perpeki_chip_new(int what) { int i; int n = 1; int suffix; double a_x; double a_y; double b_x; double b_y; double t; tenm_object *new = NULL; int *count = NULL; int x = 0; int y = 0; switch (what) { case 0: n = 37; break; case 1: n = 32; break; case 2: n = 64; break; case 3: n = 48; break; case 4: n = 48; break; case 5: n = 36; break; case 6: n = 60; break; case 7: n = 96; break; case 8: n = 120; break; case 9: n = 72; break; case 10: n = 96; break; case 11: n = 120; break; case 12: n = 90; break; case 13: n = 120; break; default: fprintf(stderr, "perpeki_chip_new: strange what (%d)\n", what); return NULL; break; } count = (int *) malloc(sizeof(int) * (3 + n * 3)); if (count == NULL) { fprintf(stderr, "perpeki_chip_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] color (for delete_enemy_shot) * [1] border y * [2] number of lasers * [3 --] laser (x, y, theta) */ count[0] = 6; count[1] = -200; count[2] = n; switch (what) { case 0: for (i = 0; i < n; i++) { suffix = 3 + i * 3; count[suffix + 0] = (int) (150.0 * tenm_cos(i * 5)); count[suffix + 1] = (int) (150.0 * tenm_sin(i * 5)); count[suffix + 0] += WINDOW_WIDTH / 2; count[suffix + 1] += WINDOW_HEIGHT / 8; count[suffix + 2] = i * 5; } break; case 1: for (i = 0; i < n; i++) { suffix = 3 + i * 3; if (i < 16) { a_x = (double) (WINDOW_WIDTH / 2 - 20); a_y = (double) (WINDOW_HEIGHT / 8); b_x = 20.0; b_y = (double) (WINDOW_HEIGHT / 2); } else { a_x = (double) (WINDOW_WIDTH / 2 + 20); a_y = (double) (WINDOW_HEIGHT / 8); b_x = (double) (WINDOW_WIDTH - 20); b_y = (double) (WINDOW_HEIGHT / 2); } t = ((double) (i % 16)) / 15.0; count[suffix + 0] = (int) (a_x * (1.0 - t) + b_x * t); count[suffix + 1] = (int) (a_y * (1.0 - t) + b_y * t); if (i < 16) count[suffix + 2] = 110 - i * 5; else count[suffix + 2] = 70 + (i - 16) * 5; } break; case 2: for (i = 0; i < n; i++) { suffix = 3 + i * 3; if (i < 16) { a_x = 300.0; a_y = 20.0; b_x = 20.0; b_y = 300.0; } else if (i < 32) { a_x = 20.0; a_y = 20.0; b_x = 300.0; b_y = 300.0; } else if (i < 48) { a_x = 340.0; a_y = 20.0; b_x = 620.0; b_y = 300.0; } else { a_x = 620.0; a_y = 20.0; b_x = 340.0; b_y = 300.0; } t = ((double) (i % 16)) / 15.0; count[suffix + 0] = (int) (a_x * (1.0 - t) + b_x * t); count[suffix + 1] = (int) (a_y * (1.0 - t) + b_y * t); if (i < 16) count[suffix + 2] = 90 - i * 10; else if (i < 32) count[suffix + 2] = 90 - (i - 16) * 10; else if (i < 48) count[suffix + 2] = 90 + (i - 32) * 10; else count[suffix + 2] = 90 + (i - 48) * 10; } break; case 3: for (i = 0; i < n; i++) { suffix = 3 + i * 3; count[suffix + 0] = (int) (100.0 * tenm_cos((i % 24) * 15)); count[suffix + 1] = (int) (100.0 * tenm_sin((i % 24) * 15)); if (i < 24) { count[suffix + 0] += WINDOW_WIDTH / 4; count[suffix + 1] += WINDOW_HEIGHT / 4; } else { count[suffix + 0] += (WINDOW_WIDTH * 3) / 4; count[suffix + 1] += WINDOW_HEIGHT / 4; } count[suffix + 2] = (i % 24) * 15; if (i < 24) count[suffix + 2] -= 45; else count[suffix + 2] += 45; } break; case 4: for (i = 0; i < n; i++) { suffix = 3 + i * 3; if (i < 12) { count[suffix + 0] = 230 + 16 * i; count[suffix + 1] = WINDOW_HEIGHT / 6; count[suffix + 2] = 35 + i * 10; } else if (i < 24) { count[suffix + 0] = 38 + 16 * (i - 12); count[suffix + 1] = WINDOW_HEIGHT / 3; count[suffix + 2] = 45 + (i - 12) * 10; } else if (i < 36) { count[suffix + 0] = 422 + 16 * (i - 24); count[suffix + 1] = WINDOW_HEIGHT / 3; count[suffix + 2] = 35 + (i - 24) * 10; } else { count[suffix + 0] = 230 + 16 * (i - 36); count[suffix + 1] = WINDOW_HEIGHT / 2; count[suffix + 2] = 35 + (i - 36) * 10; } } break; case 5: for (i = 0; i < n; i++) { suffix = 3 + i * 3; if (i < 18) { count[suffix + 0] = 7 + (int) (300.0 * tenm_cos(i * 5)); count[suffix + 1] = 7 + (int) (300.0 * tenm_sin(i * 5)); count[suffix + 2] = 30 + i * 5; } else { count[suffix + 0] = 633 + (int) (300.0 * tenm_cos(180 - (i - 18) * 5)); count[suffix + 1] = 7 + (int) (300.0 * tenm_sin(180 - (i - 18) * 5)); count[suffix + 2] = -30 + 180 - (i - 18) * 5; } } break; case 6: for (i = 0; i < n; i++) { suffix = 3 + i * 3; if (i < 15) { count[suffix + 0] = 20; count[suffix + 1] = 20 + 20 * i; count[suffix + 2] = 0 + i * 5; } else if (i < 30) { count[suffix + 0] = 120; count[suffix + 1] = 20 + 20 * (i - 15); count[suffix + 2] = 22 + (i - 15) * 10; } else if (i < 45) { count[suffix + 0] = WINDOW_WIDTH - 120; count[suffix + 1] = 20 + 20 * (i - 30); count[suffix + 2] = 158 - (i - 30) * 10; } else { count[suffix + 0] = WINDOW_WIDTH - 20; count[suffix + 1] = 20 + 20 * (i - 45); count[suffix + 2] = 180 - (i - 45) * 5; } } break; case 7: for (i = 0; i < n; i++) { suffix = 3 + i * 3; if (i < 48) count[suffix + 0] = (WINDOW_WIDTH * ((i % 48))) / 49; else count[suffix + 0] = (WINDOW_WIDTH * (48 - (i % 48))) / 49; count[suffix + 1] = (WINDOW_HEIGHT * ((i % 48) + 1)) / 49; if (i < 48) count[suffix + 2] = 90 + i * 10; else count[suffix + 2] = 0 - (i - 48) * 10; } break; case 8: for (i = 0; i < n; i++) { suffix = 3 + i * 3; count[suffix + 0] = (int) (100.0 * tenm_cos(i * 9)); count[suffix + 1] = (int) (100.0 * tenm_sin(i * 9)); if (i < 40) { count[suffix + 0] += WINDOW_WIDTH / 4; count[suffix + 1] += WINDOW_HEIGHT / 4; } else if (i < 80) { count[suffix + 0] += WINDOW_WIDTH / 2; count[suffix + 1] += WINDOW_HEIGHT / 2; } else { count[suffix + 0] += (WINDOW_WIDTH * 3) / 4; count[suffix + 1] += (WINDOW_HEIGHT * 3) / 4; } count[suffix + 2] = i * 9; if (i < 40) count[suffix + 2] -= 60; else if (i < 80) count[suffix + 2] -= 10; else count[suffix + 2] += 40; } break; case 9: for (i = 0; i < n; i++) { suffix = 3 + i * 3; if (i < 48) { count[suffix + 0] = (WINDOW_WIDTH * (((i % 16) / 4) * 2 + 1)) / 8; count[suffix + 1] = 36 + 180 * (i / 16) + 18 * (i % 4); } else { count[suffix + 0] = (WINDOW_WIDTH * ((((i-48) % 12) / 4) * 2 + 2)) / 8; count[suffix + 1] = 36 + 90 + 180 * ((i-48) / 12) + 18 * (i % 4); } count[suffix + 2] = i * 20; } break; case 10: for (i = 0; i < n; i++) { suffix = 3 + i * 3; count[suffix + 0] = ((WINDOW_WIDTH / 2) * ((i % 48))) / 49; count[suffix + 1] = (WINDOW_HEIGHT * ((i % 48) + 1)) / 49; if (i >= 48) count[suffix + 0] += WINDOW_WIDTH / 2; count[suffix + 2] = i * 10; } break; case 11: for (i = 0; i < n; i++) { suffix = 3 + i * 3; count[suffix + 0] = (int) (150.0 * tenm_cos(i * 3)); count[suffix + 1] = (int) (150.0 * tenm_sin(i * 3)); count[suffix + 0] += WINDOW_WIDTH / 2; count[suffix + 1] += WINDOW_HEIGHT / 2; count[suffix + 2] = i * 3; if (i % 3 == 0) count[suffix + 2] += 60; else if (i % 3 == 1) count[suffix + 2] -= 30; } break; case 12: for (i = 0; i < n; i++) { suffix = 3 + i * 3; if (i < 45) { count[suffix + 0] = 7 + (int) (300.0 * tenm_cos(-(i * 2))); count[suffix + 1] = 473 + (int) (300.0 * tenm_sin(-(i * 2))); count[suffix + 2] = -(i * 2); } else { count[suffix + 0] = 633 + (int) (300.0 * tenm_cos(90 + (i - 45) * 2)); count[suffix + 1] = 7 + (int) (300.0 * tenm_sin(90 + (i - 45) * 2)); count[suffix + 2] = 90 + (i - 45) * 2; } if (i % 2 == 0) count[suffix + 2] += 30; } break; case 13: for (i = 0; i < n; i++) { suffix = 3 + i * 3; a_x = 200.0 * tenm_cos((i / 24) * 72); a_y = 200.0 * tenm_sin((i / 24) * 72); b_x = 200.0 * 0.3820 * tenm_cos(((i+12) / 24) * 72 - 36); b_y = 200.0 * 0.3820 * tenm_sin(((i+12) / 24) * 72 - 36); t = ((double) (i % 12)) / 11.0; count[suffix + 0] = WINDOW_WIDTH / 2 + (int) (a_x * (1.0 - t) + b_x * t); count[suffix + 1] = WINDOW_HEIGHT / 2 + (int) (a_y * (1.0 -t) + b_y * t); count[suffix + 2] = i * 5; if (i % 2 == 0) count[suffix + 2] += 40; } break; default: fprintf(stderr, "perpeki_chip_new: undefined what (%d)\n", what); count[2] = 0; break; } /* add a little of randomness */ if (rand() % 2 == 0) { for (i = 0; i < n; i++) { suffix = 3 + i * 3; count[suffix + 0] = WINDOW_WIDTH - count[suffix + 0]; count[suffix + 2] = 180 - count[suffix + 2]; } } x = -5 + (rand() % 11); y = -5 + (rand() % 11); for (i = 0; i < n; i++) { suffix = 3 + i * 3; count[suffix + 0] += x; count[suffix + 1] += y; } /* ATTR_ENEMY_SHOT is only to clear it when the player is killed */ new = tenm_object_new("perpeki_chip", ATTR_ENEMY_SHOT, 0, 0, (double) (x + WINDOW_WIDTH / 2), (double) (y + WINDOW_HEIGHT / 2), 3 + n * 3, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&perpeki_chip_act), (int (*)(tenm_object *, int)) (&perpeki_chip_draw)); if (new == NULL) { fprintf(stderr, "perpeki_chip_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int perpeki_chip_act(tenm_object *my, const tenm_object *player) { int i; int suffix; int theta; double dx; double dy; /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; /* move border */ my->count[1] += 4; if (my->count[1] > WINDOW_HEIGHT + 15) return 1; /* shoot */ for (i = 0; i < my->count[2]; i++) { suffix = 3 + i * 3; if ((my->count[suffix + 1] > my->count[1]) || (my->count[suffix + 1] <= my->count[1] - 4)) continue; theta = my->count[suffix + 2]; while (theta >= 360) theta -= 360; while (theta < 0) theta += 360; if ((double) (my->count[suffix + 1]) < player->y) { if (theta > 180) theta -= 180; } else { if (theta <= 180) theta -= 180; } dx = 15.0 * tenm_cos(theta); dy = 15.0 * tenm_sin(theta); tenm_table_add(laser_angle_new(my->count[suffix + 0] - dx, my->count[suffix + 1] - dy, 8.0, theta, 30.0, 4)); } return 0; } static int perpeki_chip_draw(tenm_object *my, int priority) { tenm_color color; int i; int suffix; int status = 0; int dx; int dy; int theta; /* sanity check */ if (my == NULL) return 0; if (priority != 0) return 0; /* border */ color = tenm_map_color(158, 158, 158); if (my->count[1] >= 0) { if (tenm_draw_line(0, my->count[1], WINDOW_WIDTH, my->count[1], 1, color) != 0) status = 1; } /* laser */ color = tenm_map_color(118, 99, 158); for (i = 0; i < my->count[2]; i++) { suffix = 3 + i * 3; if (my->count[suffix + 1] <= my->count[1]) continue; theta = my->count[suffix + 2]; dx = (int) (15.0 * tenm_cos(theta)); dy = (int) (15.0 * tenm_sin(theta)); if (tenm_draw_line(my->count[suffix + 0] + dx, my->count[suffix + 1] + dy, my->count[suffix + 0] - dx, my->count[suffix + 1] - dy, 1, color) != 0) status = 1; } return status; } static tenm_object * perpeki_backdancer_new(int table_index, int what) { int hit_mask; tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = 0.0; double y = 0.0; double target_y; /* sanity check */ if (table_index < 0) { fprintf(stderr, "perpeki_backdancer_new: strange table_index " "(%d)\n", table_index); return NULL; } if ((what < 0) || (what > 2)) { fprintf(stderr, "perpeki_backdancer_new: strange what (%d)\n", what); return NULL; } x = (double) (WINDOW_WIDTH * (what + 1) / 4); y = - 19.0; target_y = 60.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "perpeki_backdancer_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 20.0, y + 20.0, x - 20.0, y + 20.0, x - 20.0, y - 20.0, x + 20.0, y - 20.0); if (p[0] == NULL) { fprintf(stderr, "perpeki_backdancer_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 8); if (count == NULL) { fprintf(stderr, "perpeki_backdancer_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 6); if (count_d == NULL) { fprintf(stderr, "perpeki_backdancer_new: malloc(count_d) failed\n"); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] move/shoot timer * [3] what * [4] shoot timer * [5] core index * [6] life mode */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = what; count[4] = 0; count[5] = table_index; count[6] = 0; /* list of count_d * [0] speed x * [1] speed y */ count_d[0] = 0.0; count_d[1] = (target_y - y) / 60.0; if (what == 2) hit_mask = 0; else hit_mask = ATTR_PLAYER_SHOT; new = tenm_object_new("Perpeki backdancer", ATTR_ENEMY, hit_mask, 1000, x, y, 8, count, 6, count_d, 1, p, (int (*)(tenm_object *, double)) (&perpeki_backdancer_move), (int (*)(tenm_object *, tenm_object *)) (&perpeki_backdancer_hit), (int (*)(tenm_object *, const tenm_object *)) (&perpeki_backdancer_act), (int (*)(tenm_object *, int)) (&perpeki_backdancer_draw)); if (new == NULL) { fprintf(stderr, "perpeki_backdancer_new: tenm_object_new failed\n"); free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int perpeki_backdancer_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) return 0; if (turn_per_frame <= 0.5) return 0; dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int perpeki_backdancer_hit(tenm_object *my, tenm_object *your) { int n; /* sanity check */ if (my == NULL) return 0; if (your == NULL) return 0; if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if (my->count[3] == 2) return 0; if (my->count[6] != 1) return 0; deal_damage(my, your, 0); if (perpeki_backdancer_green(my)) add_chain(my, your); my->count[1] = 41; if (my->hit_point <= 0) { add_score(75000); tenm_table_apply(my->count[5], (int (*)(tenm_object *, int)) (&perpeki_backdancer_signal), 0); if (perpeki_backdancer_green(my)) n = 8; else n = 7; tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 1, 1000, n, 8.0, 6)); tenm_table_add(fragment_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 30.0, 30, n, 5.0, 0.0, 20)); return 1; } return 0; } static int perpeki_backdancer_signal(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "Perpeki") != 0) return 0; (my->count[9])++; return 0; } static int perpeki_backdancer_act(tenm_object *my, const tenm_object *player) { /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; /* encounter */ if (my->count[6] == 0) { (my->count[2])++; if (my->count[2] >= 60) { my->count[2] = -83; my->count[4] = my->count[3] * 3; my->count[6] = 1; my->count_d[0] = 3.0; my->count_d[1] = 0.0; return 0; } return 0; } /* speed change */ if (my->x < ((double) (WINDOW_WIDTH * (my->count[3] + 1) / 4)) + NEAR_ZERO) my->count_d[0] += 0.1; else my->count_d[0] -= 0.1; /* shoot */ (my->count[2])++; (my->count[4])++; if (my->count[4] >= 9) { if (((my->count[2] >= 0) && (my->count[2] < 768)) || ((my->count[2] >= 864) && (my->count[2] < 2304)) || ((my->count[2] >= 3120) && (my->count[2] < 5184)) || ((my->count[2] >= 6000) && (my->count[2] < 6240))) tenm_table_add(normal_shot_point_new(my->x, my->y, 4.0, player->x, player->y, 3)); my->count[4] = 0; } return 0; } static int perpeki_backdancer_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if (my->count[3] == 2) return 0; if (my->count[6] != 1) return 0; if (my->count[2] >= 6336) return 0; return 1; } static int perpeki_backdancer_draw(tenm_object *my, int priority) { tenm_color color; char temp[32]; int status = 0; /* sanity check */ if (my == NULL) return 0; if (priority != 0) return 0; /* decoration */ if (my->count[3] == 2) { color = tenm_map_color(182, 123, 162); } else if (perpeki_backdancer_green(my)) { if (my->count[1] >= 40) color = tenm_map_color(181, 190, 92); else color = tenm_map_color(157, 182, 123); } else { if (my->count[1] >= 40) color = tenm_map_color(200, 164, 92); else color = tenm_map_color(182, 147, 123); } if (tenm_draw_line(((int) (my->x)) + 10, ((int) (my->y)) - 20, ((int) (my->x)) + 20, ((int) (my->y)) - 50, 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x)) - 10, ((int) (my->y)) - 20, ((int) (my->x)) - 25, ((int) (my->y)) - 40, 1, color) != 0) status = 1; /* body */ if (my->count[3] == 2) { color = tenm_map_color(95, 13, 68); } else if (perpeki_backdancer_green(my)) { if (my->count[1] >= 40) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 40) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (tenm_draw_line(((int) (my->x)) + 20, ((int) (my->y)) + 20, ((int) (my->x)) - 20, ((int) (my->y)) + 20, 2, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x)) - 20, ((int) (my->y)) + 20, ((int) (my->x)) - 20, ((int) (my->y)) - 20, 2, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x)) - 20, ((int) (my->y)) - 20, ((int) (my->x)) + 20, ((int) (my->y)) - 20, 2, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x)) + 20, ((int) (my->y)) - 20, ((int) (my->x)) + 20, ((int) (my->y)) + 20, 2, color) != 0) status = 1; /* hit point stat */ if (my->count[1] > 0) { sprintf(temp, "%d", my->hit_point); if (draw_string((int) (my->x - 10.0), (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "perpeki_backdancer_draw: draw_string failed\n"); status = 1; } } return status; } dangen-0.5/spqr/perpeki.h0000644000175000017500000000033110276702741016216 0ustar00ooharaoohara00000000000000/* $Id: perpeki.h,v 1.4 2003/10/17 14:37:39 oohara Exp $ */ #ifndef __DANGEN_PERPEKI_H__ #define __DANGEN_PERPEKI_H__ #include "tenm_object.h" tenm_object *perpeki_new(void); #endif /* not __DANGEN_PERPEKI_H__ */ dangen-0.5/spqr/plan-0.c0000644000175000017500000005023010276702741015644 0ustar00ooharaoohara00000000000000/* $Id: plan-0.c,v 1.182 2005/07/12 18:20:43 oohara Exp $ */ /* [tutorial] dangen tutorial */ #include /* malloc, rand, atexit */ #include /* strlen, strcmp */ #include /* errno */ #include #include "scheduler.h" #include "tenm_table.h" #include "normal-enemy.h" #include "const.h" #include "flatdice.h" #include "util.h" #include "tutor.h" #include "option.h" #include "ship.h" #include "score.h" #include "ship.h" #include "chain.h" #include "stage.h" #include "background.h" #include "laser.h" #include "wall-0.h" /* set_this_stage_cleared */ #include "scheduler.h" #include "plan-0.h" static flatdice *dice_where = NULL; static flatdice *dice_what = NULL; static void plan_0_more_1_quit(void); static tenm_object *plan_0_more_1_new(void); static int plan_0_more_1_act(tenm_object *my, const tenm_object *player); static int plan_0_more_1_draw(tenm_object *my, int priority); int plan_0(int t) { /* sanity check */ if (t < 0) return SCHEDULER_ERROR; if (t == 0) tenm_table_add(plan_0_more_1_new()); /* if (t == 30) tenm_table_add(tutor_new(1, 100.0, 100.0, 0, 0, 11)); */ return SCHEDULER_SUCCESS; } static void plan_0_more_1_quit(void) { if (dice_where != NULL) flatdice_delete(dice_where); if (dice_what != NULL) flatdice_delete(dice_what); dice_where = NULL; dice_what = NULL; } static tenm_object * plan_0_more_1_new(void) { int i; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; count = (int *) malloc(sizeof(int) * 11); if (count == NULL) { fprintf(stderr, "plan_0_more_1_new: malloc(count) failed\n"); return NULL; } count_d = (double *) malloc(sizeof(double) * 3); if (count_d == NULL) { fprintf(stderr, "plan_0_more_1_new: malloc(count_d) failed\n"); free(count); return NULL; } /* list of count * [0] mode * [1] timer * [2] wait (main) * [3] wait (sub) * [4] wait (reject) * [5] number of tutors killed/escaped * [6] number of tutors created * [7 -- 9] large enemy timer * [10] level display position */ count[0] = 0; count[1] = -1; count[2] = 0; count[3] = 0; count[4] = 0; count[5] = 0; count[6] = 0; for (i = 0; i < 3; i++) count[7 + i] = 0; count[10] = 20; new = tenm_object_new("plan 0 more 1", 0, 0, 1, 0.0, 0.0, 11, count, 3, count_d, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&plan_0_more_1_act), (int (*)(tenm_object *, int)) (&plan_0_more_1_draw)); if (new == NULL) { fprintf(stderr, "plan_0_more_1_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); return NULL; } return new; } int plan_0_more_1_easter_egg(tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if (my->name == NULL) return 0; /* this check is mandatory * --- this function is applied by tenm_table_apply_all() */ if (strcmp(my->name, "plan 0 more 1") != 0) return 0; if (my->count[0] != 0) return 0; if (my->count[1] >= 2970) return 0; set_background(3); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy), 0); clear_chain(); clear_score(); clear_ship(); add_ship(-get_ship()); set_stage_number(1); set_stage_id(get_stage_number(), 0); my->count[0] = 1; my->count[1] = -1; return 0; } static int plan_0_more_1_act(tenm_object *my, const tenm_object *player) { int i; int n; int temp; int where; int what; int rank; double x; double y; double speed; const option *op = NULL; /* sanity check */ if (my == NULL) { fprintf(stderr, "plan_0_more_1_act: my is NULL\n"); return 0; } if (player == NULL) return 0; op = get_option(); if (op == NULL) { fprintf(stderr, "plan_0_more_1_act: get_option failed\n"); return 1; } (my->count[1])++; /* hide the stat if the game is still on and * if the player is near it */ if ((player != NULL) && (get_ship() >= 0) && (player->x < (double) (WINDOW_WIDTH / 3)) && (player->y < 60.0)) { if (my->count[10] < 20) my->count[10] += 2; } else { if (my->count[10] > 0) my->count[10] -= 2; } if (my->count[0] == 0) my->count[10] = 20; switch (my->count[0]) { case 0: if (my->count[1] == 310) tenm_table_add(normal_enemy_new(181.4, -24.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 2, 1, /* move 0 */ 60, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 9999, 9999, 0, 0, 0, 0)); if ((my->count[1] == 750) || (my->count[1] == 765) || (my->count[1] == 780)) tenm_table_add(normal_enemy_new(-18.0, 284.5, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 3.6, 1.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 9999, 0, 0, 0, 0)); if ((my->count[1] == 697) || (my->count[1] == 712) || (my->count[1] == 727)) tenm_table_add(normal_enemy_new(102.0, -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 9999, 0, 0, 0, 0)); if (my->count[1] == 950) { tenm_table_add(normal_enemy_new(321.4, -24.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 2, 3, /* move 0 */ 60, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 800, 9999, 0, 0, 0, 1, /* shoot 1 */ 60, 9999, 0, 0, 1, 2, /* shoot 2 */ 60, 9999, 0, 0, 0, 1)); tenm_table_add(normal_enemy_new(181.4, -24.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 2, 3, /* move 0 */ 60, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 800, 9999, 9909, 0, 0, 1, /* shoot 1 */ 60, 9999, 0, 0, 0, 2, /* shoot 2 */ 60, 9999, 0, 0, 1, 1)); tenm_table_add(normal_enemy_new(41.4, -24.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 2, 3, /* move 0 */ 60, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 800, 9999, 0, 0, 0, 1, /* shoot 1 */ 60, 9999, 0, 0, 1, 2, /* shoot 2 */ 60, 9999, 0, 0, 0, 1)); } if ((my->count[1] >= 1350) && (my->count[1] < 1410) && ((my->count[1] - 1350) % 3 == 0)) { speed = 3.0 + ((double) (my->count[1] - 1350)) * 0.1; x = (double) (WINDOW_WIDTH / 2 + (my->count[1] - 1350) * 4); tenm_table_add(laser_point_new(x, 0.0, speed, player->x - 10.0, player->y, 25.0, 1)); x = (double) (WINDOW_WIDTH / 2 - (my->count[1] - 1350) * 4); tenm_table_add(laser_point_new(x, 0.0, speed, player->x + 10.0, player->y, 25.0, 1)); x = (double) (WINDOW_WIDTH / 2 - 240 + (my->count[1] - 1350) * 8); tenm_table_add(laser_point_new(x, 0.0, speed + 2.0, player->x - 30.0, player->y, 25.0, 0)); x = (double) (WINDOW_WIDTH / 2 + 240 - (my->count[1] - 1350) * 8); tenm_table_add(laser_point_new(x, 0.0, speed + 2.0, player->x + 30.0, player->y, 25.0, 0)); } if (my->count[1] == 2810) tenm_table_add(wall_0_new(65.0)); if (my->count[1] >= 3030) { /* no set_stage_cleared() here */ set_this_stage_cleared(1); return 1; } break; case 1: if (my->count[1] == 0) { if ((dice_where == NULL) && (dice_what == NULL)) { dice_where = flatdice_new(3, 3, 5); dice_what = flatdice_new(45, 1, 1); errno = 0; if (atexit(&plan_0_more_1_quit) != 0) { fprintf(stderr, "plan_0_more_1_act: cannot register " "plan_0_more_1_quit to exit"); if (errno != 0) fprintf(stderr, " (%s)", strerror(errno)); fprintf(stderr, "\n"); } } else { if ((dice_where == NULL) || (dice_what == NULL)) { fprintf(stderr, "plan_0_more_1_act: some flatdice are missing\n"); return 1; } flatdice_reset(dice_where); flatdice_reset(dice_what); } } if (my->count[1] >= 130) { my->count[0] = 2; my->count[1] = -1; } break; case 2: if (my->count[5] >= 500) { my->count[0] = 3; my->count[1] = -1; return 0; } (my->count[2])--; if (my->count[2] < 0) { my->count[2] = 0; (my->count[3])--; if (my->count[3] < 0) my->count[3] = 0; (my->count[4])--; if (my->count[4] < 0) my->count[4] = 0; } for (i = 0; i < 3; i++) { (my->count[7 + i])--; if (my->count[7 + i] < 0) my->count[7 + i] = 0; } if ((my->count[2] <= 0) && (my->count[4] <= 0) && (my->count[6] < 500)) { if ((my->count[3] > 0) && (rand() % 100 < my->count[3])) { if (my->count[4] < my->count[3]) my->count[4] = my->count[3]; } else if ((my->count[6] >= 100) && (my->count[6] % 100 == 0) && (my->count[5] < my->count[6])) { /* do nothing */ ; } else { where = flatdice_next(dice_where); n = flatdice_next(dice_what); if (n < 0) { fprintf(stderr, "plan_0_more_1_act: flatdice_next(dice_what) " "failed\n"); } if (n < 5) what = 2; else if (n < 9) what = 3; else if (n < 33) what = 0; else what = 1; if (my->count[6] % 100 >= 97) { if (rand() % 3 != 0) what = 0; else what = 1; } if ((what >= 2) && (my->count[7 + where] > 0)) { if (rand() % 2 == 0) temp = 1; else temp = -1; for (i = 1; i <= 2; i++) { if (my->count[7 + (where + i * temp + 3) % 3] <= 0) { where = (where + i * temp + 3) % 3; break; } } if (my->count[7 + where] > 0) { if (rand() % 3 != 0) what = 0; else what = 1; } } switch (where) { case 0: x = 160.0; break; case 1: x = 320.0; break; case 2: x = 480.0; break; default: fprintf(stderr, "plan_0_more_1_act: undefined where (%d)\n", where); x = (double) (WINDOW_WIDTH / 2); break; } switch (what) { case 0: y = -19.0; x += (double) (-60 + rand() % 121); break; case 1: y = -24.0; x += (double) (-60 + rand() % 121); break; case 2: y = -35.0; x += (double) (-10 + rand() % 21); break; case 3: y = -47.0; x += (double) (-10 + rand() % 21); break; default: fprintf(stderr, "plan_0_more_1_act: strange what when deciding " "position (%d)\n", what); y = 240.0; break; } rank = my->count[6]; if (op->free_select != 0) { if (rank < 499) rank = 499; } tenm_table_add(tutor_new(what, x, y, my->table_index, rank)); switch (what) { case 0: my->count[2] = 37; my->count[3] += 6; my->count[6] += 1; break; case 1: my->count[2] = 29; my->count[3] += 3; my->count[6] += 1; break; case 2: my->count[2] = 40; my->count[3] += 20; my->count[6] += 3; break; case 3: my->count[2] = 42; my->count[3] += 28; my->count[6] += 3; break; default: fprintf(stderr, "plan_0_more_1_act: strange what when adding " "wait (%d)\n", what); break; } if (what >= 2) my->count[7 + where] += 100; if ((my->count[2] > 5) && (rand() % 3 != 0)) { temp = rand() % ((my->count[2] + 1) / 2); if (temp < 5) temp = 5; my->count[2] -= temp; my->count[3] += temp; } } } break; case 3: if (get_ship() < 0) return 1; if (my->count[1] == 0) { set_background(1); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy), 0); set_stage_cleared(get_stage_number(), 1); } if (my->count[1] >= 100) { if (get_ship() >= 0) { set_this_stage_cleared(1); } return 1; } break; default: break; } return 0; } static int plan_0_more_1_draw(tenm_object *my, int priority) { int status = 0; char temp[32]; /* sanity check */ if (my == NULL) { fprintf(stderr, "plan_0_more_1_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; if ((my->count[0] == 1) && (my->count[1] < 100)) { if (draw_string(257, 220, "OK, good luck!", 14) != 0) { fprintf(stderr, "plan_0_more_1_draw: draw_string (stage name) failed\n"); status = 1; } } if (my->count[0] >= 1) { sprintf(temp, "level %3d", my->count[5]); if (draw_string(10, 10 - my->count[10], temp, (int) strlen(temp)) != 0) { fprintf(stderr, "plan_0_more_1_draw: draw_string (level) failed\n"); return 1; } } if (my->count[0] >= 1) return status; /* the tutorial */ if ((my->count[1] >= 30) && (my->count[1] < 130)) { if (draw_string(253, 220, "dangen tutorial", 15) != 0) status = 1; } if ((my->count[1] >= 160) && (my->count[1] < 290)) { if (draw_string(330, 50, "Press cursor keys to move.", 26) != 0) status = 1; } if ((my->count[1] >= 340) && (my->count[1] < 600)) { if (draw_string(330, 50, "Use the space key to shoot.", 27) != 0) status = 1; } if ((my->count[1] >= 400) && (my->count[1] < 600)) { if (draw_string(330, 90, "No, just pressing the space key is", 34) != 0) status = 1; if (draw_string(330, 110, "_NOT_ enough to fire a shot.", 28) != 0) status = 1; } if ((my->count[1] >= 650) && (my->count[1] < 900)) { if (draw_string(330, 50, "To shoot, press a cursor key", 28) != 0) status = 1; if (draw_string(330, 70, "while pressing the space key.", 29) != 0) status = 1; if (draw_string(330, 90, "A shot is fired in the direction", 32) != 0) status = 1; if (draw_string(330, 110, "of that cursor key.", 19) != 0) status = 1; } if ((my->count[1] >= 960) && (my->count[1] < 1200)) { if (draw_string(330, 50, "Your ship is destroyed if it", 28) != 0) status = 1; if (draw_string(330, 70, "gets hit by something.", 22) != 0) status = 1; } if ((my->count[1] >= 1260) && (my->count[1] < 1670)) { if (draw_string(330, 50, "The circle at the center is", 27) != 0) status = 1; if (draw_string(330, 70, "the only weak point of your ship.", 33) != 0) status = 1; if (draw_string(330, 90, "The rest is safe.", 27) != 0) status = 1; } if ((my->count[1] >= 1730) && (my->count[1] < 2000)) { if (draw_string(330, 50, "Enemies are usually brown and", 29) != 0) status = 1; if (draw_string(330, 70, "sometimes change their color", 28) != 0) status = 1; if (draw_string(330, 90, "to green.", 9) != 0) status = 1; } if ((my->count[1] >= 2060) && (my->count[1] < 2500)) { if (draw_string(330, 50, "You can get an additional score", 31) != 0) status = 1; if (draw_string(330, 70, "by shooting enemies while they are", 34) != 0) status = 1; if (draw_string(330, 90, "green.", 6) != 0) status = 1; if (draw_string(330, 110, "This is called the chain bonus.", 31) != 0) status = 1; if (draw_string(330, 130, "(See the chain status at the", 28) != 0) status = 1; if (draw_string(330, 150, "upper right of the window.)", 27) != 0) status = 1; } if ((my->count[1] >= 2560) && (my->count[1] < 2760)) { if (draw_string(330, 50, "The number of chains is reset to", 32) != 0) status = 1; if (draw_string(330, 70, "zero if your shot misses.", 25) != 0) status = 1; } if ((my->count[1] >= 2820) && (my->count[1] < 2970)) { if (draw_string(330, 50, "You can't destroy a red enemy.", 30) != 0) status = 1; } return status; } dangen-0.5/spqr/plan-0.h0000644000175000017500000000036710276702741015657 0ustar00ooharaoohara00000000000000/* $Id: plan-0.h,v 1.4 2005/07/07 11:46:55 oohara Exp $ */ #ifndef __DANGEN_PLAN_0_H__ #define __DANGEN_PLAN_0_H__ #include "tenm_object.h" int plan_0(int t); int plan_0_more_1_easter_egg(tenm_object *my); #endif /* not __DANGEN_PLAN_0_H__ */ dangen-0.5/spqr/plan-1.c0000644000175000017500000000077610276702741015657 0ustar00ooharaoohara00000000000000/* $Id: plan-1.c,v 1.4 2004/08/17 15:08:11 oohara Exp $ */ /* [hardest] L */ #include #include "scheduler.h" #include "tenm_table.h" #include "last-boss.h" #include "warning.h" #include "stage-title.h" #include "plan-1.h" int plan_1(int t) { /* sanity check */ if (t < 0) return SCHEDULER_ERROR; if (t == 30) tenm_table_add(stage_title_new()); if (t == 160) tenm_table_add(warning_new()); if (t == 290) tenm_table_add(last_boss_new()); return SCHEDULER_SUCCESS; } dangen-0.5/spqr/plan-1.h0000644000175000017500000000025610276702741015655 0ustar00ooharaoohara00000000000000/* $Id: plan-1.h,v 1.1 2003/09/24 15:09:25 oohara Exp $ */ #ifndef __DANGEN_PLAN_1_H__ #define __DANGEN_PLAN_1_H__ int plan_1(int t); #endif /* not __DANGEN_PLAN_1_H__ */ dangen-0.5/spqr/plan-2.c0000644000175000017500000001257310276702741015656 0ustar00ooharaoohara00000000000000/* $Id: plan-2.c,v 1.42 2004/09/24 13:39:45 oohara Exp $ */ /* [very hard] Senators */ #include #include "scheduler.h" #include "tenm_table.h" #include "net-can-howl.h" #include "warning.h" #include "stage-title.h" #include "normal-enemy.h" #include "const.h" #include "plan-2.h" int plan_2(int t) { /* sanity check */ if (t < 0) return SCHEDULER_ERROR; if (t == 30) tenm_table_add(stage_title_new()); if ((t >= 160) && (t <= 508) && ((t - 160) % 29 == 0)) { if ((t - 160) % 58 < 29) tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) - 120.0, -24.0, SQUARE, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, -4.8, 3.6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 50, 13, 0, 45, 0, 1, /* shoot 0 */ 9999, 13, 11, 45, 1, 1)); else tenm_table_add(normal_enemy_new(120.0, -24.0, SQUARE, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 4.8, 3.6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 50, 13, (26 - t % 13) % 13, 135, 0, 1, /* shoot 1 */ 9999, 13, (76 - t % 13) % 13, 135, 1, 1)); #if 0 tenm_table_add(normal_enemy_new(520.0, -24.0, SQUARE, 0, 0, -1, 0, -1, 0, 3, 1, /* move 0 */ 44, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 209, 0.0, 0.0, 0.0, 0.0, 320.0, 240.0, 0.0, 0.15, 2, /* move 2 */ 9999, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 9999, 17, 0, (t * 3) % 360, 1, 0)); #endif /* 0 */ } if ((t >= 190) && (t < 566)) { switch ((t - 160) % 58) { case 30: tenm_table_add(normal_enemy_new(40.0, -14.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 50, (100 - t % 50) % 50, 0, 1, 0)); break; case 38: case 46: case 54: tenm_table_add(normal_enemy_new(40.0, -14.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 50, 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 9999, 0, 0, 1, 1)); break; case 1: tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) - 40.0, -14.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 50, (100 - t % 50) % 50, 0, 1, 0)); break; case 9: case 17: case 25: tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) - 40.0, -14.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 50, 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 9999, 0, 0, 1, 1)); break; default: break; } } if (t == 740) tenm_table_add(warning_new()); if (t == 870) tenm_table_add(net_can_howl_core_new()); return SCHEDULER_SUCCESS; } dangen-0.5/spqr/plan-2.h0000644000175000017500000000025610276702741015656 0ustar00ooharaoohara00000000000000/* $Id: plan-2.h,v 1.1 2003/09/24 16:37:46 oohara Exp $ */ #ifndef __DANGEN_PLAN_2_H__ #define __DANGEN_PLAN_2_H__ int plan_2(int t); #endif /* not __DANGEN_PLAN_2_H__ */ dangen-0.5/spqr/plan-3.c0000644000175000017500000003770610276702741015664 0ustar00ooharaoohara00000000000000/* $Id: plan-3.c,v 1.87 2004/12/12 17:15:29 oohara Exp $ */ /* [hard] Seiron */ #include /* malloc */ #include #include "scheduler.h" #include "tenm_table.h" #include "seiron.h" #include "warning.h" #include "stage-title.h" #include "normal-enemy.h" #include "const.h" #include "plan-3.h" static tenm_object *plan_3_more_1_new(void); static int plan_3_more_1_act(tenm_object *my, const tenm_object *player); int plan_3(int t) { int s; int what; int t_shoot; double x; double y; double c; /* sanity check */ if (t < 0) return SCHEDULER_ERROR; if (t == 30) tenm_table_add(stage_title_new()); if (t == 160) tenm_table_add(normal_enemy_new(128.0, -42.0, TRIANGLE, 0, 0, -1, 0, -1, 0, 2, 2, /* move 0 */ 15, 0.0, 4.0 + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, 0.0, 0.0 + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 15, 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 37, 36, 0, 1, 1)); if ((t >= 160) && (t < 240)) { s = t - 160; if ((s % 8 == 0) && (s % 40 < 24)) { if (s % 40 == 0) { what = BALL_CAPTAIN; t_shoot = 23; } else { what = BALL_SOLDIER; t_shoot = 9999; } x = ((double) WINDOW_WIDTH) + 19.0; y = -50.0 + 1.0 * ((double) s); if (s < 30) tenm_table_add(normal_enemy_new(x, y, what, 0, 20, -1, 0, -1, 0, 1, 3, /* move 0 */ 9999, -6.0, 2.5 + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 30 - s, t_shoot, 0, 0, 0, 1, /* shoot 1 */ 30, t_shoot, (30 - s) % t_shoot, 0, 1, 2, /* shoot 2 */ 9999, t_shoot, (60 - s) % t_shoot, 0, 0, 2)); else tenm_table_add(normal_enemy_new(x, y, what, 0, 20, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, -6.0, 2.5 + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 50 - s % 40, t_shoot, 0, 0, 0, 1, /* shoot 1 */ 9999, t_shoot, (50 - s % 40) % t_shoot, 0, 1, 1)); } } if (t == 310) tenm_table_add(normal_enemy_new(512.0, -42.0, TRIANGLE, 0, 0, -1, 0, -1, 0, 2, 2, /* move 0 */ 15, 0.0, 4.0 + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, 0.0, 0.0 + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 15, 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 37, 36, 0, 1, 1)); if ((t >= 310) && (t < 390)) { s = t - 310; if ((s % 8 == 0) && (s % 40 < 24)) { if (s % 40 == 0) { what = BALL_CAPTAIN; t_shoot = 23; } else { what = BALL_SOLDIER; t_shoot = 9999; } x = -19.0; y = 153.0 + 1.0 * ((double) s); if (s < 30) tenm_table_add(normal_enemy_new(x, y, what, 0, 20, -1, 0, -1, 0, 1, 3, /* move 0 */ 9999, 6.0, -2.5 + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 30 - s, t_shoot, 0, 0, 0, 1, /* shoot 1 */ 30, t_shoot, (30 - s) % t_shoot, 0, 1, 2, /* shoot 2 */ 9999, t_shoot, (60 - s) % t_shoot, 0, 0, 2)); else tenm_table_add(normal_enemy_new(x, y, what, 0, 20, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 6.0, -2.5 + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 50 - s % 40, t_shoot, 0, 0, 0, 1, /* shoot 1 */ 9999, t_shoot, (50 - s % 40) % t_shoot, 0, 1, 1)); } } if (t == 460) tenm_table_add(normal_enemy_new(320.0, -42.0, TRIANGLE, 0, 0, -1, 0, -1, 0, 2, 2, /* move 0 */ 15, 0.0, 4.0 + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, 0.0, 0.0 + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 15, 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 37, 36, 0, 1, 1)); if ((t >= 460) && (t < 620)) { s = t - 460; if ((s % 8 == 0) && (s % 40 < 24)) { if (s % 40 == 0) { what = BALL_CAPTAIN; t_shoot = 23; } else { what = BALL_SOLDIER; t_shoot = 9999; } if (s % 80 < 40) { x = -19.0; y = 20.0 + 1.0 * ((double) s); tenm_table_add(normal_enemy_new(x, y, what, 0, 73, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 0.0 + 1.0, 0.0, 0.0, 41.0, 123.9230 + 1.0 * ((double) s), 0.0, 0.25, 0, /* shoot 0 */ 9999, t_shoot, 0, 0, 1, 0)); } else { x = ((double) WINDOW_WIDTH) + 19.0; y = -100.0 + 1.0 * ((double) s); tenm_table_add(normal_enemy_new(x, y, what, 0, 73, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 0.0 + 1.0, 0.0, 0.0, ((double) WINDOW_WIDTH) - 41.0, 3.9230 + 1.0 * ((double) s), 0.0, -0.25, 0, /* shoot 0 */ 9999, t_shoot, 0, 0, 1, 0)); } } } if ((t >= 630) && (t < 710)) { s = t - 630; if (s % 8 == 0) { x = -19.0; y = 250.0 + 1.0 * ((double) s); tenm_table_add(normal_enemy_new(x, y, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 6.0, -2.5 + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 85 - s, 9999, 9999 - (85 - s), 0, 0, 1, /* shoot 1 */ 9999, 9999, 0, 0, 1, 1)); } } if (t == 705) tenm_table_add(normal_enemy_new(210.0, -42.0, TRIANGLE, 0, 0, -1, 0, -1, 0, 2, 2, /* move 0 */ 15, 0.0, 4.0 + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, 0.0, 0.0 + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 15, 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 37, 36, 0, 1, 1)); if (t == 796) tenm_table_add(normal_enemy_new(420.0, -42.0, TRIANGLE, 0, 0, -1, 0, -1, 0, 2, 2, /* move 0 */ 15, 0.0, 4.0 + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, 0.0, 0.0 + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 15, 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 37, 36, 0, 1, 1)); if ((t >= 756) && (t < 836)) { s = t - 756; if (s % 8 == 0) { x = -19.0; y = 69 + 1.0 * ((double) s); t_shoot = 43; tenm_table_add(normal_enemy_new(x, y, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 6.0, -2.5 + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 30, t_shoot, s % t_shoot, 0, 0, 1, /* shoot 1 */ 9999, t_shoot, (s + 30) % t_shoot, 0, 1, 1)); } } if ((t >= 1020) && (t < 1380)) { s = t - 1020; if ((s % 9 == 0) && ((s >= 90) || (s % 45 < 36))) { if (s < 90) { if (s < 45) { x = -19.0; c = -1.0; } else { x = ((double) WINDOW_WIDTH) + 19.0; c = 1.0; } if (s % 45 == 0) t_shoot = 13; else t_shoot = 9999; } else { if (s % 18 == 0) { x = -19.0; c = -1.0; } else { x = ((double) WINDOW_WIDTH) + 19.0; c = 1.0; } t_shoot = 43; } if (s % 45 == 0) what = BALL_CAPTAIN; else what = BALL_SOLDIER; y = 209.8075; tenm_table_add(normal_enemy_new(x, y, what, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 0.0, 0.0, 0.0, 320.0 + 189.0 * c, -50.0, 0.0, 0.16 * c, 0, /* shoot 0 */ 9999, t_shoot, s % t_shoot, 0, 1, 0)); } } if (t == 1480) tenm_table_add(plan_3_more_1_new()); return SCHEDULER_SUCCESS; } static tenm_object * plan_3_more_1_new(void) { tenm_object *new = NULL; int *count = NULL; count = (int *) malloc(sizeof(int) * 3); if (count == NULL) { fprintf(stderr, "plan_3_more_1_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] mode * [1] timer * [2] number of enemies killed */ count[0] = 0; count[1] = -1; count[2] = 0; new = tenm_object_new("plan 3 more 1", 0, 0, 1, 0.0, 0.0, 3, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&plan_3_more_1_act), (int (*)(tenm_object *, int)) NULL); if (new == NULL) { fprintf(stderr, "plan_3_more_1_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int plan_3_more_1_act(tenm_object *my, const tenm_object *player) { /* sanity check */ if (my == NULL) { fprintf(stderr, "plan_3_more_1_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[1])++; if (my->count[0] == 0) { if (my->count[1] == 0) { tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) + 49.0, 300.0, TRIANGLE, 0, 0, my->table_index, 2, -1, 0, 1, 1, /* move 0 */ 9999, -3.6, -1.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 17, 0, 0, 1, 0)); } if (my->count[1] == 30) { tenm_table_add(normal_enemy_new(-49.0, 300.0, TRIANGLE, 0, 0, my->table_index, 2, -1, 0, 1, 1, /* move 0 */ 9999, 3.6, -1.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 17, 0, 0, 1, 0)); } if ((my->count[1] <= 160) && (my->count[2] >= 2)) { my->count[0] = 1; my->count[1] = -1; } else if (my->count[1] >= 370) { my->count[0] = 2; my->count[1] = -1; } } else if (my->count[0] == 1) { if ((my->count[1] >= 30) && (my->count[1] < 110) && (my->count[1] % 8 == 0)) { tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) + 19.0, 300.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, -6.0, -2.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 9999, 0, 0, 1, 0)); tenm_table_add(normal_enemy_new(-19.0, 300.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 6.0, -2.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 9999, 0, 0, 1, 0)); } if (my->count[1] >= 260) { my->count[0] = 2; my->count[1] = -1; } } else if (my->count[0] == 2) { if (my->count[1] == 0) tenm_table_add(warning_new()); if (my->count[1] == 130) { tenm_table_add(seiron_new()); return 1; } } return 0; } dangen-0.5/spqr/plan-3.h0000644000175000017500000000025610276702741015657 0ustar00ooharaoohara00000000000000/* $Id: plan-3.h,v 1.1 2003/09/25 03:48:26 oohara Exp $ */ #ifndef __DANGEN_PLAN_3_H__ #define __DANGEN_PLAN_3_H__ int plan_3(int t); #endif /* not __DANGEN_PLAN_3_H__ */ dangen-0.5/spqr/plan-4.c0000644000175000017500000002730110276702741015653 0ustar00ooharaoohara00000000000000/* $Id: plan-4.c,v 1.58 2005/06/22 16:10:12 oohara Exp $ */ /* [easy] Seiron Fake */ #include #include "scheduler.h" #include "tenm_table.h" #include "seiron-fake.h" #include "warning.h" #include "stage-title.h" #include "wall-4.h" #include "const.h" #include "normal-enemy.h" #include "plan-4.h" int plan_4(int t) { int i; int t_shoot; /* sanity check */ if (t < 0) return SCHEDULER_ERROR; if (t == 30) tenm_table_add(stage_title_new()); if (t == 160) { for (i = 0; i < 3; i++) tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) - 140.0 - 120.0 * ((double) i), -24.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 3, 1, /* move 0 */ 208 + 30 * i, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 30, 0.0, -5.0 + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 9999, 51, i * 17, 0, 1, 0)); } if (t == 165) { for (i = 0; i < 4; i++) tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) - 80.0 - 120.0 * ((double) i), -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 208, 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 9999, 0, 0, 1, 1)); } if (t == 225) { tenm_table_add(wall_4_new(150.0, -29.0, 4.0, 100, 0)); tenm_table_add(wall_4_new(90.0, -29.0, 0.0, -1, 0)); tenm_table_add(wall_4_new(((double) WINDOW_WIDTH) - 30.0, -29.0, 0.0, -1, 0)); } if ((t >= 360) && (t < 408) && ((t - 360) % 8 == 0)) { if ((t - 360) % 24 == 0) t_shoot = 41; else t_shoot = 9999; tenm_table_add(normal_enemy_new(322.0, -481.0 + ((double) (t - 225)) * 1.0, BALL_SOLDIER, 0, 97, -1, 0, -1, 0, 2, 2, /* move 0 */ 73, -4.0, 4.0 + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, 0.0, 5.657 + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 73, t_shoot, 0, 0, 0, 1, /* shoot 1 */ 9999, t_shoot, 73 % t_shoot, 0, 1, 1)); } if ((t >= 535) && (t < 583) && ((t - 535) % 8 == 0)) { if ((t - 535) % 24 == 0) t_shoot = 9958; else t_shoot = 9999; tenm_table_add(normal_enemy_new(318.0, -481.0 + ((double) (t - 225)) * 1.0, BALL_SOLDIER, ENEMY_TYPE_WEAK, 97, -1, 0, -1, 0, 2, 2, /* move 0 */ 73, 4.0, 4.0 + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, 0.0, 5.657 + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 73, 9999, t_shoot, 0, 0, 1, /* shoot 1 */ 9999, 9999, 0, 0, 1, 1)); } if (t == 545) { tenm_table_add(wall_4_new(90.0, -29.0, 4.0, 100, 0)); tenm_table_add(wall_4_new(30.0, -29.0, 0.0, -1, 0)); tenm_table_add(wall_4_new(((double) WINDOW_WIDTH) - 90.0, -29.0, 0.0, -1, 0)); } if (t == 640) { tenm_table_add(normal_enemy_new(200.0, -24.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 340, 88, 22, 0, 0, 1, /* shoot 1 */ 9999, 88, (340 + 22) % 88, 0, 1, 1)); tenm_table_add(normal_enemy_new(320.0, -24.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 340, 88, 11, 0, 0, 1, /* shoot 1 */ 9999, 88, (340 + 11) % 88, 0, 1, 1)); tenm_table_add(normal_enemy_new(440.0, -24.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 340, 88, 0, 0, 0, 1, /* shoot 1 */ 9999, 88, 340 % 88, 0, 1, 1)); } if (t == 760) { tenm_table_add(normal_enemy_new(200.0, -24.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 190, 88, (33 + 120) % 88, 0, 0, 1, /* shoot 1 */ 9999, 88, (190 + 33 + 120) % 88, 0, 1, 1)); tenm_table_add(normal_enemy_new(440.0, -24.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 190, 88, (77 + 120) % 88, 0, 0, 1, /* shoot 1 */ 9999, 88, (190 + 77 + 120) % 88, 0, 1, 1)); } if (t == 880) { tenm_table_add(normal_enemy_new(200.0, -24.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 100, 88, (44 + 240) % 88, 0, 1, 1, /* shoot 1 */ 9999, 88, (100 + 44 + 240) % 88, 0, 0, 1)); tenm_table_add(normal_enemy_new(320.0, -24.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 100, 88, (55 + 240) % 88, 0, 1, 1, /* shoot 1 */ 9999, 88, (100 + 55 + 240) % 88, 0, 0, 1)); tenm_table_add(normal_enemy_new(440.0, -24.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 100, 88, (66 + 240) % 88, 0, 1, 1, /* shoot 1 */ 9999, 88, (100 + 66 + 240) % 88, 0, 0, 1)); } if (t == 770) tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) - 30.0, -24.0, SQUARE, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 0.0, 4.0 + 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 79, 23, 13, 157, 1, 1, /* shoot 1 */ 9999, 9999, 0, 157, 1, 1)); if (t == 975) { tenm_table_add(wall_4_new(30.0, -29.0, 4.0, 145, 0)); } if (t == 1035) { tenm_table_add(wall_4_new(30.0, -29.0, 4.0, 65, 0)); tenm_table_add(wall_4_new(((double) WINDOW_WIDTH) - 30.0, -29.0, -4.0, 65, 0)); } if ((t >= 1045) && (t < 1173) && ((t - 1045) % 8 == 0)) { if ((t - 1045) % 32 == 0) t_shoot = 19; else t_shoot = 9999; tenm_table_add(normal_enemy_new(-19.0, -29.0 + ((double) (t - 975)) * 1.0, BALL_SOLDIER, ENEMY_TYPE_WEAK, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 6.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 30, t_shoot, 0, 0, 0, 1, /* shoot 1 */ 9999, t_shoot, 30 % t_shoot, 0, 1, 1)); } if ((t >= 1213) && (t < 1341) && ((t - 1213) % 8 == 0)) { if ((t - 1213) % 32 == 0) t_shoot = 19; else t_shoot = 9999; tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) + 19.0, -29.0 + ((double) (t - 975)) * 1.0, BALL_SOLDIER, ENEMY_TYPE_WEAK, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, -6.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 30, t_shoot, 0, 0, 0, 1, /* shoot 1 */ 9999, t_shoot, 30 % t_shoot, 0, 1, 1)); } if (t == 1600) tenm_table_add(warning_new()); if (t == 1730) tenm_table_add(seiron_fake_new()); return SCHEDULER_SUCCESS; } dangen-0.5/spqr/plan-4.h0000644000175000017500000000025610276702741015660 0ustar00ooharaoohara00000000000000/* $Id: plan-4.h,v 1.1 2003/09/25 03:49:47 oohara Exp $ */ #ifndef __DANGEN_PLAN_4_H__ #define __DANGEN_PLAN_4_H__ int plan_4(int t); #endif /* not __DANGEN_PLAN_4_H__ */ dangen-0.5/spqr/plan-5.c0000644000175000017500000000114010276702741015645 0ustar00ooharaoohara00000000000000/* $Id: plan-5.c,v 1.55 2004/09/06 21:19:45 oohara Exp $ */ /* [very hard] Perpeki */ #include #include "scheduler.h" #include "tenm_table.h" #include "perpeki.h" #include "negation-engine.h" #include "warning.h" #include "stage-title.h" #include "plan-5.h" int plan_5(int t) { /* sanity check */ if (t < 0) return SCHEDULER_ERROR; if (t == 30) tenm_table_add(stage_title_new()); if (t == 160) tenm_table_add(negation_engine_new()); if (t == 10960) tenm_table_add(warning_new()); if (t == 11090) tenm_table_add(perpeki_new()); return SCHEDULER_SUCCESS; } dangen-0.5/spqr/plan-5.h0000644000175000017500000000025610276702741015661 0ustar00ooharaoohara00000000000000/* $Id: plan-5.h,v 1.1 2003/10/08 17:41:15 oohara Exp $ */ #ifndef __DANGEN_PLAN_5_H__ #define __DANGEN_PLAN_5_H__ int plan_5(int t); #endif /* not __DANGEN_PLAN_5_H__ */ dangen-0.5/spqr/plan-6.c0000644000175000017500000001311110276702741015647 0ustar00ooharaoohara00000000000000/* $Id: plan-6.c,v 1.74 2004/10/03 21:56:48 oohara Exp $ */ /* [very hard] Empty Wind */ #include /* malloc */ #include #include "scheduler.h" #include "tenm_table.h" #include "empty-wind.h" #include "warning.h" #include "stage-title.h" #include "normal-enemy.h" #include "tenm_math.h" #include "const.h" #include "respiration.h" #include "tenm_object.h" #include "plan-6.h" static tenm_object *plan_6_more_1_new(void); static int plan_6_more_1_act(tenm_object *my, const tenm_object *player); int plan_6(int t) { double x; double y; double dx; double dy; double ddx; double ddy; int n; /* sanity check */ if (t < 0) return SCHEDULER_ERROR; if (t == 30) tenm_table_add(stage_title_new()); if ((((t >= 160) && (t < 864)) || ((t >= 952) && (t < 1654))) && ((t - 160) % 11 == 0)) { if ((t - 160) % 176 < 44) n = 0; else if ((t - 160) % 176 < 88) n = 1; else if ((t - 160) % 176 < 132) n = 2; else n = 3; if (t >= 952) n = (8 - n) % 4; switch (n) { case 0: x = -19.0; y = 120.0; dx = 8.0; dy = 6.0; ddx = -0.06; ddy = -0.06; break; case 1: x = ((double) (WINDOW_WIDTH)) + 19.0; y = 120.0; dx = -8.0; dy = 6.0; ddx = 0.06; ddy = -0.06; break; case 2: x = ((double) (WINDOW_WIDTH)) + 19.0; y = ((double) (WINDOW_HEIGHT)) - 120.0; dx = -8.0; dy = -6.0; ddx = 0.06; ddy = 0.06; break; case 3: x = -19.0; y = ((double) (WINDOW_HEIGHT)) - 120.0; dx = 8.0; dy = -6.0; ddx = -0.06; ddy = 0.06; break; default: fprintf(stderr, "plan_6: undefined n (%d) (t = %d)\n", n, t); x = -19.0; y = 120.0; dx = 8.0; dy = 6.0; ddx = -0.06; ddy = -0.06; break; } tenm_table_add(normal_enemy_new(x, y, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, dx, dy, ddx, ddy, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 150, 120, 120 - t % 120, 0, 0, 1, /* shoot 1 */ 9999, 120, (270 - t % 120) % 120, 0, 1, 1)); } if (t == 1840) tenm_table_add(plan_6_more_1_new()); return SCHEDULER_SUCCESS; } static tenm_object * plan_6_more_1_new(void) { tenm_object *new = NULL; int *count = NULL; count = (int *) malloc(sizeof(int) * 2); if (count == NULL) { fprintf(stderr, "plan_6_more_1_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] timer * [1] "Respiration is dead" flag */ count[0] = -1; count[1] = -1; new = tenm_object_new("plan 6 more 1", 0, 0, 1, 0.0, 0.0, 2, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&plan_6_more_1_act), (int (*)(tenm_object *, int)) NULL); if (new == NULL) { fprintf(stderr, "plan_6_more_1_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int plan_6_more_1_act(tenm_object *my, const tenm_object *player) { int t; /* sanity check */ if (my == NULL) { fprintf(stderr, "plan_6_more_1_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[0])++; if (my->count[0] == 0) { tenm_table_add(respiration_new(my->table_index)); } if ((my->count[1] >= 0) && (my->count[0] < 1080)) { t = my->count[0] - my->count[1]; if ((t > 0) && (t % 11 == 0)) tenm_table_add(normal_enemy_new(-8.0, -8.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 3, 2, /* move 0 */ 18, 6.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 30, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 6.0, 6.0, 0.1 * tenm_cos(t * 2), 0.1 * tenm_sin(t * 2), 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 76, 25, -48 - t % 25, 0, 0, 1, /* shoot 1 */ 9999, 25, (3 + 25 - t % 25) % 25, 0, 1, 1)); } if (((my->count[1] >= 0) && (my->count[0] == 1300)) || ((my->count[1] < 0) && (my->count[0] == 1400))) tenm_table_add(warning_new()); if (((my->count[1] >= 0) && (my->count[0] == 1430)) || ((my->count[1] < 0) && (my->count[0] == 1530))) tenm_table_add(empty_wind_new()); return 0; } dangen-0.5/spqr/plan-6.h0000644000175000017500000000025610276702741015662 0ustar00ooharaoohara00000000000000/* $Id: plan-6.h,v 1.1 2003/10/25 09:30:44 oohara Exp $ */ #ifndef __DANGEN_PLAN_6_H__ #define __DANGEN_PLAN_6_H__ int plan_6(int t); #endif /* not __DANGEN_PLAN_6_H__ */ dangen-0.5/spqr/plan-7.c0000644000175000017500000003070210276702741015655 0ustar00ooharaoohara00000000000000/* $Id: plan-7.c,v 1.96 2004/12/01 12:55:27 oohara Exp $ */ /* [hard] cat tail (grep mix) */ #include /* malloc */ #include #include "scheduler.h" #include "tenm_table.h" #include "cat-tail-grep.h" #include "warning.h" #include "stage-title.h" #include "normal-enemy.h" #include "const.h" #include "tenm_math.h" #include "plan-7.h" static tenm_object *plan_7_more_1_new(void); static int plan_7_more_1_act(tenm_object *my, const tenm_object *player); int plan_7(int t) { int i; int s; double x; double c; /* sanity check */ if (t < 0) return SCHEDULER_ERROR; if (t == 30) tenm_table_add(stage_title_new()); if (t == 160) { for (i = 0; i < 5; i++) tenm_table_add(normal_enemy_new(120.0 + 100.0 * ((double) i), -23.0, BRICK, 0, 0, -1, 0, -1, 0, 3, 1, /* move 0 */ 34, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 96, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 1 */ 9999, 10, (i * 6) % 10, 50, 1, 0)); } if ((t >= 250) && (t < 850)) { s = t - 250; if ((s % 10 == 0) && (s % 60 < 30)) { if (s % 120 < 60) { x = ((double) (WINDOW_WIDTH)) + 13.0; c = 1.0; } else { x = -13.0; c = -1.0; } tenm_table_add(normal_enemy_new(x, -13.0, BALL_SOLDIER, 0, 150, -1, 0, -1, 0, 3, 3, /* move 0 */ 30, -0.8 * c, 5.6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 60, -5.6 * c, -0.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 60, -0.8 * c, 5.6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 29, 9999, 0, 0, 0, 1, /* shoot 1 */ 60, 30, 29, 0, 1, 2, /* shoot 2 */ 60, 30, 29, 0, 0, 1)); tenm_table_add(normal_enemy_new(x, -13.0, BALL_SOLDIER, 0, 150, -1, 0, -1, 0, 3, 3, /* move 0 */ 30, -5.6 * c, -0.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 60, -0.8 * c, 5.6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 60, -5.6 * c, -0.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 29, 9999, 0, 0, 1, 1, /* shoot 1 */ 60, 30, 29, 0, 0, 2, /* shoot 2 */ 60, 30, 29, 0, 1, 1)); } } if (t == 1050) tenm_table_add(plan_7_more_1_new()); return SCHEDULER_SUCCESS; } static tenm_object * plan_7_more_1_new(void) { tenm_object *new = NULL; int *count = NULL; count = (int *) malloc(sizeof(int) * 3); if (count == NULL) { fprintf(stderr, "plan_7_more_1_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] mode * [1] timer * [2] number of enemies killed / escaped */ count[0] = 0; count[1] = -1; count[2] = 0; new = tenm_object_new("plan 7 more 1", 0, 0, 1, 0.0, 0.0, 3, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&plan_7_more_1_act), (int (*)(tenm_object *, int)) NULL); if (new == NULL) { fprintf(stderr, "plan_7_more_1_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int plan_7_more_1_act(tenm_object *my, const tenm_object *player) { int i; /* sanity check */ if (my == NULL) { fprintf(stderr, "plan_7_more_1_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[1])++; if ((my->count[0] == 0) && (my->count[1] == 0)) { for (i = -9; i <= 9; i += 2) { if ((i + 9) % 4 < 2) tenm_table_add(normal_enemy_new(32.0, -23.0, BRICK, 0, 0, my->table_index, 2, my->table_index, 2, 6, 10, /* move 0 */ 48, 0.0, 5.5 + 0.5 * ((double) i), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 144, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 48, 0.0, -1.0 - 1.0 * ((double) i), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3, /* move 3 */ 96, -6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4, /* move 4 */ 48, 0.0, 1.0 + 1.0 * ((double) i), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5, /* move 5 */ 9999, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5, /* shoot 0 */ 48, 100, 5 * i, 0, 0, 1, /* shoot 1 */ 46, 100, (5 * i + 48) % 100, 0, 1, 2, /* shoot 2 */ 24, 100, (5 * i + 94) % 100, 0, 0, 3, /* shoot 3 */ 74, 100, (5 * i + 118) % 100, 0, 1, 4, /* shoot 4 */ 48, 100, (5 * i + 192) % 100, 0, 0, 5, /* shoot 5 */ 20, 100, (5 * i + 240) % 100, 0, 1, 6, /* shoot 6 */ 16, 100, (5 * i + 260) % 100, 0, 0, 7, /* shoot 7 */ 60, 100, (5 * i + 276) % 100, 0, 1, 8, /* shoot 8 */ 48, 100, (5 * i + 336) % 100, 0, 0, 9, /* shoot 9 */ 9999, 100, (5 * i + 384) % 100, 0, 1, 9)); else tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) - 32.0, -23.0, BRICK, 0, 0, my->table_index, 2, my->table_index, 2, 6, 10, /* move 0 */ 48, 0.0, 5.5 + 0.5 * ((double) i), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 96, -6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 48, 0.0, 1.0 - 1.0 * ((double) i), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3, /* move 3 */ 144, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4, /* move 4 */ 48, 0.0, -1.0 + 1.0 * ((double) i), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5, /* move 5 */ 9999, -6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5, /* shoot 0 */ 48, 100, 5 * i, 0, 0, 1, /* shoot 1 */ 50, 100, (5 * i + 48) % 100, 0, 1, 2, /* shoot 2 */ 16, 100, (5 * i + 98) % 100, 0, 0, 3, /* shoot 3 */ 30, 100, (5 * i + 114) % 100, 0, 1, 4, /* shoot 4 */ 48, 100, (5 * i + 144) % 100, 0, 0, 5, /* shoot 5 */ 64, 100, (5 * i + 192) % 100, 0, 1, 6, /* shoot 6 */ 24, 100, (5 * i + 256) % 100, 0, 0, 7, /* shoot 7 */ 56, 100, (5 * i + 280) % 100, 0, 1, 8, /* shoot 8 */ 48, 100, (5 * i + 336) % 100, 0, 0, 9, /* shoot 9 */ 9999, 100, (5 * i + 384) % 100, 0, 1, 9)); } } if ((my->count[0] == 0) && ((my->count[2] >= 10) || (my->count[1] >= 9999))) { my->count[0] = 1; my->count[1] = 0; } if (my->count[0] == 1) { if (my->count[1] == 100) tenm_table_add(warning_new()); if (my->count[1] == 230) { tenm_table_add(cat_tail_grep_new()); return 1; } } return 0; } dangen-0.5/spqr/plan-7.h0000644000175000017500000000025610276702741015663 0ustar00ooharaoohara00000000000000/* $Id: plan-7.h,v 1.1 2004/01/20 10:25:58 oohara Exp $ */ #ifndef __DANGEN_PLAN_7_H__ #define __DANGEN_PLAN_7_H__ int plan_7(int t); #endif /* not __DANGEN_PLAN_7_H__ */ dangen-0.5/spqr/plan-8.c0000644000175000017500000010003510276702741015653 0ustar00ooharaoohara00000000000000/* $Id: plan-8.c,v 1.224 2005/01/17 12:38:58 oohara Exp $ */ /* [hard] Silver Chimera */ #include /* malloc */ #include #include "scheduler.h" #include "tenm_table.h" #include "stage-title.h" #include "normal-enemy.h" #include "wall-8.h" #include "const.h" #include "tenm_math.h" #include "tenm_object.h" #include "mankanshoku.h" #include "plan-8.h" static tenm_object *plan_8_more_1_new(void); static int plan_8_more_1_act(tenm_object *my, const tenm_object *player); int plan_8(int t) { int s; int what; int temp1; int temp2; int t_shoot; int i; double x; /* sanity check */ if (t < 0) return SCHEDULER_ERROR; if (t == 30) tenm_table_add(stage_title_new()); if ((t >= 160) && (t < 2458) && ((t - 160) % 24 == 0)) { tenm_table_add(wall_8_new(30.0, -29.0, 0, t)); tenm_table_add(wall_8_new(((double) WINDOW_WIDTH) - 30.0, -29.0, 0, t)); } if (t == 2458) { for (i = 0; i < 4; i++) { tenm_table_add(wall_8_new(30.0, -74.0 - ((double) i) * 180.0, 0, t)); tenm_table_add(wall_8_new(((double) WINDOW_WIDTH) - 30.0, -74.0 - ((double) i) * 180.0, 0, t)); } } if (((t >= 224) && (t <= 236)) || ((t >= 249) && (t <= 261)) || ((t >= 274) && (t <= 286)) || ((t >= 299) && (t <= 311)) || ((t >= 324) && (t <= 336))) { if (t <= 236) { s = t - 224; x = 135.0; } else if (t <= 261) { s = t - 249; x = 320.0; } else if (t <= 286) { s = t - 274; x = 505.0; } else if (t <= 311) { s = t - 299; x = 228.0; } else { s = t - 324; x = 412.0; } if ((s == 0) || (s == 12)) { tenm_table_add(normal_enemy_new(x - 45.0, -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 7.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 9999, 0, 0, 1, 0)); tenm_table_add(normal_enemy_new(x + 45.0, -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 7.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 9999, 0, 0, 1, 0)); } if (s == 6) { tenm_table_add(normal_enemy_new(x, -19.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 7.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 9999, 0, 0, 1, 0)); } } if (t == 408) tenm_table_add(plan_8_more_1_new()); if ((t >= 584) && (t < 744)) { s = t - 584; if ((s % 8 == 0) && (s % 40 != 32)) { if ((s == 0) || (s == 40) || (s == 80) || (s == 120)) { what = BRICK; t_shoot = 31; } else { what = BALL_SOLDIER; t_shoot = 9999; } if (s < 40) { temp1 = 29; temp2 = 35; } else if (s < 80) { temp1 = 79; temp2 = 9999; } else if (s < 120) { temp1 = 179; temp2 = 9999; } else { temp1 = 129; temp2 = 35; } tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) - 472.8, -19.6153, what, 0, 0, -1, 0, -1, 0, 3, 3, /* move 0 */ 29, 7.2, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ /* ./rotate.py 400 376 67.3847 * 299.0769 252.0 0 0.195 */ 191, 0.0, 0.0, 0.0, 0.0, 299.0769, 252.0, 0.0, 0.195, 2, /* move 2 */ 9999, 0.0, 7.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ temp1, t_shoot, (62 - s % 31) % 31, 0, 0, 1, /* shoot 1 */ temp2, t_shoot, (temp1 + 62 - s % 31) % 31, 0, 1, 2, /* shoot 2 */ 9999, 9999, 0, 0, 0, 2)); } } if (t == 680) { tenm_table_add(normal_enemy_new(60.0, -29.0, BALL_CAPTAIN, 0, 2, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 7.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 7, 0, 0, 1, 0)); } if (t == 776) { tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) - 60.0, -29.0, BALL_CAPTAIN, 0, 2, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 7.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 7, 0, 0, 1, 0)); } if ((t >= 1000) && (t < 1750)) { s = t - 1000; if ((s % 75 == 0) && (s < 750)) { temp1 = rand() % 2; tenm_table_add(normal_enemy_new(164.0, -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 0.0, 7.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 22 + (temp1 % 2) * 21, 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 9999, 0, 0, 1, 1)); tenm_table_add(normal_enemy_new(190.0, -19.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 0.0, 7.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 22 + (temp1 % 2) * 21, 9999, 9967 * (temp1 % 2), 0, 0, 1, /* shoot 1 */ 9999, 9999, 0, 0, 1, 1)); tenm_table_add(normal_enemy_new(320.0, -19.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 7.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 9999, 0, 0, 1, 0)); tenm_table_add(normal_enemy_new(450.0, -19.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 0.0, 7.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 22 + ((temp1 + 1) % 2) * 21, 9999, 9967 * ((temp1 + 1) % 2), 0, 0, 1, /* shoot 1 */ 9999, 9999, 0, 0, 1, 1)); tenm_table_add(normal_enemy_new(476.0, -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 0.0, 7.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 22 + ((temp1 + 1) % 2) * 21, 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 9999, 0, 0, 1, 1)); } if (s == 150) tenm_table_add(normal_enemy_new(112.0, -24.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 2, 2, /* move 0 */ 600, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, 0.0, 0.5, 0.0, 0.2, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 600, 41, 0, 0, 0, 1, /* shoot 1 */ 9999, 41, 26, 0, 1, 1)); if (s == 300) tenm_table_add(normal_enemy_new(528.0, -24.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 2, 2, /* move 0 */ 475, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, 0.0, 0.5, 0.0, 0.2, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 475, 41, 6, 0, 0, 1, /* shoot 1 */ 9999, 41, 30, 0, 1, 1)); } if ((t >= 1904) && (t < 2192)) { s = t - 1904; if (s < 288) { if (s % 24 == 0) { what = 1 + rand() % 2; if (s < 96) { temp1 = rand() % 300; for (i = -2; i <= 4; i++) tenm_table_add(wall_8_new((double) (i * 300 + temp1), -29.0, what, t)); } else if (s < 192) { temp1 = rand() % 240; for (i = -3; i <= 4; i++) tenm_table_add(wall_8_new((double) (i * 240 + temp1), -29.0, what, t)); } else { temp1 = rand() % 180; for (i = -4; i <= 5; i++) tenm_table_add(wall_8_new((double) (i * 180 + temp1), -29.0, what, t)); } } if (s % 24 == 8) { tenm_table_add(wall_8_new(210.0, -29.0, 0, t)); /* tenm_table_add(wall_8_new(90.0 + ((double) (rand() % 2)) * 60.0, -29.0, 0, t)); */ } if (s % 24 == 16) { tenm_table_add(wall_8_new(210.0, -29.0, 0, t)); for (i = 0; i < 3; i++) { if (i == 1) temp1 = 17; else temp1 = 9999; tenm_table_add(normal_enemy_new(80.0 + ((double) i) * 40.0, -29.0, BALL_SOLDIER, 0, 2, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 7.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, temp1, 11, 0, 1, 0)); } } } } if ((t >= 2248) && (t < 2398)) { s = t - 2248; if ((s % 32 == 0) && (s < 96)) tenm_table_add(normal_enemy_new(300.0 + ((double) (s / 32)) * 100.0, -23.0, BRICK, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 8.0 + ((double) (s / 32)) * 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 11, 0, 0, 1, 0)); if (s == 96) { for (i = 0; i < 5; i++) tenm_table_add(wall_8_new(90.0 + ((double) i) * 60.0, -29.0, 3, t)); } if ((s % 12 == 0) && (s >= 108) && (s <= 132)) tenm_table_add(wall_8_new(330.0, -29.0, 3, t)); if ((s % 3 == 0) && (s >= 105) && (s < 150)) { tenm_table_add(normal_enemy_new(90.0, -19.0, BALL_SOLDIER, ENEMY_TYPE_WEAK, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 15.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 9999, 0, 0, 1, 0)); } } if (t == 2458) tenm_table_add(mankanshoku_new()); if (t >= 2543) { s = t - 2543; if (s == 0) { tenm_table_add(normal_enemy_new(210.0, -24.0, SQUARE, 0, 0, -1, 0, -1, 0, 4, 2, /* move 0 */ 14, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 933, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 75, 0.0, 0.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 3, /* move 3 */ 9999, 0.0, 7.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3, /* shoot 0 */ 947, 19, 0, 35, 1, 1, /* shoot 1 */ 9999, 9999, 0, 35, 0, 1)); tenm_table_add(normal_enemy_new(430.0, -24.0, SQUARE, 0, 0, -1, 0, -1, 0, 4, 2, /* move 0 */ 14, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 933, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 75, 0.0, 0.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 3, /* move 3 */ 9999, 0.0, 7.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3, /* shoot 0 */ 947, 19, 0, 145, 1, 1, /* shoot 1 */ 9999, 9999, 0, 145, 0, 1)); tenm_table_add(normal_enemy_new(-24.0, 150.0, SQUARE, 0, 0, -1, 0, -1, 0, 4, 2, /* move 0 */ 14, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 933, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 75, 0.0, 0.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 3, /* move 3 */ 9999, 0.0, 7.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3, /* shoot 0 */ 947, 19, 0, 57, 1, 1, /* shoot 1 */ 9999, 9999, 0, 57, 0, 1)); tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) + 24.0, 150.0, SQUARE, 0, 0, -1, 0, -1, 0, 4, 2, /* move 0 */ 14, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 933, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 75, 0.0, 0.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 3, /* move 3 */ 9999, 0.0, 7.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3, /* shoot 0 */ 947, 19, 0, 123, 1, 1, /* shoot 1 */ 9999, 9999, 0, 123, 0, 1)); } if ((s == 36) || (s == 48)) { temp1 = 83 - (s - 36); if (temp1 < 1) temp1 = 1; tenm_table_add(normal_enemy_new(555.0, -19.0, BALL_SOLDIER, ENEMY_TYPE_WEAK, 0, -1, 0, -1, 0, 2, 2, /* move 0 */ 58, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, -6.0, -4.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ temp1, 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 11, 0, 0, 1, 1)); } if ((s == 98) || (s == 110)) { temp1 = 91 - (s - 98); if (temp1 < 1) temp1 = 1; tenm_table_add(normal_enemy_new(85.0, -19.0, BALL_SOLDIER, ENEMY_TYPE_WEAK, 0, -1, 0, -1, 0, 2, 2, /* move 0 */ 58, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, 5.0, -4.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ temp1, 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 11, 0, 0, 1, 1)); } if ((s == 156) || (s == 168)) { temp1 = 103 - (s - 156); if (temp1 < 1) temp1 = 1; tenm_table_add(normal_enemy_new(555.0, -19.0, BALL_SOLDIER, ENEMY_TYPE_WEAK, 0, -1, 0, -1, 0, 2, 2, /* move 0 */ 58, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, -4.0, -4.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ temp1, 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 11, 0, 0, 1, 1)); } if ((s == 206) || (s == 218)) { temp1 = 123 - (s - 206); if (temp1 < 1) temp1 = 1; tenm_table_add(normal_enemy_new(85.0, -19.0, BALL_SOLDIER, ENEMY_TYPE_WEAK, 0, -1, 0, -1, 0, 2, 2, /* move 0 */ 58, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, 3.0, -4.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ temp1, 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 11, 0, 0, 1, 1)); } if ((s == 236) || (s == 248)) { temp1 = 163 - (s - 236); if (temp1 < 1) temp1 = 1; tenm_table_add(normal_enemy_new(555.0, -19.0, BALL_SOLDIER, ENEMY_TYPE_WEAK, 0, -1, 0, -1, 0, 2, 2, /* move 0 */ 58, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, -2.0, -4.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ temp1, 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 11, 0, 0, 1, 1)); } if ((s == 450) || (s == 458) || (s == 466) || (s == 474)) { if (s == 474) { temp1 = BALL_CAPTAIN; temp2 = 23; } else { temp1 = BALL_SOLDIER; temp2 = 9999; } tenm_table_add(normal_enemy_new(95.0, -19.0, temp1, 0, 0, -1, 0, -1, 0, 3, 2, /* move 0 */ 75 - (s - 450), 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ /* ./rotate.py 300 95.0 287.0 * 283.0 287.0 0.0 -0.16 */ 245, 0.0, 0.0, 0.0, 0.0, 139.0 + ((double) (s - 450)) * 6.0, 431.0 - ((double) (s - 450)) * 6.0, 0.0, -0.16, 2, /* move 2 */ 9999, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 296, temp2, 0, 0, 0, 1, /* shoot 1 */ 9999, temp2, 296 % temp2, 0, 1, 1)); } if ((s == 520) || (s == 528) || (s == 536) || (s == 544)) { if (s == 544) { temp1 = BALL_CAPTAIN; temp2 = 23; } else { temp1 = BALL_SOLDIER; temp2 = 9999; } tenm_table_add(normal_enemy_new(545.0, -19.0, temp1, 0, 0, -1, 0, -1, 0, 3, 2, /* move 0 */ 75 - (s - 520), 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 245, 0.0, 0.0, 0.0, 0.0, 501.0 - ((double) (s - 520)) * 6.0, 431.0 - ((double) (s - 520)) * 6.0, 0.0, 0.16, 2, /* move 2 */ 9999, -6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 296, temp2, 0, 0, 0, 1, /* shoot 1 */ 9999, temp2, 296 % temp2, 0, 1, 1)); } } return SCHEDULER_SUCCESS; } static tenm_object * plan_8_more_1_new(void) { tenm_object *new = NULL; int *count = NULL; count = (int *) malloc(sizeof(int) * 6); if (count == NULL) { fprintf(stderr, "plan_8_more_1_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] total timer * [1] number of normal enemies killed */ count[0] = -1; count[1] = 0; new = tenm_object_new("plan 8 more 1", 0, 0, 1, 0.0, 0.0, 6, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&plan_8_more_1_act), (int (*)(tenm_object *, int)) NULL); if (new == NULL) { fprintf(stderr, "plan_8_more_1_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int plan_8_more_1_act(tenm_object *my, const tenm_object *player) { int i; int j; /* sanity check */ if (my == NULL) { fprintf(stderr, "plan_8_more_1_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[0])++; if (my->count[0] == 0) { for (i = 15; i < 360; i += 30) { if ((i % 180 >= 75) && (i % 180 <= 105)) continue; for (j = 0; j < 360; j += 180) tenm_table_add(normal_enemy_new(320.0 + 130.0 * tenm_cos(35 + j) + 65.0 * tenm_cos(i), -225.0 + 130.0 * tenm_sin(35 + j) + 65.0 * tenm_sin(i), BALL_SOLDIER, 0, 56, my->table_index, 1, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 7.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 9999, 0, 0, 1, 0)); } for (j = 0; j < 360; j += 90) tenm_table_add(normal_enemy_new(320.0 + 130.0 * tenm_cos(15 + j), -225.0 + 130.0 * tenm_sin(15 + j), BALL_SOLDIER, 0, 56, my->table_index, 1, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 7.5, 0.0, 0.0, 320.0, -225.0, 0.0, -0.6, 0, /* shoot 0 */ 9999, 11, 0, 0, 1, 0)); } if ((my->count[0] == 120) && (my->count[1] < 20)) return 1; if (my->count[0] == 120) tenm_table_add(normal_enemy_new((double) (WINDOW_WIDTH / 2), -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 7.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 9999, 0, 0, 1, 0)); if ((my->count[0] == 132) || (my->count[0] == 138) || (my->count[0] == 144)) { tenm_table_add(normal_enemy_new(((double) (WINDOW_WIDTH / 2)) - 20.0, -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 7.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 9999, 0, 0, 1, 0)); tenm_table_add(normal_enemy_new(((double) (WINDOW_WIDTH / 2)) + 20.0, -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 7.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 9999, 0, 0, 1, 0)); } if (my->count[0] >= 144) return 1; return 0; } dangen-0.5/spqr/plan-8.h0000644000175000017500000000025610276702741015664 0ustar00ooharaoohara00000000000000/* $Id: plan-8.h,v 1.1 2004/04/14 09:09:30 oohara Exp $ */ #ifndef __DANGEN_PLAN_8_H__ #define __DANGEN_PLAN_8_H__ int plan_8(int t); #endif /* not __DANGEN_PLAN_8_H__ */ dangen-0.5/spqr/plan-9.c0000644000175000017500000001362510276702741015664 0ustar00ooharaoohara00000000000000/* $Id: plan-9.c,v 1.49 2004/11/28 07:36:00 oohara Exp $ */ /* [hard] 0x82da3104 */ #include /* malloc */ #include #include "scheduler.h" #include "tenm_table.h" #include "hatsuda.h" #include "warning.h" #include "stage-title.h" #include "tenmado.h" #include "const.h" #include "tenm_object.h" #include "normal-enemy.h" #include "plan-9.h" static tenm_object *plan_9_more_1_new(void); static int plan_9_more_1_act(tenm_object *my, const tenm_object *player); int plan_9(int t) { /* sanity check */ if (t < 0) return SCHEDULER_ERROR; if (t == 30) tenm_table_add(stage_title_new()); if (t == 160) tenm_table_add(plan_9_more_1_new()); return SCHEDULER_SUCCESS; } static tenm_object * plan_9_more_1_new(void) { tenm_object *new = NULL; int *count = NULL; count = (int *) malloc(sizeof(int) * 6); if (count == NULL) { fprintf(stderr, "plan_9_more_1_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] total timer * [1] number of tenmado created * [2] number of tenmado killed * [3] new enemy timer * [4] new enemy direction * [5] more end time */ count[0] = -1; count[1] = 0; count[2] = 0; count[3] = -1; count[4] = -1; count[5] = 1000; new = tenm_object_new("plan 9 more 1", 0, 0, 1, 0.0, 0.0, 6, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&plan_9_more_1_act), (int (*)(tenm_object *, int)) NULL); if (new == NULL) { fprintf(stderr, "plan_9_more_1_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int plan_9_more_1_act(tenm_object *my, const tenm_object *player) { double x; double dx; int t_shoot; int temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "plan_9_more_1_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[0])++; if ((my->count[4] < 0) && (my->count[0] < my->count[5] - 100) && (my->count[0] < 9999) && (((my->count[2] < 3) && (my->count[1] < my->count[2] + 1)) || ((my->count[2] >= 3) && (my->count[1] < my->count[2] + 2)))) { (my->count[1])++; my->count[3] = -1; if (player->x < ((double) (WINDOW_WIDTH / 2))) my->count[4] = 0; else my->count[4] = 1; if (my->count[1] <= 1) { temp = 0; } else { if (my->count[1] <= 4) temp = 68; else temp = 68 - (my->count[1] - 4) * 2; if (temp < 49) temp = 49; } my->count[5] += temp; } if (my->count[4] >= 0) { (my->count[3])++; if ((my->count[1] > 1) && (my->count[1] != 5) && (my->count[3] == 0)) { if (my->count[4] == 0) { x = ((double) WINDOW_WIDTH) - 44.0; } else { x = 44.0; } tenm_table_add(normal_enemy_new(x, -24.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 2, 2, /* move 0 */ 66, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, 0.0, 7.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 51, 17, 0, 0, 1, 1, /* shoot 1 */ 9999, 9, 0, 0, 1, 1)); } if ((my->count[1] > 1) && (my->count[1] != 5) && ((my->count[3] == 22) || (my->count[3] == 36) || (my->count[3] == 43) || (my->count[3] == 50))) { if (my->count[4] == 0) { x = ((double) WINDOW_WIDTH) - 50.0; } else { x = 50.0; } tenm_table_add(normal_enemy_new(x, -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 2, 2, /* move 0 */ 66 - my->count[3], 0.0, 7.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 0 */ 9999, 0.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 64 - my->count[3], 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 9999, 0, 0, 1, 1)); } if (((my->count[1] <= 1) && (my->count[3] == 0)) || ((my->count[1] > 1) && (my->count[3] == 50))) { if (my->count[4] == 0) { x = 0.0; dx = 6.0; } else { x = (double) WINDOW_WIDTH; dx = -6.0; } if (my->count[1] <= 4) t_shoot = 13; else t_shoot = 13 - (my->count[1] - 4); if (t_shoot < 7) t_shoot = 7; tenm_table_add(tenmado_new(x, -29.0, my->count[1] % 2, dx, my->count[5] - my->count[0], my->table_index, t_shoot)); my->count[3] = -1; my->count[4] = -1; } } if (my->count[0] == my->count[5] + 130) { tenm_table_add(warning_new()); } if (my->count[0] == my->count[5] + 260) { tenm_table_add(hatsuda_new()); return 1; } return 0; } dangen-0.5/spqr/plan-9.h0000644000175000017500000000025610276702741015665 0ustar00ooharaoohara00000000000000/* $Id: plan-9.h,v 1.1 2004/04/21 06:31:16 oohara Exp $ */ #ifndef __DANGEN_PLAN_9_H__ #define __DANGEN_PLAN_9_H__ int plan_9(int t); #endif /* not __DANGEN_PLAN_9_H__ */ dangen-0.5/spqr/plan-10.c0000644000175000017500000000067010276702741015730 0ustar00ooharaoohara00000000000000/* $Id: plan-10.c,v 1.6 2005/01/01 17:02:15 oohara Exp $ */ #include #include "scheduler.h" #include "tenm_table.h" #include "normal-enemy.h" #include "nexus.h" #include "stage-title.h" #include "plan-10.h" int plan_10(int t) { /* sanity check */ if (t < 0) return SCHEDULER_ERROR; if (t == 30) tenm_table_add(stage_title_new()); if (t == 160) tenm_table_add(nexus_new()); return SCHEDULER_SUCCESS; } dangen-0.5/spqr/plan-10.h0000644000175000017500000000026310276702741015733 0ustar00ooharaoohara00000000000000/* $Id: plan-10.h,v 1.1 2004/04/25 09:39:48 oohara Exp $ */ #ifndef __DANGEN_PLAN_10_H__ #define __DANGEN_PLAN_10_H__ int plan_10(int t); #endif /* not __DANGEN_PLAN_10_H__ */ dangen-0.5/spqr/plan-11.c0000644000175000017500000006734310276702741015743 0ustar00ooharaoohara00000000000000/* $Id: plan-11.c,v 1.117 2004/12/15 12:13:51 oohara Exp $ */ #include /* malloc */ #include #include "scheduler.h" #include "tenm_table.h" #include "theorem-weapon.h" #include "warning.h" #include "stage-title.h" #include "normal-enemy.h" #include "const.h" #include "tenm_math.h" #include "wall-11.h" #include "plan-11.h" static tenm_object *plan_11_more_1_new(int what); static int plan_11_more_1_act(tenm_object *my, const tenm_object *player); static tenm_object *plan_11_more_2_new(void); static int plan_11_more_2_act(tenm_object *my, const tenm_object *player); int plan_11(int t) { int s; int what; double x; /* sanity check */ if (t < 0) return SCHEDULER_ERROR; if (t == 30) tenm_table_add(stage_title_new()); if ((t >= 160) && (t <= 185)) { s = t - 160; if (s == 0) tenm_table_add(wall_11_new((double) (WINDOW_WIDTH / 2), -29.0, 7.0, 90, 7)); if (s == 25) { tenm_table_add(plan_11_more_1_new(0)); tenm_table_add(plan_11_more_1_new(1)); } if (s == 10) tenm_table_add(normal_enemy_new((double) (WINDOW_WIDTH / 2), -23.0, BRICK, ENEMY_TYPE_OBSTACLE, 0, -1, 0, -1, 0, 3, 1, /* move 0 */ 24, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 130, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 9999, 9999, 0, 0, 1, 0)); } if ((t >= 340) && (t <= 616)) { s = t - 340; if (s == 0) { tenm_table_add(normal_enemy_new((double) (WINDOW_WIDTH / 2), -23.0, BRICK, 0, 0, -1, 0, -1, 0, 3, 3, /* move 0 */ 24, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 352, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 336, 9999, 0, 0, 0, 1, /* shoot 1 */ 30, 15, 0, 0, 1, 2, /* shoot 2 */ 9999, 9999, 0, 0, 0, 2)); } if (s == 12) { tenm_table_add(normal_enemy_new((double) (WINDOW_WIDTH / 2) + 45.0, -24.0, SQUARE, 0, 0, -1, 0, -1, 0, 3, 3, /* move 0 */ 12, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 352, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 168, 31, 0, 65, 0, 1, /* shoot 1 */ 196, 9999, 0, 65, 0, 2, /* shoot 2 */ 9999, 31, 0, 65, 1, 2)); tenm_table_add(normal_enemy_new((double) (WINDOW_WIDTH / 2) - 45.0, -24.0, SQUARE, 0, 0, -1, 0, -1, 0, 3, 3, /* move 0 */ 12, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 352, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 168, 31, 0, 115, 0, 1, /* shoot 1 */ 196, 9999, 0, 115, 0, 2, /* shoot 1 */ 9999, 31, 0, 115, 1, 2)); } if (s == 150) { tenm_table_add(normal_enemy_new(70.0 + 45.0, -24.0, SQUARE, 0, 0, -1, 0, -1, 0, 3, 4, /* move 0 */ 36, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 190, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 66, 9999, 0, 135, 0, 1, /* shoot 1 */ 30, 29, 0, 135, 0, 2, /* shoot 2 */ 90, 29, 1, 135, 1, 3, /* shoot 3 */ 9999, 29, 4, 135, 0, 3)); tenm_table_add(normal_enemy_new(70.0 - 45.0, -24.0, SQUARE, 0, 0, -1, 0, -1, 0, 3, 4, /* move 0 */ 36, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 190, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 66, 9999, 0, 45, 0, 1, /* shoot 1 */ 30, 29, 0, 45, 0, 2, /* shoot 2 */ 90, 29, 1, 45, 1, 3, /* shoot 3 */ 9999, 29, 4, 45, 0, 3)); tenm_table_add(normal_enemy_new(570.0 + 45.0, -24.0, SQUARE, 0, 0, -1, 0, -1, 0, 3, 3, /* move 0 */ 36, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 190, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 66, 9999, 0, 135, 0, 1, /* shoot 1 */ 160, 29, 0, 135, 0, 2, /* shoot 2 */ 9999, 29, 5, 135, 1, 2)); tenm_table_add(normal_enemy_new(570.0 - 45.0, -24.0, SQUARE, 0, 0, -1, 0, -1, 0, 3, 3, /* move 0 */ 36, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 190, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 66, 9999, 0, 45, 0, 1, /* shoot 1 */ 160, 29, 0, 45, 0, 2, /* shoot 2 */ 9999, 29, 5, 45, 1, 2)); } if (s == 174) { tenm_table_add(normal_enemy_new(70.0, -23.0, BRICK, 0, 0, -1, 0, -1, 0, 3, 3, /* move 0 */ 12, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 190, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 72, 9999, 0, 0, 0, 1, /* shoot 1 */ 90, 23, 0, 0, 1, 2, /* shoot 2 */ 9999, 9999, 0, 0, 0, 2)); tenm_table_add(normal_enemy_new(570.0, -23.0, BRICK, 0, 0, -1, 0, -1, 0, 3, 3, /* move 0 */ 12, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 190, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 12, 9999, 0, 0, 0, 1, /* shoot 1 */ 30, 15, 0, 0, 1, 2, /* shoot 2 */ 9999, 9999, 0, 0, 0, 2)); } if (s == 176) tenm_table_add(wall_11_new(195.0, -29.0, 7.0, 90, 7)); if (s == 276) tenm_table_add(wall_11_new(445.0, -29.0, 7.0, 90, 7)); } if ((t >= 860) && (t <= 1028)) { s = t - 860; if ((s >= 0) && (s < 168) && (s % 7 == 0)) { if (s < 42) x = 128.0; else if (s < 84) x = 384.0; else if (s < 126) x = 256.0; else x = 512.0; switch (s % 42) { case 0: tenm_table_add(wall_11_new(x, -29.0, 7.0, 90, 7)); break; case 14: case 21: case 28: case 35: if (s % 42 == 14) { what = BALL_CAPTAIN; } else { what = BALL_SOLDIER; } tenm_table_add(normal_enemy_new(x, -19.0, what, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 7.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 28, 0, 0, 1, 0)); break; default: break; } } } if (t == 1110) tenm_table_add(plan_11_more_2_new()); if ((t >= 1640) && (t <= 1830)) { s = t - 1640; if (s == 0) { tenm_table_add(normal_enemy_new(210.0, -42.0, TRIANGLE, ENEMY_TYPE_WEAK, 0, -1, 0, -1, 0, 2, 1, /* move 0 */ 24, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 9999, 67, 0, 0, 1, 0)); tenm_table_add(normal_enemy_new(430.0, -42.0, TRIANGLE, ENEMY_TYPE_WEAK, 0, -1, 0, -1, 0, 2, 1, /* move 0 */ 24, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 9999, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 9999, 67, 0, 0, 1, 0)); } if ((s >= 160) && (s <= 190) && (s % 10 == 0)) { if (s % 20 == 0) tenm_table_add(wall_11_new(-29.0, (double) ((s - 160) * 8), 7.0, 15, 7)); else tenm_table_add(wall_11_new(669.0, (double) ((s - 160) * 8), 7.0, 155, 7)); } } if (t == 2090) tenm_table_add(warning_new()); if (t == 2220) tenm_table_add(theorem_weapon_new()); return SCHEDULER_SUCCESS; } static tenm_object * plan_11_more_1_new(int what) { tenm_object *new = NULL; int *count = NULL; /* sanity check */ if ((what < 0) || (what > 1)) { fprintf(stderr, "plan_11_more_1_new: strange what (%d)\n", what); return NULL; } count = (int *) malloc(sizeof(int) * 4); if (count == NULL) { fprintf(stderr, "plan_11_more_1_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] mode * [1] timer * [2] what * [3] number of enemies killed */ count[0] = 0; count[1] = -1; count[2] = what; count[3] = 0; new = tenm_object_new("plan 11 more 1", 0, 0, 1, 0.0, 0.0, 4, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&plan_11_more_1_act), (int (*)(tenm_object *, int)) NULL); if (new == NULL) { fprintf(stderr, "plan_11_more_1_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int plan_11_more_1_act(tenm_object *my, const tenm_object *player) { double x; double dx; int t_shoot; /* sanity check */ if (my == NULL) { fprintf(stderr, "plan_11_more_1_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[1])++; if (my->count[0] == 0) { if ((my->count[1] >= 0) && (my->count[1] <= 40) && (my->count[1] % 20 == 0)) { x = ((double) WINDOW_WIDTH) + 19.0; dx = -5.0; if (my->count[2] != 0) { x = ((double) WINDOW_WIDTH) - x; dx *= -1.0; } tenm_table_add(normal_enemy_new(x, 97.0, BALL_SOLDIER, ENEMY_TYPE_WEAK, 0, my->table_index, 3, -1, 0, 1, 2, /* move 0 */ 9999, dx, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 60 - my->count[1], 17, 0, 0, 0, 1, /* shoot 1 */ 9999, 17, (60 - my->count[1]) % 17, 0, 1, 1)); } if ((my->count[1] >= 100) && (my->count[1] <= 125) && ((my->count[1] - 100) % 5 == 0)) { if ((my->count[1] - 100) % 10 == 0) x = 105.0; else x = 3.0; if (my->count[2] != 0) x = ((double) WINDOW_WIDTH) - x; if ((my->count[1] - 100 == 5) || (my->count[1] - 100 == 20)) t_shoot = 23; else t_shoot = 9999; tenm_table_add(normal_enemy_new(x, -19.0, BALL_SOLDIER, 0, 0, my->table_index, 3, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, t_shoot, 0, 0, 1, 0)); } if ((my->count[1] <= 230) && (my->count[3] >= 9)) { my->count[0] = 1; my->count[1] = -1; } else if (my->count[1] > 230) { return 1; } } else if (my->count[0] == 1) { if ((my->count[1] >= 50) && (my->count[1] <= 70) && (my->count[1] % 5 == 0)) { x = 44.0; if (my->count[2] != 0) x = ((double) WINDOW_WIDTH) - x; tenm_table_add(normal_enemy_new(x, -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 9999, 0, 0, 1, 0)); } if (my->count[1] > 70) return 1; } return 0; } static tenm_object * plan_11_more_2_new(void) { tenm_object *new = NULL; int *count = NULL; count = (int *) malloc(sizeof(int) * 4); if (count == NULL) { fprintf(stderr, "plan_11_more_2_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] mode * [1] timer * [2] number of enemies killed * [3] total timer */ count[0] = 0; count[1] = -1; count[2] = 0; count[3] = -1; new = tenm_object_new("plan 11 more 2", 0, 0, 1, 0.0, 0.0, 4, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&plan_11_more_2_act), (int (*)(tenm_object *, int)) NULL); if (new == NULL) { fprintf(stderr, "plan_11_more_2_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int plan_11_more_2_act(tenm_object *my, const tenm_object *player) { double dx; /* sanity check */ if (my == NULL) { fprintf(stderr, "plan_11_more_2_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[1])++; (my->count[3])++; if (my->count[3] > 430) return 1; if ((my->count[0] == 0) || (my->count[0] == 1)) { if ((my->count[1] == 0) && (my->count[3] <= 349)) { tenm_table_add(normal_enemy_new((double) (WINDOW_WIDTH / 2), -42.0, TRIANGLE, 0, 0, my->table_index, 2, -1, 0, 3, 3, /* move 0 */ 31, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 359 - my->count[3], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, -5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 31, 9999, 0, 0, 0, 1, /* shoot 1 */ 359 - my->count[3], 43, 31, 0, 1, 2, /* shoot 2 */ 9999, 9999, 0, 0, 0, 2)); tenm_table_add(normal_enemy_new(25.0, -24.0, BALL_CAPTAIN, 0, 0, my->table_index, 2, -1, 0, 3, 2, /* move 0 */ 31, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 359 - my->count[3], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, -5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 390 - my->count[3], 17, 0, 0, 1, 1, /* shoot 1 */ 9999, 9999, 0, 0, 0, 1)); tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) - 25.0, -24.0, BALL_CAPTAIN, 0, 0, my->table_index, 2, -1, 0, 3, 2, /* move 0 */ 31, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 359 - my->count[3], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, -5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 390 - my->count[3], 17, 0, 0, 1, 1, /* shoot 1 */ 9999, 9999, 0, 0, 0, 1)); } if (my->count[2] >= 3) { if (my->count[0] == 0) { if (my->count[3] < 349) { my->count[0] = 1; my->count[1] = -31; my->count[2] = 0; } } else if (my->count[0] == 1) { if (my->count[3] < 390) { if (my->count[3] < 285) my->count[0] = 2; else if (my->count[3] < 300) my->count[0] = 3; else my->count[0] = 4; my->count[1] = -1; my->count[2] = 0; } } } } else if (my->count[0] == 2) { if ((my->count[3] < 390) && (my->count[1] % 5 == 0)) { if (my->count[1] % 50 < 25) dx = 8.0; else dx = -8.0; tenm_table_add(normal_enemy_new((double) (WINDOW_WIDTH / 2), -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 3, 2, /* move 0 */ 24, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 10, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, dx, 0.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 34, 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 9999, 0, 0, 1, 1)); } if (my->count[3] == 290) tenm_table_add(wall_11_new(669.0, 260.0, 7.0, 180, 7)); if (my->count[3] == 320) tenm_table_add(wall_11_new(-29.0, 360.0, 7.0, 0, 7)); } else if (my->count[0] == 3) { if ((my->count[3] < 390) && (my->count[1] % 7 == 0)) { if (my->count[1] % 56 < 28) dx = 6.0; else dx = -6.0; tenm_table_add(normal_enemy_new((double) (WINDOW_WIDTH / 2), -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 3, 2, /* move 0 */ 24, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 10, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, dx, 0.6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 34, 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 9999, 0, 0, 1, 1)); } if (my->count[3] == 320) tenm_table_add(wall_11_new(-29.0, 260.0, 7.0, 0, 7)); } else if (my->count[0] == 4) { if ((my->count[3] < 390) && (my->count[1] % 8 == 0) && (my->count[1] % 32 < 24)) { if (my->count[1] % 64 < 32) dx = 5.0; else dx = -5.0; tenm_table_add(normal_enemy_new((double) (WINDOW_WIDTH / 2), -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 3, 2, /* move 0 */ 24, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 10, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, dx, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 34, 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 9999, 0, 0, 1, 1)); } } return 0; } dangen-0.5/spqr/plan-11.h0000644000175000017500000000026310276702741015734 0ustar00ooharaoohara00000000000000/* $Id: plan-11.h,v 1.1 2004/05/06 13:46:07 oohara Exp $ */ #ifndef __DANGEN_PLAN_11_H__ #define __DANGEN_PLAN_11_H__ int plan_11(int t); #endif /* not __DANGEN_PLAN_11_H__ */ dangen-0.5/spqr/plan-12.c0000644000175000017500000000341410276702741015731 0ustar00ooharaoohara00000000000000/* $Id: plan-12.c,v 1.4 2004/12/12 13:30:10 oohara Exp $ */ #include #include "scheduler.h" #include "tenm_table.h" #include "w-ko.h" #include "warning.h" #include "stage-title.h" #include "normal-enemy.h" #include "const.h" #include "tenm_math.h" #include "plan-12.h" int plan_12(int t) { int i; int s; double x; double y; int theta; int temp; /* sanity check */ if (t < 0) return SCHEDULER_ERROR; if (t == 30) tenm_table_add(stage_title_new()); if ((t >= 160) && (t < 880)) { s = t - 160; if (s % 13 == 0) { for (i = 0; i < 2; i++) { if ((s < 180) && (i != 0)) continue; theta = -(s + i * 180); if (s % 26 == 0) temp = 37; else temp = 9999; x = ((double) (WINDOW_WIDTH / 2)) + 424.0 * tenm_cos(theta) + 100.0 * tenm_cos(theta - 90); y = ((double) (WINDOW_HEIGHT / 2)) + 424.0 * tenm_sin(theta) + 100.0 * tenm_sin(theta - 90); tenm_table_add(normal_enemy_new(x, y, BALL_SOLDIER, 0, 140, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, -7.0 * tenm_cos(theta), -7.0 * tenm_sin(theta), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, temp, s % temp, 0, 1, 0)); } } } if (t == 1070) tenm_table_add(warning_new()); if (t == 1200) tenm_table_add(w_ko_new()); return SCHEDULER_SUCCESS; } dangen-0.5/spqr/plan-12.h0000644000175000017500000000026310276702741015735 0ustar00ooharaoohara00000000000000/* $Id: plan-12.h,v 1.2 2004/05/12 22:55:14 oohara Exp $ */ #ifndef __DANGEN_PLAN_12_H__ #define __DANGEN_PLAN_12_H__ int plan_12(int t); #endif /* not __DANGEN_PLAN_12_H__ */ dangen-0.5/spqr/plan-13.c0000644000175000017500000005262210276702741015737 0ustar00ooharaoohara00000000000000/* $Id: plan-13.c,v 1.105 2005/01/16 12:03:37 oohara Exp $ */ #include #include "scheduler.h" #include "tenm_table.h" #include "insane-hand.h" #include "warning.h" #include "stage-title.h" #include "normal-enemy.h" #include "const.h" #include "wall-13.h" #include "plan-13.h" void plan_13_formation(double x, double y, double v, int t_move, int what); int plan_13(int t) { int i; int s; int t_shoot; double x; double y; double dx; double dy; /* sanity check */ if (t < 0) return SCHEDULER_ERROR; if (t == 30) tenm_table_add(stage_title_new()); if (t >= 160) { s = t - 160; if ((((s >= 0) && (s < 32)) || ((s >= 64) && (s < 96)) || ((s >= 128) && (s < 160))) && (s % 8 == 0)) { if (s % 32 == 0) t_shoot = 43; else t_shoot = 9999; tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) + 19.0, 90.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, -5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, t_shoot, 0, 0, 1, 0)); } if ((((s >= 32) && (s < 64)) || ((s >= 160) && (s < 192)) || ((s >= 224) && (s < 256))) && (s % 8 == 0)) { if (s % 32 == 0) t_shoot = 43; else t_shoot = 9999; tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) + 19.0, 240.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, -5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, t_shoot, 0, 0, 1, 0)); } if ((((s >= 96) && (s < 128)) || ((s >= 192) && (s < 224)) || ((s >= 256) && (s < 288))) && (s % 8 == 0)) { if (s % 32 == 0) t_shoot = 43; else t_shoot = 9999; tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) + 19.0, 390.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, -5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, t_shoot, 0, 0, 1, 0)); } if (s == 0) { plan_13_formation(729.0, 90.0, 5.2, 25, 3); plan_13_formation(969.0, 390.0, 5.2, 25, 3); for (i = 0; i < 5; i++) tenm_table_add(wall_13_new(1100.0 + ((double) i) * 145.0, 30.0, t)); tenm_table_add(wall_13_new(1100.0, 450.0, t)); tenm_table_add(wall_13_new(1680.0, 450.0, t)); } if ((s >= 581) && (s < 1016) && ((s - 581) % 145 == 0)) tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) + 24.0, 450.0, SQUARE, 0, 0, -1, 0, -1, 0, 3, 2, /* move 0 */ 1230 - t, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 270, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 1500 - t, 43, 0, 225, 1, 1, /* shoot 2 */ 9999, 9999, 0, 225, 0, 1)); if ((s >= 600) && (s < 960) && ((s - 600) % 30 == 0)) tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) - 67.0 - ((double) (s - 600)) + ((double) (((s - 600) % 120) / 30)) * 145.0, -24.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, -1.0, 0.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 17, 0, 0, 1, 0)); if ((s >= 1100) && (s < 1220) && ((s - 1100) % 30 == 0)) tenm_table_add(normal_enemy_new(102.0 + ((double) (((s - 1100) % 120) / 30)) * 145.0, -24.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 0.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 17, 0, 0, 1, 0)); } if (t >= 1530) { s = t - 1530; if ((s >= 0) && (s < 80) && (s % 4 == 0)) { if (s % 16 < 8) dx = 0.75; else dx = -0.75; dy = -5.0 - ((double) (s / 8)) * 0.25; if (s % 8 == 0) tenm_table_add(normal_enemy_new(234.0, ((double) WINDOW_HEIGHT) + 19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, dx, dy, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 9999, 0, 0, 1, 0)); else tenm_table_add(normal_enemy_new(406.0, ((double) WINDOW_HEIGHT) + 19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, dx, dy, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 9999, 0, 0, 1, 0)); } } if ((t >= 1921) && (t <= 2821) && ((t - 1921) % 180 == 0)) { tenm_table_add(wall_13_new(30.0, ((double) WINDOW_HEIGHT) + 29.0, t)); tenm_table_add(wall_13_new(((double) WINDOW_WIDTH) - 30.0, ((double) WINDOW_HEIGHT) + 29.0, t)); } if (t == 1800) { for (i = 0; i < 5; i++) { if (i < 3) dy = -2.0 * ((double) i); else dy = -3.0 + 2.0 * ((double) (i - 3)); tenm_table_add(normal_enemy_new(82.0 + 10.0 * ((double) i), 520.0 - dy * 43.0, BALL_SOLDIER, 0, 250, -1, 0, -1, 0, 3, 2, /* move 0 */ 380, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 43, (double) i, dy - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 350, 85, 17 * i, 0, 0, 1, /* shoot 1 */ 9999, 85, (350 + 17 * i) % 85, 0, 1, 1)); tenm_table_add(normal_enemy_new(559.0 - 10.0 * ((double) i), 520.0 - dy * 43.0, BALL_SOLDIER, 0, 250, -1, 0, -1, 0, 3, 2, /* move 0 */ 380, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 43, -((double) i), dy - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 350, 85, 17 * i, 0, 0, 1, /* shoot 1 */ 9999, 85, (350 + 17 * i) % 85, 0, 1, 1)); tenm_table_add(normal_enemy_new(82.0 + 10.0 * ((double) i), 740.0 - dy * 43.0, BALL_SOLDIER, 0, 480, -1, 0, -1, 0, 3, 2, /* move 0 */ 380, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 43, (double) i, dy - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 350, 85, 17 * i, 0, 0, 1, /* shoot 1 */ 9999, 85, (350 + 17 * i) % 85, 0, 1, 1)); tenm_table_add(normal_enemy_new(559.0 - 10.0 * ((double) i), 740.0 - dy * 43.0, BALL_SOLDIER, 0, 480, -1, 0, -1, 0, 3, 2, /* move 0 */ 380, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 43, -((double) i), dy - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 350, 85, 17 * i, 0, 0, 1, /* shoot 1 */ 9999, 85, (350 + 17 * i) % 85, 0, 1, 1)); } } if (t == 2281) { for (i = 0; i < 4; i++) tenm_table_add(wall_13_new(120.0 + ((double) i) * 90.0, ((double) WINDOW_HEIGHT) + 29.0, t)); plan_13_formation(280.0, ((double) WINDOW_HEIGHT) + 259.0, 3.0, 80, 0); plan_13_formation(360.0, ((double) WINDOW_HEIGHT) + 259.0, 3.0, 80, 0); plan_13_formation(280.0, ((double) WINDOW_HEIGHT) + 339.0, 3.0, 80, 0); plan_13_formation(360.0, ((double) WINDOW_HEIGHT) + 339.0, 3.0, 80, 0); plan_13_formation(320.0, ((double) WINDOW_HEIGHT) + 299.0, 5.0, 48, 1); } if (t == 2556) { tenm_table_add(normal_enemy_new(30.0, ((double) WINDOW_HEIGHT) + 24.0, SQUARE, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 43, 0, 350, 1, 0)); tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) - 30.0, ((double) WINDOW_HEIGHT) + 24.0, SQUARE, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 43, 0, 170, 1, 0)); } if (t == 2821) for (i = 0; i < 4; i++) tenm_table_add(wall_13_new(520.0 - ((double) i) * 90.0, ((double) WINDOW_HEIGHT) + 29.0, t)); if ((t >= 2981) && (t < 3191)) { s = t - 2981; if (s % 30 == 0) { if (s % 60 == 30) { x = -31.0; dx = 5.0; } else { x = ((double) WINDOW_WIDTH) + 31.0; dx = -5.0; } y = ((double) WINDOW_HEIGHT) - 24.0 - ((double) (s - 90)) * 1.0; if (s >= 90) y -= ((double) (((s - 90) / 30) * 48)); else y += ((double) ((s / 30) * 48)) - 144.0; tenm_table_add(normal_enemy_new(x, y, BRICK, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, dx, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 37, 27, 0, 1, 0)); } } if (t == 3380) tenm_table_add(warning_new()); if (t == 3510) tenm_table_add(insane_hand_new()); return SCHEDULER_SUCCESS; } void plan_13_formation(double x, double y, double v, int t_move, int what) { int w; int t_no_escape; int t_shoot; double d; /* sanity check */ if (t_move <= 0) { fprintf(stderr, "plan_13_formation: t_move is non-positive (%d)\n", t_move); return; } if ((what < 0) || (what > 3)) { fprintf(stderr, "plan_13_formation: strange what (%d)\n", what); return; } d = v * ((double) t_move) / 2.0; t_no_escape = ((int) ((x + d) / 1.0)) + 26; switch (what) { case 0: case 1: t_no_escape = ((int) ((y + d) / 1.0)) + 26; if (what == 1) { w = BALL_CAPTAIN; t_shoot = 36; } else { w = BALL_SOLDIER; t_shoot = 9999; } tenm_table_add(normal_enemy_new(x + d, y - d, w, 0, t_no_escape, -1, 0, -1, 0, 2, 1, /* move 0 */ t_move, -v, v - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ t_move, v, -v - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, t_shoot, 0, 0, 1, 0)); tenm_table_add(normal_enemy_new(x + d, y + d, w, 0, t_no_escape, -1, 0, -1, 0, 2, 1, /* move 0 */ t_move, -v, -v - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ t_move, v, v - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, t_shoot, 9, 0, 1, 0)); tenm_table_add(normal_enemy_new(x - d, y + d, w, 0, t_no_escape, -1, 0, -1, 0, 2, 1, /* move 0 */ t_move, v, -v - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ t_move, -v, v - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, t_shoot, 18, 0, 1, 0)); tenm_table_add(normal_enemy_new(x - d, y - d, w, 0, t_no_escape, -1, 0, -1, 0, 2, 1, /* move 0 */ t_move, v, v - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ t_move, -v, -v - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, t_shoot, 27, 0, 1, 0)); break; case 2: case 3: t_no_escape = ((int) ((x + d) / 1.0)) + 26; if (what == 3) { w = BALL_CAPTAIN; t_shoot = 36; } else { w = BALL_SOLDIER; t_shoot = 9999; } tenm_table_add(normal_enemy_new(x + d, y - d, w, 0, t_no_escape, -1, 0, -1, 0, 4, 2, /* move 0 */ t_move, -v - 1.0, v, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ t_move, 0.0 - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ t_move, v - 1.0, -v, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3, /* move 3 */ t_move, 0.0 - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 300, t_shoot, 27, 0, 0, 1, /* shoot 1 */ 9999, t_shoot, 327 % t_shoot, 0, 1, 1)); tenm_table_add(normal_enemy_new(x + d, y + d, w, 0, t_no_escape, -1, 0, -1, 0, 4, 2, /* move 0 */ t_move, 0.0 - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ t_move, -v - 1.0, -v, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ t_move, 0.0 - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3, /* move 3 */ t_move, v - 1.0, v, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 300, t_shoot, 18, 0, 0, 1, /* shoot 1 */ 9999, t_shoot, 318 % t_shoot, 0, 1, 1)); tenm_table_add(normal_enemy_new(x - d, y + d, w, 0, t_no_escape, -1, 0, -1, 0, 4, 2, /* move 0 */ t_move, v - 1.0, -v, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ t_move, 0.0 - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ t_move, -v - 1.0, v, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3, /* move 3 */ t_move, 0.0 - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 300, t_shoot, 9, 0, 0, 1, /* shoot 1 */ 9999, t_shoot, 309 % t_shoot, 0, 1, 1)); tenm_table_add(normal_enemy_new(x - d, y - d, w, 0, t_no_escape, -1, 0, -1, 0, 4, 2, /* move 0 */ t_move, 0.0 - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ t_move, v - 1.0, v, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ t_move, 0.0 - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3, /* move 3 */ t_move, -v - 1.0, -v, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 300, t_shoot, 0, 0, 0, 1, /* shoot 1 */ 9999, t_shoot, 300 % t_shoot, 0, 1, 1)); break; default: fprintf(stderr, "plan_13_formation: undefined what (%d)\n", what); break; } } dangen-0.5/spqr/plan-13.h0000644000175000017500000000026310276702741015736 0ustar00ooharaoohara00000000000000/* $Id: plan-13.h,v 1.1 2004/06/08 06:27:35 oohara Exp $ */ #ifndef __DANGEN_PLAN_13_H__ #define __DANGEN_PLAN_13_H__ int plan_13(int t); #endif /* not __DANGEN_PLAN_13_H__ */ dangen-0.5/spqr/plan-14.c0000644000175000017500000007452210276702741015743 0ustar00ooharaoohara00000000000000/* $Id: plan-14.c,v 1.158 2005/06/26 14:30:00 oohara Exp $ */ /* [easy] Strikers 1341 */ #include /* malloc */ #include #include "scheduler.h" #include "tenm_table.h" #include "strikers.h" #include "stage-title.h" #include "warning.h" #include "normal-enemy.h" #include "const.h" #include "plan-14.h" static tenm_object *plan_14_more_1_new(void); static int plan_14_more_1_act(tenm_object *my, const tenm_object *player); int plan_14(int t) { int i; int s; double x; /* sanity check */ if (t < 0) return SCHEDULER_ERROR; if (t == 30) tenm_table_add(stage_title_new()); if ((t >= 160) && (t < 370)) { s = t - 160; if (s % 14 == 0) { x = ((double) (WINDOW_WIDTH)) - 40.0 - 2.0 * ((double) s); tenm_table_add(normal_enemy_new(x, -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, -2.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 45 - (s % 42), 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 9999, 0, 0, 1, 1)); } if ((s % 14 == 7) && (s % 42 < 35)) { x = ((double) (WINDOW_WIDTH)) - 240.0 - 2.0 * ((double) ((s / 42) * 42)) + 2.0 * ((double) (s % 42)); tenm_table_add(normal_enemy_new(x, -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 4.0 - 2.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 45 - (s % 42), 37, s % 37, 0, 0, 1, /* shoot 1 */ 9999, 37, (45 - (s % 42) + s) % 37, 0, 1, 1)); } } if (t == 470) { for (i = -1; i <= 1; i++) tenm_table_add(normal_enemy_new(70.0 + 40.0 * ((double) i), -59.0 - 40.0 * ((double) i), BALL_SOLDIER, 0, 70, -1, 0, -1, 0, 3, 2, /* move 0 */ 70, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 170, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 5.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 240, 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 9999, 9989 + i * 5, 0, 1, 1)); for (i = -1; i <= 1; i++) tenm_table_add(normal_enemy_new(230.0 + 40.0 * ((double) i), -59.0 + 40.0 * ((double) i), BALL_SOLDIER, 0, 70, -1, 0, -1, 0, 3, 2, /* move 0 */ 70, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 200, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 1.1, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 270, 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 9999, 9989 + i * 5, 0, 1, 1)); tenm_table_add(normal_enemy_new(150.0, -19.0, BALL_CAPTAIN, 0, 70, -1, 0, -1, 0, 3, 1, /* move 0 */ 70, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 90, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 9999, 38, 0, 0, 1, 0)); for (i = -1; i <= 1; i++) tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) - (70.0 + 40.0 * ((double) i)), -59.0 - 40.0 * ((double) i), BALL_SOLDIER, 0, 70, -1, 0, -1, 0, 3, 2, /* move 0 */ 70, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 170, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, -5.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 240, 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 9999, 9989 + i * 5, 0, 1, 1)); for (i = -1; i <= 1; i++) tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) - (230.0 + 40.0 * ((double) i)), -59.0 + 40.0 * ((double) i), BALL_SOLDIER, 0, 70, -1, 0, -1, 0, 3, 2, /* move 0 */ 70, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 200, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, -1.1, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 270, 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 9999, 9989 + i * 5, 0, 1, 1)); tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) - 150.0, -19.0, BALL_CAPTAIN, 0, 70, -1, 0, -1, 0, 3, 1, /* move 0 */ 70, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 90, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 9999, 38, 0, 0, 1, 0)); for (i = -1; i <= 1; i++) tenm_table_add(normal_enemy_new(237.0 + 40.0 * ((double) i), -210.0 - 40.0 * ((double) i), BALL_SOLDIER, 0, 70, -1, 0, -1, 0, 3, 2, /* move 0 */ 70, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 140, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 4.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 210, 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 9999, 9989 + i * 5, 0, 1, 1)); for (i = -1; i <= 1; i++) tenm_table_add(normal_enemy_new(403.0 + 40.0 * ((double) i), -210.0 + 40.0 * ((double) i), BALL_SOLDIER, 0, 70, -1, 0, -1, 0, 3, 2, /* move 0 */ 70, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 140, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, -4.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 210, 9999, 0, 0, 0, 1, /* shoot 0 */ 9999, 9999, 9989 + i * 5, 0, 1, 1)); tenm_table_add(normal_enemy_new(((double) (WINDOW_WIDTH / 2)), -170.0, BALL_CAPTAIN, 0, 70, -1, 0, -1, 0, 3, 1, /* move 0 */ 70, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 90, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 9999, 38, 19, 0, 1, 0)); } if (t == 890) tenm_table_add(plan_14_more_1_new()); return SCHEDULER_SUCCESS; } static tenm_object * plan_14_more_1_new(void) { tenm_object *new = NULL; int *count = NULL; count = (int *) malloc(sizeof(int) * 6); if (count == NULL) { fprintf(stderr, "plan_14_more_1_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] mode * [1 -- 2] timer * [3] number of enemies killed * [4] number of right captains created * [5] number of right captains killed */ count[0] = 0; count[1] = -1; count[2] = 0; count[3] = 0; count[4] = 0; count[5] = 0; new = tenm_object_new("plan 14 more 1", 0, 0, 1, 0.0, 0.0, 6, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&plan_14_more_1_act), (int (*)(tenm_object *, int)) NULL); if (new == NULL) { fprintf(stderr, "plan_14_more_1_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int plan_14_more_1_act(tenm_object *my, const tenm_object *player) { int i; int t_shoot; double dx; double dy; /* sanity check */ if (my == NULL) { fprintf(stderr, "plan_11_more_1_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[1])++; if (my->count[0] == 0) { if (my->count[1] % 82 == 0) { if (my->count[1] < 328) tenm_table_add(normal_enemy_new(75.0, -24.0, BALL_CAPTAIN, 0, 0, my->table_index, 3, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 5.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 37, my->count[0] % 37, 0, 1, 0)); if (my->count[1] < 492) tenm_table_add(normal_enemy_new(-24.0, 240.0, BALL_CAPTAIN, 0, 0, my->table_index, 3, -1, 0, 1, 1, /* move 0 */ 9999, 4.8, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 37, my->count[0] % 37, 0, 1, 0)); } if ((my->count[4] < 5) && (my->count[1] < 482) && (my->count[4] <= my->count[5])) { (my->count[2])++; if (my->count[2] >= 35) { (my->count[4])++; my->count[2] = 0; tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) - 75.0, -24.0, BALL_CAPTAIN, 0, 0, my->table_index, 5, -1, 0, 3, 2, /* move 0 */ 9, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 627 - my->count[1], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, -6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 636 - my->count[1], 37, my->count[0] % 37, 0, 1, 1, /* shoot 1 */ 9999, 9999, 0, 0, 0, 1)); } } if ((my->count[1] >= 328) && (my->count[1] < 376) && (my->count[5] >= 2) && ((my->count[1] - 328) % 12 == 0)) { tenm_table_add(normal_enemy_new(-19.0, 0.0, BALL_SOLDIER, 0, 0, my->table_index, 3, -1, 0, 1, 2, /* move 0 */ 9999, 3.6, 1.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 121 - (my->count[1] - 328), 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 9999, 0, 0, 1, 1)); tenm_table_add(normal_enemy_new(-19.0, 170.0, BALL_SOLDIER, 0, 0, my->table_index, 3, -1, 0, 1, 2, /* move 0 */ 9999, 3.6, 1.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 121 - (my->count[1] - 328), 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 9999, 0, 0, 1, 1)); } if ((my->count[1] >= 384) && (my->count[1] < 420) && (my->count[5] >= 4) && ((my->count[1] - 384) % 6 == 0)) { tenm_table_add(normal_enemy_new(-19.0, 85.0, BALL_SOLDIER, 0, 0, my->table_index, 3, -1, 0, 1, 3, /* move 0 */ 9999, 7.2, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 30, 9999, 0, 0, 0, 1, /* shoot 1 */ 15, 9999, 0, 0, 1, 2, /* shoot 2 */ 9999, 9999, 0, 0, 0, 2)); } } else if (my->count[0] == 1) { if (my->count[1] == 0) { tenm_table_add(normal_enemy_new(160.0, -23.0, BRICK, 0, 0, -1, 0, -1, 0, 3, 2, /* move 0 */ 14, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 500, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, -6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 514, 74, 37, 0, 1, 1, /* shoot 1 */ 9999, 9999, 0, 0, 0, 1)); tenm_table_add(normal_enemy_new(320.0, -23.0, BRICK, 0, 0, -1, 0, -1, 0, 3, 2, /* move 0 */ 14, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 500, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, -6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 514, 74, 0, 0, 1, 1, /* shoot 1 */ 9999, 9999, 0, 0, 0, 1)); tenm_table_add(normal_enemy_new(480.0, -23.0, BRICK, 0, 0, -1, 0, -1, 0, 3, 2, /* move 0 */ 14, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 500, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, -6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 514, 74, 37, 0, 1, 1, /* shoot 1 */ 9999, 9999, 0, 0, 0, 1)); } if ((my->count[1] >= 0) && (my->count[1] < 144) && ((my->count[1] - 0) % 12 == 0)) { tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) + 19.0, 0.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 3, 2, /* move 0 */ 176, -3.6, 1.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 44, 0.0, -6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 3.6, 1.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 320 - my->count[1], 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 9999, 0, 0, 1, 1)); tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) + 19.0, 170.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 3, 2, /* move 0 */ 176, -3.6, 1.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 44, 0.0, -6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 3.6, 1.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 320 - my->count[1], 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 9999, 0, 0, 1, 1)); } if ((my->count[1] >= 56) && (my->count[1] < 92) && ((my->count[1] - 56) % 6 == 0)) { if (my->count[1] == 86) t_shoot = 15; else t_shoot = 9999; tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) + 19.0, 85.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 3, /* move 0 */ 9999, -7.2, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 30, t_shoot, 0, 0, 0, 1, /* shoot 1 */ 15, 9999, 0, 0, 1, 2, /* shoot 2 */ 9999, 9999, 0, 0, 0, 2)); } if ((my->count[1] >= 260) && (my->count[1] < 296) && ((my->count[1] - 260) % 6 == 0)) { if (my->count[1] == 290) t_shoot = 15; else t_shoot = 9999; tenm_table_add(normal_enemy_new(-17.6, 75.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 3, /* move 0 */ 9999, 7.2, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 30, t_shoot, 0, 0, 0, 1, /* shoot 1 */ 15, 9999, 0, 0, 1, 2, /* shoot 2 */ 9999, 9999, 0, 0, 0, 2)); } } else if (my->count[0] == 2) { if (my->count[1] == 30) { for (i = 6; i < 9; i++) { if (i % 2 == 0) t_shoot = 9959; else t_shoot = 0; tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) + 16.0 + 35.0 * ((double) i), 300.0 - 35.0 * ((double) i), BALL_SOLDIER, 0, 106, -1, 0, -1, 0, 3, 3, /* move 0 */ 106, -6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 136, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0 + 1.2, 3.0 + 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 72 - i * 8, 9999, 0, 0, 0, 1, /* shoot 1 */ 48, 9999, t_shoot, 0, 1, 2, /* shoot 2 */ 24, 9999, 0, 0, 0, 1)); } for (i = 0; i < 6; i++) { if (i % 2 == 0) t_shoot = 9959; else t_shoot = 0; if (i < 3) { dx = 3.0; dy = 0.0; } else { dx = 1.5; dy = 1.5; } dx += 1.2; dy += 0.5; tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) + 16.0 + 35.0 * ((double) i), 300.0 - 35.0 * ((double) i), BALL_SOLDIER, 0, 106, -1, 0, -1, 0, 3, 3, /* move 0 */ 106, -6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 136, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, dx, dy, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 48 - i * 8, 9999, t_shoot + i * 8, 0, 1, 1, /* shoot 1 */ 24, 9999, 0, 0, 0, 2, /* shoot 2 */ 48, 9999, t_shoot, 0, 1, 1)); } for (i = 6; i < 9; i++) { if (i % 2 == 0) t_shoot = 9959; else t_shoot = 0; tenm_table_add(normal_enemy_new(-16.0 - 35.0 * ((double) i), 300.0 - 35.0 * ((double) i), BALL_SOLDIER, 0, 106, -1, 0, -1, 0, 3, 3, /* move 0 */ 106, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 136, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0 - 1.2, 3.0 + 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 72 - i * 8, 9999, 0, 0, 0, 1, /* shoot 1 */ 48, 9999, t_shoot, 0, 1, 2, /* shoot 2 */ 24, 9999, 0, 0, 0, 1)); } for (i = 0; i < 6; i++) { if (i % 2 == 0) t_shoot = 9959; else t_shoot = 0; if (i < 3) { dx = -3.0; dy = 0.0; } else { dx = -1.5; dy = 1.5; } dx += -1.2; dy += 0.5; tenm_table_add(normal_enemy_new(-16.0 - 35.0 * ((double) i), 300.0 - 35.0 * ((double) i), BALL_SOLDIER, 0, 106, -1, 0, -1, 0, 3, 3, /* move 0 */ 106, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 136, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, dx, dy, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 48 - i * 8, 9999, t_shoot + i * 8, 0, 1, 1, /* shoot 1 */ 24, 9999, 0, 0, 0, 2, /* shoot 2 */ 48, 9999, t_shoot, 0, 1, 1)); } } } else if (my->count[0] == 3) { if (my->count[1] == 0) tenm_table_add(warning_new()); if (my->count[1] == 130) { tenm_table_add(strikers_new()); return 1; } } if (my->count[0] == 0) { if (my->count[1] >= 642) { if ((my->count[3] >= 24) && (my->count[5] >= 5)) my->count[0] = 1; else my->count[0] = 2; my->count[1] = -1; my->count[2] = 0; my->count[3] = 0; my->count[4] = 0; my->count[5] = 0; } } else if (my->count[0] == 1) { if (my->count[1] >= 544) { my->count[0] = 2; my->count[1] = -1; my->count[2] = 0; my->count[3] = 0; my->count[4] = 0; my->count[5] = 0; } } else if (my->count[0] == 2) { if (my->count[1] >= 522) { my->count[0] = 3; my->count[1] = -1; my->count[2] = 0; my->count[3] = 0; my->count[4] = 0; my->count[5] = 0; } } return 0; } dangen-0.5/spqr/plan-14.h0000644000175000017500000000026310276702741015737 0ustar00ooharaoohara00000000000000/* $Id: plan-14.h,v 1.1 2004/07/08 13:29:31 oohara Exp $ */ #ifndef __DANGEN_PLAN_14_H__ #define __DANGEN_PLAN_14_H__ int plan_14(int t); #endif /* not __DANGEN_PLAN_14_H__ */ dangen-0.5/spqr/plan-15.c0000644000175000017500000002315610276702741015741 0ustar00ooharaoohara00000000000000/* $Id: plan-15.c,v 1.70 2005/05/03 16:36:29 oohara Exp $ */ /* [easy] Watcher Below */ #include /* malloc */ #include #include "scheduler.h" #include "tenm_table.h" #include "watcher-below.h" #include "warning.h" #include "stage-title.h" #include "const.h" #include "normal-enemy.h" #include "brilliance.h" #include "plan-15.h" static tenm_object *plan_15_more_1_new(void); static int plan_15_more_1_act(tenm_object *my, const tenm_object *player); int plan_15(int t) { int s; int t_shoot; double x; /* sanity check */ if (t < 0) return SCHEDULER_ERROR; if (t == 30) tenm_table_add(stage_title_new()); if ((t >= 160) && (t <= 702)) { if (t < 220) { s = t - 160; x = 280.0; } else if (t < 290) { s = t - 220; x = 510.0; } else if (t < 360) { s = t - 290; x = 340.0; } else if (t < 430) { s = t - 360; x = 170.0; } else if (t < 480) { s = t - 430; x = 230.0; } else if (t < 550) { s = t - 480; x = 370.0; } else if (t < 600) { s = t - 550; x = 300.0; } else if (t < 670) { s = t - 600; x = 440.0; } else { s = t - 670; x = 510.0; } if (s == 0) tenm_table_add(normal_enemy_new(x, -23.0, BRICK, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 60, 9999, 9939, 0, 0, 1, /* shoot 1 */ 9999, 9999, 0, 0, 1, 1)); if ((s >= 0) && (s < 32) && (s % 8 == 0)) { if (s == 0) t_shoot = 43; else t_shoot = 9999; tenm_table_add(normal_enemy_new(x, -133.0 + ((double) s) * 2.0, BALL_SOLDIER, 0, 103, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 0.0, 2.0, 0.0, 0.0, x, -23.0 + ((double) s) * 2.0, 0.0, 0.3, 0, /* shoot 0 */ 90 - s, t_shoot, 0, 0, 0, 1, /* shoot 1 */ 9999, t_shoot, (90 - s) % t_shoot, 0, 1, 1)); } } if (t == 900) tenm_table_add(plan_15_more_1_new()); /* if (t == 160) tenm_table_add(warning_new()); if (t == 290) tenm_table_add(watcher_below_new()); */ return SCHEDULER_SUCCESS; } static tenm_object * plan_15_more_1_new(void) { tenm_object *new = NULL; int *count = NULL; count = (int *) malloc(sizeof(int) * 4); if (count == NULL) { fprintf(stderr, "plan_15_more_1_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] mode * [1] total timer * [2] number of enemies killed * [3] mode timer */ count[0] = 0; count[1] = -1; count[2] = 0; count[3] = -1; new = tenm_object_new("plan 15 more 1", 0, 0, 1, 0.0, 0.0, 3, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&plan_15_more_1_act), (int (*)(tenm_object *, int)) NULL); if (new == NULL) { fprintf(stderr, "plan_15_more_1_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int plan_15_more_1_act(tenm_object *my, const tenm_object *player) { int t; int t_shoot; /* sanity check */ if (my == NULL) { fprintf(stderr, "plan_15_more_1_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[1])++; t = my->count[1]; if ((t >= 0) && (t <= 504)) { if ((t % 8 == 0) && (t % 40 < 32)) { if (t % 16 == 0) t_shoot = 43; else t_shoot = 9999; tenm_table_add(normal_enemy_new(((double) t) * 1.0, -240.0 + ((double) t) * 0.2, BALL_SOLDIER, 0, 206, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 1.0, 0.2, 0.0, 0.0, ((double) t) * 1.0, ((double) t) * 0.2, 0.0, 0.15, 0, /* shoot 0 */ 9999, t_shoot, t % t_shoot, 0, 1, 0)); } } (my->count[3])++; if ((t < 450) && (((my->count[0] == 0) && (my->count[3] == 50)) || ((my->count[0] == 1) && (my->count[3] == 10)))) tenm_table_add(normal_enemy_new(48.0 + ((double) t) * 1.0, -240.0 + ((double) t) * 0.2, BRICK, 0, 48, my->table_index, 2, -1, 0, 3, 3, /* move 0 */ 48, -1.0 + 1.0, 5.0 + 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 500 - t, 0.0 + 1.0, 0.0 + 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 1.0 + 1.0, -5.0 + 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 48, 9999, 0, 0, 1, 1, /* shoot 1 */ 500 - t, 43, 0, 0, 1, 2, /* shoot 2 */ 9999, 9999, 0, 0, 0, 2)); if ((my->count[0] == 2) && (t < 450) && (my->count[3] == 10)) tenm_table_add(brilliance_new(48.0 + ((double) t) * 1.0, -240.0 + ((double) t) * 0.2, 500 - t, my->table_index)); if (my->count[0] == 3) { if ((my->count[3] >= 0) && (my->count[3] < 16) && ((my->count[3] - 0) % 4 == 0)) tenm_table_add(normal_enemy_new(480.0, -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 0.0, 1.5, 0.0, 0.0, 320.0, -19.0, 0.0, 0.3, 0, /* shoot 0 */ 13 - (my->count[3] - 0), 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 9999, 0, 0, 1, 1)); if ((my->count[3] >= 30) && (my->count[3] < 46) && ((my->count[3] - 30) % 4 == 0)) tenm_table_add(normal_enemy_new(80.0, -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 0.0, 1.5, 0.0, 0.0, 320.0, -19.0, 0.0, -0.225, 0, /* shoot 0 */ 19 - (my->count[3] - 30), 9999, 0, 0, 0, 1, /* shoot 1 */ 9999, 9999, 0, 0, 1, 1)); if ((my->count[3] >= 60) && (my->count[3] < 76) && ((my->count[3] - 60) % 4 == 0)) { tenm_table_add(normal_enemy_new(640.0, -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 3, /* move 0 */ 9999, 0.0, 1.5, 0.0, 0.0, 320.0, -19.0, 0.0, 0.15, 0, /* shoot 0 */ 55 - (my->count[3] - 60), 9999, 0, 0, 0, 1, /* shoot 1 */ 15, 9999, 0, 0, 1, 2, /* shoot 2 */ 9999, 9999, 0, 0, 0, 2)); } } if (my->count[0] == 4) { if (my->count[3] == 30) tenm_table_add(warning_new()); if (my->count[3] == 160) { tenm_table_add(watcher_below_new()); return 1; } } /* mode change */ if (t < 450) { if ((my->count[0] <= 1) && (my->count[2] >= 1)) { (my->count[0])++; my->count[2] = 0; my->count[3] = -1; } } else if ((t >= 720) && (my->count[0] <= 2)) { if ((my->count[0] == 2) && (my->count[2] >= 1)) my->count[0] = 3; else my->count[0] = 4; my->count[2] = 0; my->count[3] = -1; } if ((my->count[0] == 3) && (my->count[3] >= 200)) { my->count[0] = 4; my->count[2] = 0; my->count[3] = -1; } return 0; } dangen-0.5/spqr/plan-15.h0000644000175000017500000000026310276702741015740 0ustar00ooharaoohara00000000000000/* $Id: plan-15.h,v 1.1 2004/07/14 15:07:47 oohara Exp $ */ #ifndef __DANGEN_PLAN_15_H__ #define __DANGEN_PLAN_15_H__ int plan_15(int t); #endif /* not __DANGEN_PLAN_15_H__ */ dangen-0.5/spqr/plan-16.c0000644000175000017500000002363410276702741015743 0ustar00ooharaoohara00000000000000/* $Id: plan-16.c,v 1.65 2005/06/24 14:20:03 oohara Exp $ */ /* [easy] cat tail */ #include /* malloc */ #include #include "scheduler.h" #include "tenm_table.h" #include "cat-tail.h" #include "stage-title.h" #include "warning.h" #include "normal-enemy.h" #include "const.h" #include "spellbook.h" #include "plan-16.h" static tenm_object *plan_16_more_1_new(void); static int plan_16_more_1_act(tenm_object *my, const tenm_object *player); int plan_16(int t) { /* sanity check */ if (t < 0) return SCHEDULER_ERROR; if (t == 30) tenm_table_add(stage_title_new()); if (t == 160) tenm_table_add(plan_16_more_1_new()); return SCHEDULER_SUCCESS; } static tenm_object * plan_16_more_1_new(void) { tenm_object *new = NULL; int *count = NULL; count = (int *) malloc(sizeof(int) * 4); if (count == NULL) { fprintf(stderr, "plan_16_more_1_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] mode * [1] total timer * [2] number of enemies killed * [3] number of enemies killed in time */ count[0] = 0; count[1] = -1; count[2] = 0; count[3] = 0; new = tenm_object_new("plan 16 more 1", 0, 0, 1, 0.0, 0.0, 3, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&plan_16_more_1_act), (int (*)(tenm_object *, int)) NULL); if (new == NULL) { fprintf(stderr, "plan_16_more_1_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int plan_16_more_1_act(tenm_object *my, const tenm_object *player) { int t_shoot; /* sanity check */ if (my == NULL) { fprintf(stderr, "plan_16_more_1_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[1])++; switch (my->count[0]) { case 0: if ((my->count[1] >= 0) && (my->count[1] < 360) && (my->count[1] % 8 == 0)) { if ((my->count[1] >= 0) && (my->count[1] < 288) && ((my->count[1] + 0) % 72 < 40)) { if ((my->count[1] + 0) % 72 == 32) t_shoot = 37; else t_shoot = 9999; tenm_table_add(normal_enemy_new(-19.0, 30.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, t_shoot, my->count[1] % t_shoot, 0, 1, 0)); } if ((my->count[1] >= 48) && (my->count[1] < 336) && ((my->count[1] + 24) % 72 < 40)) { if ((my->count[1] + 24) % 72 == 32) t_shoot = 37; else t_shoot = 9999; tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) + 19.0, 130.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, -6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, t_shoot, my->count[1] % t_shoot, 0, 1, 0)); } if ((my->count[1] >= 24) && (my->count[1] < 312) && ((my->count[1] + 48) % 72 < 40)) { if ((my->count[1] + 48) % 72 == 32) t_shoot = 37; else t_shoot = 9999; tenm_table_add(normal_enemy_new(-19.0, 230.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, t_shoot, my->count[1] % t_shoot, 0, 1, 0)); } } break; case 1: if (my->count[1] == 0) tenm_table_add(spellbook_new(my->table_index)); break; case 2: if ((my->count[1] >= 0) && (my->count[1] < 220) && (my->count[1] % 11 == 0) && (my->count[1] % 55 != 44)) { if (my->count[1] % 33 == 0) t_shoot = 43; else t_shoot = 9999; tenm_table_add(normal_enemy_new(-19.0, 100.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 13.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, t_shoot, 33, 0, 1, 0)); tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) + 19.0, 100.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, -13.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, t_shoot, 33, 0, 1, 0)); } break; case 3: if ((my->count[1] == 0) || (my->count[1] == 208)) tenm_table_add(spellbook_new(my->table_index)); break; case 4: if ((my->count[1] >= 0) && (my->count[1] < 540) && (my->count[1] % 10 == 0) && (my->count[1] % 90 < 40)) { tenm_table_add(normal_enemy_new(35.0 + ((double) ((my->count[1] % 90) / 10)) * 120.0 + ((double) ((my->count[1] % 360) / 90)) * 70.0, -24.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 9999, 9958, 0, 1, 0)); } break; case 5: if ((my->count[1] == 0) || (my->count[1] == 138) || (my->count[1] == 276)) tenm_table_add(spellbook_new(my->table_index)); break; case 6: if ((my->count[1] >= 0) && (my->count[1] < 220) && (my->count[1] % 5 == 0)) { if (my->count[1] % 110 < 55) tenm_table_add(normal_enemy_new(100.0, -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 6.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 9999, 0, 0, 1, 0)); else tenm_table_add(normal_enemy_new(((double) WINDOW_WIDTH) - 100.0, -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, -6.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 9999, 0, 0, 1, 0)); } break; case 7: if (my->count[1] == 30) tenm_table_add(warning_new()); if (my->count[1] == 160) { tenm_table_add(cat_tail_new()); return 1; } break; default: fprintf(stderr, "plan_16_more_1_act: strange mode when adding enemies " "(%d)\n", my->count[0]); break; } /* mode change */ switch (my->count[0]) { case 0: if (my->count[1] >= 450) { my->count[0] = 1; my->count[1] = -1; my->count[2] = 0; my->count[3] = 0; } break; case 1: if (my->count[2] >= 1) { if (my->count[3] >= 1) my->count[0] = 2; else my->count[0] = 7; my->count[1] = -41; my->count[2] = 0; my->count[3] = 0; } break; case 2: if (my->count[1] >= 280) { my->count[0] = 3; my->count[1] = -1; my->count[2] = 0; my->count[3] = 0; } break; case 3: if (my->count[2] >= 2) { if (my->count[3] >= 2) my->count[0] = 4; else my->count[0] = 7; my->count[1] = -41; my->count[2] = 0; my->count[3] = 0; } break; case 4: if (my->count[1] >= 680) { my->count[0] = 5; my->count[1] = -1; my->count[2] = 0; my->count[3] = 0; } break; case 5: if (my->count[2] >= 3) { if (my->count[3] >= 3) my->count[0] = 6; else my->count[0] = 7; my->count[1] = -41; my->count[2] = 0; my->count[3] = 0; } break; case 6: if (my->count[1] >= 300) { my->count[0] = 7; my->count[1] = -1; my->count[2] = 0; my->count[3] = 0; } break; case 7: break; default: fprintf(stderr, "plan_16_more_1_act: strange mode when changing mode " "(%d)\n", my->count[0]); break; } return 0; } dangen-0.5/spqr/plan-16.h0000644000175000017500000000026310276702741015741 0ustar00ooharaoohara00000000000000/* $Id: plan-16.h,v 1.1 2004/07/17 12:10:01 oohara Exp $ */ #ifndef __DANGEN_PLAN_16_H__ #define __DANGEN_PLAN_16_H__ int plan_16(int t); #endif /* not __DANGEN_PLAN_16_H__ */ dangen-0.5/spqr/plan-17.c0000644000175000017500000001374110276702741015742 0ustar00ooharaoohara00000000000000/* $Id: plan-17.c,v 1.113 2005/06/26 10:17:35 oohara Exp $ */ /* [very easy] Afterdeath */ #include #include "scheduler.h" #include "tenm_table.h" #include "afterdeath.h" #include "stage-title.h" #include "warning.h" #include "normal-enemy.h" #include "const.h" #include "tenm_math.h" #include "plan-17.h" static void plan_17_circle_party(double x, double dx, double dy); int plan_17(int t) { int s; int theta; double x; double ddy; int t_shoot; /* sanity check */ if (t < 0) return SCHEDULER_ERROR; if (t == 30) tenm_table_add(stage_title_new()); if (t == 160) plan_17_circle_party(200.0, 4.0, 3.0); if (t == 350) plan_17_circle_party(440.0, -3.5, 0.5); if (t == 400) plan_17_circle_party(520.0, -3.3, 4.4); if ((t == 590) || (t == 630) || (t == 670)) { if (t == 590) x = 200.0; else if (t == 630) x = 100.0; else x = 300.0; tenm_table_add(normal_enemy_new(x, -24.0, BRICK, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 15 + (t - 590), 37, 30, 0, 0, 1, /* shoot 1 */ 9999, 37, (45 + (t - 590)) % 37, 0, 1, 1)); } if ((t >= 860) && (t < 1294)) { s = t - 860; if ((s % 62 == 0) || (s % 62 == 26)) { x = 60.0; theta = 25 + s % 26; if (s % 62 != 0) { x = 500.0; theta = 180 - theta; } plan_17_circle_party(x, 2.7 * tenm_cos(theta), 3.6 * tenm_sin(theta)); } } if ((t >= 1490) && (t < 1610)) { s = t - 1490; if ((s % 8 == 0) && (s % 40 < 32)) { if (s < 40) { x = 20.0; ddy = -0.06; } else if (s < 80) { x = 120.0; ddy = -0.08; } else { x = 220.0; ddy = -0.1; } if (s % 40 == 0) t_shoot = 40; else t_shoot = 9999; tenm_table_add(normal_enemy_new(x, -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 2.0, ddy * (-90.0), 0.0, ddy, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 90, t_shoot, 0, 0, 0, 1, /* shoot 1 */ 9999, 9999, 0, 0, 1, 1)); } } if ((t >= 1800) && (t < 1960)) { s = t - 1800; if ((s % 8 == 0) && (s % 40 < 32)) { if (s < 40) { x = ((double) WINDOW_WIDTH) - 10.0; ddy = -0.04; } else if (s < 80) { x = ((double) WINDOW_WIDTH) - 100.0; ddy = -0.06; } else if (s < 120) { x = ((double) WINDOW_WIDTH) - 190.0; ddy = -0.08; } else { x = ((double) WINDOW_WIDTH) - 280.0; ddy = -0.1; } if (s % 40 == 0) t_shoot = 25; else t_shoot = 9999; tenm_table_add(normal_enemy_new(x, -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, -1.5, ddy * (-90.0), 0.0, ddy, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 90, t_shoot, 0, 0, 0, 1, /* shoot 1 */ 9999, 9999, 0, 0, 1, 1)); } } if (t == 2200) tenm_table_add(warning_new()); if (t == 2330) tenm_table_add(afterdeath_new()); return SCHEDULER_SUCCESS; } static void plan_17_circle_party(double x, double dx, double dy) { int i; int t_shoot; double speed_theta; int theta; if (dx > 0.0) { speed_theta = 0.4; theta = -180; } else { speed_theta = -0.4; theta = 180; } for (i = 0; i < 4; i++) { if (i == 0) t_shoot = 9912; else t_shoot = 0; tenm_table_add(normal_enemy_new(x, -19.0 - ((double) i) * 25.0, BALL_SOLDIER, 0, 50, -1, 0, -1, 0, 5, 2, /* move 0 */ 50, 0.0, 3.0 + ((double) i) * 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 10, 3.0 * tenm_cos(i * 25), 3.0 * tenm_sin(i * 25), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3, /* move 3 */ 100, dx, dy, 0.0, 0.0, x, 150.0 - 19.0, 1.0, speed_theta, 4, /* move 4 */ 9999, 11.0 * tenm_cos(i * 25 + theta), 11.0 * tenm_sin(i * 25 + theta), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4, /* shoot 0 */ 97, 9999, t_shoot, 0, 0, 1, /* shoot 1 */ 9999, 9999, 0, 0, 1, 1)); } } dangen-0.5/spqr/plan-17.h0000644000175000017500000000026310276702741015742 0ustar00ooharaoohara00000000000000/* $Id: plan-17.h,v 1.1 2004/07/19 13:28:32 oohara Exp $ */ #ifndef __DANGEN_PLAN_17_H__ #define __DANGEN_PLAN_17_H__ int plan_17(int t); #endif /* not __DANGEN_PLAN_17_H__ */ dangen-0.5/spqr/plan-18.c0000644000175000017500000001501210276702741015734 0ustar00ooharaoohara00000000000000/* $Id: plan-18.c,v 1.80 2005/06/26 16:16:50 oohara Exp $ */ /* [very easy] Hugin */ #include #include "scheduler.h" #include "tenm_table.h" #include "hugin.h" #include "stage-title.h" #include "warning.h" #include "normal-enemy.h" #include "const.h" #include "plan-18.h" int plan_18(int t) { int i; int s; int what; double x; double y; double dx; int t_shoot; /* sanity check */ if (t < 0) return SCHEDULER_ERROR; if (t == 30) tenm_table_add(stage_title_new()); if ((t == 160) || (t == 240)) { for (i = 0; i < 4; i++) { if (i == 0) what = BALL_CAPTAIN; else what = BALL_SOLDIER; x = -19.0; dx = 6.0 - ((double) i) * 0.6; if (t == 240) { x = ((double) WINDOW_WIDTH) - x; dx *= -1.0; } tenm_table_add(normal_enemy_new(x, 0.0, what, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, dx, 4.5 - ((double) i) * 0.45, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 9999, 9999, 0, 0, 1, 0)); } } if (t == 320) { tenm_table_add(normal_enemy_new(((double) (WINDOW_WIDTH / 2)), -23.0, BRICK, 0, 0, -1, 0, -1, 0, 3, 3, /* move 0 */ 10, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 445, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, -6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 400, 46, 0, 0, 0, 1, /* shoot 1 */ 55, 9999, 0, 0, 1, 2, /* shoot 2 */ 9999, 9999, 0, 0, 0, 2)); tenm_table_add(normal_enemy_new(((double) (WINDOW_WIDTH / 2)) + 60.0, -23.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 3, 3, /* move 0 */ 10, 0.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 445, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, -8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 400, 46, 23, 0, 0, 1, /* shoot1 */ 55, 9999, 0, 0, 1, 2, /* shoot 2 */ 9999, 9999, 0, 0, 0, 2)); tenm_table_add(normal_enemy_new(((double) (WINDOW_WIDTH / 2)) - 60.0, -23.0, BALL_CAPTAIN, 0, 0, -1, 0, -1, 0, 3, 3, /* move 0 */ 10, 0.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 445, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, -8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 400, 46, 23, 0, 0, 1, /* shoot1 */ 55, 9999, 0, 0, 1, 2, /* shoot 2 */ 9999, 9999, 0, 0, 0, 2)); } if ((t >= 320) && (t < 720)) { s = t - 160; if (s % 40 == 0) { for (i = 0; i < 4; i++) { if (i == 0) what = BALL_CAPTAIN; else what = BALL_SOLDIER; x = -19.0; dx = 12.0 - ((double) i) * 1.2; if (s % 80 >= 40) { x = ((double) WINDOW_WIDTH) - x; dx *= -1.0; } tenm_table_add(normal_enemy_new(x, 0.0, what, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, dx, 9.0 - ((double) i) * 0.9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* shoot 0 */ 9999, 9999, 0, 0, 1, 0)); } } } if ((t >= 820) && (t < 1130)) { s = t - 820; if ((s % 10 == 0) && (s != 210)) { y = -19.0 - 400.0 + ((double) ((s + 90) % 100)) * 4.0; if (s % 30 == 0) t_shoot = 9969; else t_shoot = 0; tenm_table_add(normal_enemy_new(400.0, y, BALL_SOLDIER, 0, 300, -1, 0, -1, 0, 2, 3, /* move 0 */ 100, 8.0, 2.0, -0.16, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 100, -8.0, 2.0, 0.16, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 20, 9999, 0, 0, 0, 1, /* shoot 1 */ 60, 9999, t_shoot, 0, 1, 2, /* shoot 2 */ 40, 9999, 0, 0, 0, 1)); } } if (t == 1570) tenm_table_add(warning_new()); if (t == 1700) tenm_table_add(hugin_new()); return SCHEDULER_SUCCESS; } dangen-0.5/spqr/plan-18.h0000644000175000017500000000026310276702741015743 0ustar00ooharaoohara00000000000000/* $Id: plan-18.h,v 1.1 2004/07/23 12:51:46 oohara Exp $ */ #ifndef __DANGEN_PLAN_18_H__ #define __DANGEN_PLAN_18_H__ int plan_18(int t); #endif /* not __DANGEN_PLAN_18_H__ */ dangen-0.5/spqr/plan-19.c0000644000175000017500000001206011625011057015725 0ustar00ooharaoohara00000000000000/* $Id: plan-19.c,v 1.30 2011/08/23 20:48:47 oohara Exp $ */ /* [very easy] Gosanpachi */ #include /* malloc */ #include #include "scheduler.h" #include "tenm_table.h" #include "gosanpachi.h" #include "stage-title.h" #include "warning.h" #include "normal-enemy.h" #include "const.h" #include "tenm_graphic.h" #include "ship.h" #include "plan-19.h" static tenm_object *plan_19_more_1_new(void); static int plan_19_more_1_act(tenm_object *my, const tenm_object *player); static int plan_19_more_1_draw(tenm_object *my, int priority); int plan_19(int t) { /* sanity check */ if (t < 0) return SCHEDULER_ERROR; if (t == 30) tenm_table_add(stage_title_new()); if (t == 160) tenm_table_add(plan_19_more_1_new()); return SCHEDULER_SUCCESS; } static tenm_object * plan_19_more_1_new(void) { tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; count = (int *) malloc(sizeof(int) * 4); if (count == NULL) { fprintf(stderr, "plan_19_more_1_new: malloc(count) failed\n"); return NULL; } count_d = (double *) malloc(sizeof(double) * 3); if (count_d == NULL) { fprintf(stderr, "plan_19_more_1_new: malloc(count_d) failed\n"); free(count); return NULL; } /* list of count * [0] number of tries * [1] mode * [2] timer * [3] captain timer */ /* list of count_d * [0] target x * [1] speed * [2] distance */ count[0] = 0; count[1] = 0; count[2] = -1; count[3] = -1; count_d[0] = 0.0; count_d[1] = 3.0; count_d[2] = 73.0; new = tenm_object_new("plan 19 more 1", 0, 0, 1, 0.0, 0.0, 4, count, 3, count_d, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&plan_19_more_1_act), (int (*)(tenm_object *, int)) (&plan_19_more_1_draw)); if (new == NULL) { fprintf(stderr, "plan_19_more_1_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); return NULL; } return new; } static int plan_19_more_1_act(tenm_object *my, const tenm_object *player) { int what; /* sanity check */ if (my == NULL) { fprintf(stderr, "plan_19_more_1_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[2])++; switch (my->count[1]) { case 0: /* don't lock-on if the player is immutable */ if ((my->count[2] >= 0) && (get_ship() >= 0) &&(player->count[1] <= 0)) { my->count_d[0] = player->x; my->count_d[1] = 3.0; my->count_d[2] = 48.0; my->count[1] = 1; my->count[2] = -30; my->count[3] = -1; } break; case 1: /* don't lock-on if the player is immutable */ if ((my->count[2] >= 30) && ((player->x < my->count_d[0] - 20.0) || (player->x > my->count_d[0] + 20.0) || (get_ship() < 0) || (player->count[1] > 0) || (my->count[2] >= 500))) { (my->count[0])++; if (my->count[0] >= 2) { my->count[1] = 2; my->count[2] = -1; } else { my->count[1] = 0; my->count[2] = -100; } return 0; } if (my->count[2] < 0) return 0; (my->count[3])++; my->count_d[1] += 0.05; my->count_d[2] += my->count_d[1]; if (my->count_d[2] > 76.0) { if (my->count[3] >= 0) { my->count[3] = -25; what = BALL_CAPTAIN; } else { what = BALL_SOLDIER; } my->count_d[2] -= 75.0; tenm_table_add(normal_enemy_new(my->count_d[0], -19.0, what, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, my->count_d[1], 0.0, 0.05, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 9999, 0, 0, 1, 0)); } break; case 2: if (my->count[2] == 100) tenm_table_add(warning_new()); if (my->count[2] == 230) { tenm_table_add(gosanpachi_new()); return 1; } break; default: fprintf(stderr, "plan_19_more_1_act: undefined mode (%d)\n", my->count[1]); break; } return 0; } static int plan_19_more_1_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; /* sanity check */ if (my == NULL) { fprintf(stderr, "plan_19_more_1_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; color = tenm_map_color(158, 158, 158); if (my->count[1] == 1) { if (tenm_draw_line((int) (my->count_d[0]), 0, (int) (my->count_d[0]), WINDOW_HEIGHT, 1, color) != 0) status = 1; } return status; } dangen-0.5/spqr/plan-19.h0000644000175000017500000000026310276702741015744 0ustar00ooharaoohara00000000000000/* $Id: plan-19.h,v 1.1 2004/07/27 14:48:40 oohara Exp $ */ #ifndef __DANGEN_PLAN_19_H__ #define __DANGEN_PLAN_19_H__ int plan_19(int t); #endif /* not __DANGEN_PLAN_19_H__ */ dangen-0.5/spqr/plan-20.c0000644000175000017500000002730210276702741015732 0ustar00ooharaoohara00000000000000/* $Id: plan-20.c,v 1.30 2005/06/26 18:54:32 oohara Exp $ */ /* [easiest] P-can */ #include /* malloc */ #include #include "scheduler.h" #include "tenm_table.h" #include "p-can.h" #include "stage-title.h" #include "warning.h" #include "normal-enemy.h" #include "const.h" #include "plan-20.h" static tenm_object *plan_20_more_1_new(void); static int plan_20_more_1_act(tenm_object *my, const tenm_object *player); int plan_20(int t) { /* sanity check */ if (t < 0) return SCHEDULER_ERROR; if (t == 30) tenm_table_add(stage_title_new()); if (t == 160) tenm_table_add(plan_20_more_1_new()); /* if (t == 160) tenm_table_add(warning_new()); if (t == 290) tenm_table_add(p_can_new()); */ return SCHEDULER_SUCCESS; } static tenm_object * plan_20_more_1_new(void) { tenm_object *new = NULL; int *count = NULL; count = (int *) malloc(sizeof(int) * 6); if (count == NULL) { fprintf(stderr, "plan_20_more_1_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] total timer * [1] mode * [2] timer * [3] number of enemies killed/escaped */ count[0] = -1; count[1] = 0; count[2] = -1; count[3] = 0; new = tenm_object_new("plan 20 more 1", 0, 0, 1, 0.0, 0.0, 6, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&plan_20_more_1_act), (int (*)(tenm_object *, int)) NULL); if (new == NULL) { fprintf(stderr, "plan_20_more_1_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int plan_20_more_1_act(tenm_object *my, const tenm_object *player) { int i; int t_shoot; double x; /* sanity check */ if (my == NULL) { fprintf(stderr, "plan_20_more_1_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[0])++; (my->count[2])++; switch(my->count[1]) { case 0: case 2: case 4: if (my->count[2] == 0) { if (my->count[1] == 0) x = 240.0; else x = 50.0; tenm_table_add(normal_enemy_new(x, -24.0, BALL_CAPTAIN, 0, 0, my->table_index, 3, my->table_index, 3, 3, 1, /* move 0 */ 20, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 150, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 9999, 9999, 0, 0, 1, 0)); } if (my->count[3] >= 1) { (my->count[1])++; my->count[2] = -1; my->count[3] = 0; } break; case 1: case 3: case 5: if (my->count[2] == 0) { if (my->count[1] == 1) x = ((double) WINDOW_WIDTH) - 240.0; else x = ((double) WINDOW_WIDTH) - 50.0; tenm_table_add(normal_enemy_new(x, -24.0, BALL_CAPTAIN, 0, 0, my->table_index, 3, my->table_index, 3, 3, 1, /* move 0 */ 20, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 150, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 9999, 9999, 0, 0, 1, 0)); } if (my->count[3] >= 1) { if ((my->count[1] == 5) && (my->count[0] >= 700)) my->count[1] = 7; else (my->count[1])++; my->count[2] = -1; my->count[3] = 0; } break; case 6: if (my->count[0] >= 701) { my->count[1] = 7; my->count[2] = -150; my->count[3] = 0; } if (my->count[2] % 12 == 0) { if (my->count[2] < 84) { tenm_table_add(normal_enemy_new((double) (WINDOW_WIDTH / 2), -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 1, /* move 0 */ 9999, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 9999, 9999, 0, 0, 1, 0)); } else if (my->count[2] < 154) { /* do nothing */ ; } else if (my->count[2] < 204) { tenm_table_add(normal_enemy_new((double) (WINDOW_WIDTH / 2), -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 80, 9999, 0, 0, 0, 1, /* shoot 0 */ 9999, 9999, 0, 0, 1, 1)); } else if (my->count[2] < 252) { /* do nothing */ ; } else if (!((my->count[2] >= 360) && (my->count[2] < 396))) { if (my->count[2] % 24 == 0) t_shoot = 40; else t_shoot = 9999; x = ((double) (WINDOW_WIDTH / 2)); if (my->count[2] >= 360) { x = ((double) ((my->count[2] % 36) / 12)) * 40.0; x += ((double) (WINDOW_WIDTH / 2)) - 40.0; } tenm_table_add(normal_enemy_new(x, -19.0, BALL_SOLDIER, 0, 0, -1, 0, -1, 0, 1, 2, /* move 0 */ 9999, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, /* shoot 0 */ 40, t_shoot, my->count[2] % t_shoot, 0, 0, 1, /* shoot 0 */ 9999, 9999, 0, 0, 1, 1)); } } break; case 7: if (my->count[2] == 30) { tenm_table_add(normal_enemy_new((double) (WINDOW_WIDTH / 2), -23.0, BRICK, 0, 0, my->table_index, 3, my->table_index, 3, 3, 1, /* move 0 */ 20, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 300, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 9999, 73, 0, 0, 1, 0)); tenm_table_add(normal_enemy_new((double) (WINDOW_WIDTH / 2) + 150.0, -24.0, SQUARE, 0, 0, my->table_index, 3, my->table_index, 3, 3, 1, /* move 0 */ 20, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 300, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 9999, 73, 20, 157, 1, 0)); tenm_table_add(normal_enemy_new((double) (WINDOW_WIDTH / 2) - 150.0, -24.0, SQUARE, 0, 0, my->table_index, 3, my->table_index, 3, 3, 1, /* move 0 */ 20, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 300, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 9999, 73, 20, 23, 1, 0)); } if (my->count[3] >= 3) { if (my->count[2] <= 130) my->count[1] = 8; else my->count[1] = 9; my->count[2] = -1; my->count[3] = 0; } break; case 8: if (my->count[2] == 30) { for (i = 0; i < 4; i++) { x = 50.0 + 180.0 * ((double) i); tenm_table_add(normal_enemy_new(x, -24.0, SQUARE, 0, 0, my->table_index, 3, my->table_index, 3, 3, 1, /* move 0 */ 20, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, /* move 1 */ 300, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* move 2 */ 9999, 0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2, /* shoot 0 */ 9999, 73, 0, 90, 1, 0)); } } if (my->count[3] >= 4) { my->count[1] = 9; my->count[2] = -1; my->count[3] = 0; } break; case 9: if (my->count[2] == 100) tenm_table_add(warning_new()); if (my->count[2] == 230) { tenm_table_add(p_can_new()); return 1; } break; default: fprintf(stderr, "plan_20_more_1_act: undefined mode (%d)\n", my->count[1]); break; } return 0; } dangen-0.5/spqr/plan-20.h0000644000175000017500000000026310276702741015734 0ustar00ooharaoohara00000000000000/* $Id: plan-20.h,v 1.1 2004/08/07 08:05:30 oohara Exp $ */ #ifndef __DANGEN_PLAN_20_H__ #define __DANGEN_PLAN_20_H__ int plan_20(int t); #endif /* not __DANGEN_PLAN_20_H__ */ dangen-0.5/spqr/player-shot.c0000644000175000017500000002354410276702741017034 0ustar00ooharaoohara00000000000000/* $Id: player-shot.c,v 1.93 2004/08/30 16:23:27 oohara Exp $ */ #include /* malloc, rand */ #include /* strcmp */ #include #include "const.h" #include "tenm_graphic.h" #include "tenm_object.h" #include "tenm_primitive.h" #include "tenm_math.h" #include "tenm_input.h" #include "util.h" #include "score.h" #include "chain.h" #include "player-shot.h" #define NEAR_ZERO 0.0001 static int player_shot_move(tenm_object *my, double turn_per_frame); static int player_shot_hit(tenm_object *my, tenm_object *your); static int player_shot_draw(tenm_object *my, int priority); static int player_shot_act(tenm_object *my, const tenm_object *player); static int player_shot_explode(tenm_object *my); static int deal_damage2(tenm_object *my, tenm_object *your); tenm_object * player_shot_new(double x, double y, int n) { tenm_primitive **p; tenm_object *new; int *count = NULL; double *count_d = NULL; /* sanity check */ if ((n < 0) || (n >= 4)) { fprintf(stderr, "player_shot_new: strange n (%d)\n", n); return NULL; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "player_shot_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_circle_new(x, y, 10.0); if (p[0] == NULL) { fprintf(stderr, "player_shot_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 4); if (count == NULL) { fprintf(stderr, "player_shot_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 4); if (count_d == NULL) { fprintf(stderr, "player_new: malloc(count_d) failed\n"); (p[0])->delete(p[0]); free(p); if (count != NULL) free(count); return NULL; } count[0] = 1; count[1] = 0; count[2] = 0; count[3] = 0; if (n == 0) { count_d[0] = 0.0; count_d[1] = -52.0; } else if (n == 1) { count_d[0] = 0.0; count_d[1] = 52.0; } else if (n == 2) { count_d[0] = 48.0; count_d[1] = -20.0; } else { count_d[0] = -48.0; count_d[1] = -20.0; } count_d[2] = x; count_d[3] = y; /* list of count * [0] phase (begins with 1) * [1] explosion timer * [2] trail timer * [3] "hit during phase 1" flag */ /* list of count_d * [0] speed x * [1] speed y * [2] origin x * [3] origin y */ new =tenm_object_new("player shot", ATTR_PLAYER_SHOT, ATTR_BOSS | ATTR_ENEMY | ATTR_OBSTACLE | ATTR_OPAQUE, 20, x, y, 4, count, 4, count_d, 1, p, (int (*)(tenm_object *, double)) (&player_shot_move), (int (*)(tenm_object *, tenm_object *)) (&player_shot_hit), (int (*)(tenm_object *, const tenm_object *)) (&player_shot_act), (int (*)(tenm_object *, int)) (&player_shot_draw)); if (new == NULL) { fprintf(stderr, "player_shot_new: tenm_object_new failed\n"); free(count_d); free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int player_shot_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) return 0; if (turn_per_frame <= 0.5) return 0; if (my->count[0] != 1) return 0; if (my->hit_point <= 0) return 0; if (my->count[3] != 0) { my->attr = 0; my->hit_mask = 0; return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; tenm_move_mass(my->mass, dx_temp, dy_temp); if (!in_window_object(my)) { my->attr = 0; my->hit_mask = 0; my->hit_point = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; clear_chain(); /* we have to wait for the trail to disappear */ return 0; } return 0; } static int player_shot_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) return 0; if (your == NULL) return 0; if (my->count[0] == 1) { /* don't call player_shot_explode() here --- hit() of the enemy * may or may not be called before this */ my->count[3] = 1; return 0; } return 0; } static int player_shot_act(tenm_object *my, const tenm_object *player) { /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; if ((my->count[0] < 1) || (my->count[0] > 2)) { fprintf(stderr, "player_shot_act: strange mode (%d)\n", my->count[0]); return 1; } if (my->hit_point > 0) { if (my->count[0] == 1) { /* explode if we hit something */ if (my->count[3] != 0) player_shot_explode(my); } else if (my->count[0] == 2) { (my->count[1])++; if (my->count[1] > 30) { my->attr = 0; my->hit_mask = 0; my->hit_point = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; /* no "return 1" here --- we have to wait * for the trail to disappear */ } } } if (my->count[2] >= 32) { if (my->hit_point <= 0) return 1; } else { (my->count[2])++; } return 0; } static int player_shot_draw(tenm_object *my, int priority) { int i; double length; int theta; int red_orig; int green_orig; int blue_orig; tenm_color color; int status = 0; /* sanity check */ if (my == NULL) return 0; if ((priority != 0) && (priority != -1)) return 0; color = tenm_map_color(134, 215, 170); if (priority == 0) { if ((my->count[0] == 1) && (my->hit_point > 0)) { if (tenm_draw_circle((int) my->x, (int) my->y, 10, 1, color) != 0) status = 1; } else if (my->count[0] == 2) { for (i = 0; i < 10 - my->count[1] / 3; i++) { length = 50.0 - 5.0 * ((double) (rand() % 32)) / 32.0; theta = rand() % 360; if (tenm_draw_line((int) my->x, (int) my->y, (int) (my->x + length * tenm_cos(theta)), (int) (my->y + length * tenm_sin(theta)), 1, color) != 0) status = 1; } for (i = 0; i < 30 - my->count[1]; i++) { length = 50.0 - 25.0 * ((double) (rand() % 32)) / 32.0; theta = rand() % 360; if (tenm_draw_line((int) my->x, (int) my->y, (int) (my->x + length * tenm_cos(theta)), (int) (my->y + length * tenm_sin(theta)), 1, color) != 0) status = 1; } if (tenm_draw_circle((int) my->x, (int) my->y, 50, 1, color) != 0) status = 1; } } else if (priority == -1) { /* don't draw the trail if the shot did not move at all */ if ((my->count[2] > 0) && (my->count[2] < 32)) { if ((my->count[0] == 1) && (my->hit_point <= 0)) { red_orig = 63; green_orig = 63; blue_orig = 63; } else { red_orig = 134; green_orig = 215; blue_orig = 170; } color = tenm_map_color((red_orig * (32- my->count[2]) + DEFAULT_BACKGROUND_RED * my->count[2]) / 32, (green_orig * (32- my->count[2]) + DEFAULT_BACKGROUND_GREEN * my->count[2]) / 32, (blue_orig * (32- my->count[2]) + DEFAULT_BACKGROUND_BLUE * my->count[2]) / 32); if (tenm_draw_line((int) (my->x), (int) (my->y), (int) (my->count_d[2]), (int) (my->count_d[3]), 1, color) != 0) status = 1; } } return status; } /* return 0 on success, 1 on error */ static int player_shot_explode(tenm_object *my) { /* sanity check */ if (my == NULL) { fprintf(stderr, "player_shot_explode: my is NULL\n"); return 1; } if (my->name == NULL) { fprintf(stderr, "player_shot_explode: my->name is NULL\n"); return 1; } if (strcmp(my->name, "player shot") != 0) { fprintf(stderr, "player_shot_explode: my->name is not \"player shot\"\n"); return 1; } my->attr = ATTR_PLAYER_SHOT; my->hit_mask = 0; my->hit_point = 1; my->count[0] = 2; my->count[1] = 1; ((tenm_circle *) my->mass->p[0])->r = 50.0; return 0; } /* damage handling function for hit() of an enemy * my is the enemy, your is the player shot * n (arg 3) is the index of count[] for phase 2 boomerang handling * you must set my->count[n] to 0 in act() every frame * warning: turn_per_frame is hard-coded */ int deal_damage(tenm_object *my, tenm_object *your, int n) { /* sanity check */ if (my == NULL) { fprintf(stderr, "deal_damage: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "deal_damage: your is NULL\n"); return 0; } if ((n < 0) || (n >= my->n)) { fprintf(stderr, "deal_damage: strange n (%d)\n", n); return 0; } if (your->count[0] == 1) { deal_damage2(my, your); } else if (your->count[0] == 2) { my->count[n] -= 1; if (my->count[n] <= 0) { deal_damage2(my, your); /* turn_per_frame */ my->count[n] = 30; } } return 0; } /* change the hit point of the enemy and add score * my is the enemy, your is the player shot */ static int deal_damage2(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "deal_damage: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "deal_damage: your is NULL\n"); return 0; } if (my->hit_point <= your->hit_point) { add_score(my->hit_point - 1); my->hit_point = 0; } else { add_score(your->hit_point); my->hit_point -= your->hit_point; } return 0; } dangen-0.5/spqr/player-shot.h0000644000175000017500000000047610276702741017040 0ustar00ooharaoohara00000000000000/* $Id: player-shot.h,v 1.5 2004/07/06 02:49:50 oohara Exp $ */ #ifndef __DANGEN_PLAYER_SHOT_H__ #define __DANGEN_PLAYER_SHOT_H__ #include "tenm_object.h" tenm_object *player_shot_new(double x, double y, int n); int deal_damage(tenm_object *my, tenm_object *your, int n); #endif /* not __DANGEN_PLAYER_SHOT_H__ */ dangen-0.5/spqr/player.c0000644000175000017500000004573110276702741016063 0ustar00ooharaoohara00000000000000/* $Id: player.c,v 1.187 2005/07/12 18:12:06 oohara Exp $ */ #include /* malloc */ #include /* strcmp, strlen */ #include #include "const.h" #include "tenm_graphic.h" #include "tenm_input.h" #include "tenm_object.h" #include "tenm_primitive.h" #include "player-shot.h" #include "tenm_table.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "chain.h" #include "ship.h" /* delete_enemy_shot */ #include "util.h" /* easter egg */ #include "plan-0.h" #include "player.h" #define TIME_RESTART 40 #define TIME_IMMUTABLE 50 #define TIME_OPPOSITE_DIRECTION 15 #define TIME_ROLLING 24 static int player_draw(tenm_object *my, int priority); static int player_move(tenm_object *my, double turn_per_frame); static int player_hit(tenm_object *my, tenm_object *your); static int player_act(tenm_object *my, const tenm_object *player); static int player_draw_wing(int x, int y, int n, int theta, int red_orig, int green_orig, int blue_orig); static int player_shoot(tenm_object *my, int k); static int player_shoot_direction(int k); static int player_tutorial_input(int t); tenm_object * player_new(int tutorial) { double x; double y; tenm_primitive **p = NULL; int *count = NULL; double *count_d = NULL; tenm_object *player = NULL; /* sanity check */ if ((tutorial < 0) || (tutorial > 1)) { fprintf(stderr, "player_new: strange tutorial (%d)\n", tutorial); return NULL; } x = ((double) WINDOW_WIDTH) / 2.0; y = ((double) WINDOW_HEIGHT) * 0.9; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "player_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_circle_new(x, y, 5.0); if (p[0] == NULL) { fprintf(stderr, "player_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 10); if (count == NULL) { fprintf(stderr, "player_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "player_new: malloc(count_d) failed\n"); (p[0])->delete(p[0]); free(p); if (count != NULL) free(count); return NULL; } count[0] = 0; count[1] = 50; count[2] = tutorial; count[3] = 0; count[4] = 0; count[5] = 0; count[6] = -1; count[7] = 0; count[8] = 0; count[9] = 0; count_d[0] = 0.0; count_d[1] = 0.0; /* list of count * [0] shoot wait (no auto-repeat) * -1: the shot key is being pressed and has not been released * since the last shot * 0: the shot key is not pressed * 1: the shot key is being pressed and has been released * since the last shot * [1] immutable time * [2] input mode * 0: normal game * 1: tutorial * 2: easter egg * [3] input timer (for tutorial) * [4] rolling/recharge timer * [5] rolling theta * [6] rolling direction * [7] normal roll theta * [8] slow move timer * [9] easter egg trigger timer */ /* * list of cound_d * [0] speed x * [1] speed y */ player = tenm_object_new("player", ATTR_PLAYER, 0, 1, x, y, 10, count, 2, count_d, 1, p, (int (*)(tenm_object *, double)) (&player_move), (int (*)(tenm_object *, tenm_object *)) (&player_hit), (int (*)(tenm_object *, const tenm_object *)) (&player_act), (int (*)(tenm_object *, int)) (&player_draw)); if (player == NULL) { fprintf(stderr, "player_new: tenm_object_new failed\n"); (p[0])->delete(p[0]); free(p); if (count != NULL) free(count); if (count_d != NULL) free(count_d); return NULL; } return player; } static int player_draw(tenm_object *my, int priority) { int red; int green; int blue; int theta; int k; int status = 0; /* sanity check */ if ((priority < 0) || (priority >= 2)) return 0; /* we don't check my == NULL here because this can be called * even if the game is over */ /* no need to draw the player if the game is over */ if (get_ship() < 0) { if (priority == 1) draw_string(280, 280, "game over", 9); return 0; } /* sanity check again */ if (my == NULL) return 0; if (priority != 0) return 0; /* input display */ if (my->count[2] == 1) { k = player_tutorial_input(my->count[3]); if (k & 1) { if (draw_string(490, 320, " UP ", 5) != 0) status = 1; } else { if (draw_string(490, 320, "-----", 5) != 0) status = 1; } if (k & 2) { if (draw_string(490, 360, "DOWN ", 5) != 0) status = 1; } else { if (draw_string(490, 360, "-----", 5) != 0) status = 1; } if (k & 4) { if (draw_string(540, 340, "RIGHT", 5) != 0) status = 1; } else { if (draw_string(540, 340, "-----", 5) != 0) status = 1; } if (k & 8) { if (draw_string(440, 340, "LEFT ", 5) != 0) status = 1; } else { if (draw_string(440, 340, "-----", 5) != 0) status = 1; } if (k & 16) { if (draw_string(590, 360, "SPACE", 5) != 0) status = 1; } else { if (draw_string(590, 360, "-----", 5) != 0) status = 1; } if (draw_string(460, 400, "press ESC to quit", 17) != 0) status = 1; } if (my->count[1] > TIME_IMMUTABLE) return 0; /* decoration */ if (my->count[1] > 0) { if (my->count[4] > 0) { red = 216; green = 167; blue = 214; } else { red = 172; green = 204; blue = 214; } if (tenm_draw_circle((int) (my->x), (int) (my->y), 5 + my->count[1] * 3, 1, tenm_map_color(red, green, blue)) != 0) status = 1; } /* body */ if (my->count[1] > 0) { if (my->count[4] > 0) { red = 177; green = 89; blue = 237; } else { red = 89; green = 164; blue = 237; } } else { if (my->count[4] > 0) { red = 86; green = 10; blue = 139; } else { red = 10; green = 75; blue = 139; } } theta = my->count[5] + my->count[7]; player_draw_wing((int) (my->x), (int) (my->y), 0, theta, red, green, blue); player_draw_wing((int) (my->x), (int) (my->y), 0, theta + 120, red, green, blue); player_draw_wing((int) (my->x), (int) (my->y), 0, theta - 120, red, green, blue); player_draw_wing((int) (my->x), (int) (my->y), 1, theta + 90, red, green, blue); player_draw_wing((int) (my->x), (int) (my->y), 1, theta - 90, red, green, blue); if (tenm_draw_circle((int) (my->x), (int) (my->y), 5, 2, tenm_map_color(red, green, blue)) != 0) status = 1; /* may be useful for debugging */ /* if (tenm_draw_primitive(my->mass->p[0], tenm_map_color(0, 0, 0)) != 0) status = 1; */ /* { char temp[32]; sprintf(temp, "%3.1f", my->x); if (my->x > ((double) WINDOW_WIDTH * 2 / 3)) { if (draw_string((int) (my->x - 100.0), (int) (my->y - 10.0), temp, (int) strlen(temp)) != 0) status = 1; } else { if (draw_string((int) (my->x + 50.0), (int) (my->y - 10.0), temp, (int) strlen(temp)) != 0) status = 1; } sprintf(temp, "%3.1f", my->y); if (my->x > ((double) WINDOW_WIDTH * 2 / 3)) { if (draw_string((int) (my->x - 100.0), (int) (my->y + 10.0), temp, (int) strlen(temp)) != 0) status = 1; } else { if (draw_string((int) (my->x + 50.0), (int) (my->y + 10.0), temp, (int) strlen(temp)) != 0) status = 1; } } */ return status; } static int player_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) return 0; if (turn_per_frame <= 0.5) return 0; dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; /* boundary check */ if (my->x + dx_temp < 0.0) dx_temp = -(my->x); else if (my->x + dx_temp > (double) WINDOW_WIDTH) dx_temp = ((double) WINDOW_WIDTH) - my->x; if (my->y + dy_temp < 0.0) dy_temp = -(my->y); else if (my->y + dy_temp > (double) WINDOW_HEIGHT) dy_temp = ((double) WINDOW_HEIGHT) - my->y; my->x += dx_temp; my->y += dy_temp; tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int player_hit(tenm_object *my, tenm_object *your) { double speed_theta; /* sanity check */ if (my == NULL) return 0; if (your == NULL) return 0; if (my->count[4] > 0) speed_theta = 30.0 * ((double) (my->count[6])); else speed_theta = 0.0; tenm_table_add(fragment_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 50.0, 5, 10, 5.0, speed_theta, 20)); tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 3, 50, 10, 2.0, 12)); my->hit_mask = 0; my->hit_point = 0; my->count[0] = -1; my->count[1] = TIME_RESTART + TIME_IMMUTABLE; my->count_d[0] = 0.0; my->count_d[1] = 0.0; return 0; } /* list of keys * 1 TENM_KEY_UP * 2 TENM_KEY_DOWN * 4 TENM_KEY_RIGHT * 8 TENM_KEY_LEFT * 16 TENM_KEY_SPACE (shoot) * 32 TENM_KEY_ESCAPE (quit) * 64 TENM_KEY_p (pause) * 128 TENM_KEY_CAPSLOCK (cheat --- slow down) */ /* note that "player" (arg 2) is NULL */ static int player_act(tenm_object *my, const tenm_object *player) { int key_status; double speed; double speed_diagonal; /* sanity check */ if (my == NULL) return 0; if ((get_ship() < 0) || (my->count[1] > 0)) (my->count[1])--; if (get_ship() < 0) { if (my->count[1] <= TIME_IMMUTABLE * (-2)) return 1; return 0; } key_status = tenm_get_key_status(); if (my->count[2] == 1) { if (key_status & 31) { (my->count[9])++; if (my->count[9] >= 40) { tenm_table_apply_all((int (*)(tenm_object *, int)) (&plan_0_more_1_easter_egg), 0); my->count[2] = 2; my->count[9] = 0; } } else { my->count[9] = 0; } /* tutorial input */ key_status = player_tutorial_input(my->count[3]); (my->count[3])++; } if (my->count[1] == TIME_IMMUTABLE) { /* player restarts */ add_ship(-1); if (get_ship() < 0) return 0; player_neutral_position(my); /* clear enemy shots */ tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); } if (my->count[1] <= 0) my->hit_mask = ATTR_BOSS | ATTR_ENEMY | ATTR_ENEMY_SHOT | ATTR_OBSTACLE | ATTR_OPAQUE; if (my->hit_point == 0) return 0; /* note that 8.0 * sqrt(2.0) / 2.0 = 5.656... */ /* speed = 8.0; speed_diagonal = 5.656; */ if (my->count[8] < 0) my->count[8] = 0; if (my->count[8] > 10) my->count[8] = 10; /* speed = 5.5 + ((double) (my->count[8])) * 0.25; */ speed = 2.5 + ((double) (my->count[8])) * 0.55; speed_diagonal = speed * tenm_sqrt(2) / 2.0; if (!(key_status & 16)) { if (key_status & 15) { my->count[8] += 2; if (my->count[8] > 10) my->count[8] = 10; } else { (my->count[8])--; if (my->count[8] < 0) my->count[8] = 0; /* my->count[8] = 0; */ } } /* first, refuse to move for a stupid player */ if ((key_status & 1) && (key_status & 2)) { my->count_d[1] = 0.0; my->count_d[0] = 0.0; /* don't reset my->count[8] here to prevent abuse of "wrong" input */ } else if ((key_status & 4) && (key_status & 8)) { my->count_d[1] = 0.0; my->count_d[0] = 0.0; /* don't reset my->count[8] here to prevent abuse of "wrong" input */ } else if (key_status & 1) { if (key_status & 4) { my->count_d[1] = -speed_diagonal; my->count_d[0] = speed_diagonal; } else if (key_status & 8) { my->count_d[1] = -speed_diagonal; my->count_d[0] = -speed_diagonal; } else { my->count_d[1] = -speed; my->count_d[0] = 0.0; } } else if (key_status & 2) { if (key_status & 4) { my->count_d[1] = speed_diagonal; my->count_d[0] = speed_diagonal; } else if (key_status & 8) { my->count_d[1] = speed_diagonal; my->count_d[0] = -speed_diagonal; } else { my->count_d[1] = speed; my->count_d[0] = 0.0; } } else { if (key_status & 4) { my->count_d[1] = 0.0; my->count_d[0] = speed; } else if (key_status & 8) { my->count_d[1] = 0.0; my->count_d[0] = -speed; } else { my->count_d[1] = 0.0; my->count_d[0] = 0.0; } } /* normal rolling */ if ((key_status & 8) && (!(key_status & 4))) { my->count[7] += 3; if (my->count[7] > 30) my->count[7] = 30; } else if ((key_status & 4) && (!(key_status & 8))) { my->count[7] -= 3; if (my->count[7] < -30) my->count[7] = -30; } else { if (my->count[7] > 3) my->count[7] -= 3; else if (my->count[7] < -3) my->count[7] += 3; else my->count[7] = 0; } /* rolling/recharge count down */ if (my->count[4] > 0) { my->count[5] += 15 * my->count[6]; while (my->count[5] > 360) my->count[5] -= 360; while (my->count[5] < 0) my->count[5] += 360; (my->count[4])--; } /* shoot */ if (key_status & 16) { my->count_d[1] = 0.0; my->count_d[0] = 0.0; /* don't reset my->count[8] --- no speed down */ if ((my->count[4] <= 0) && (my->count[0] >= 0)) { switch (key_status & 15) { case 1: case 2: case 4: case 8: player_shoot(my, key_status & 15); break; default: my->count[0] = 1; break; } } } else { if (my->count[0] > 0) { player_shoot(my, 0); } my->count[0] = 0; } return 0; } void player_neutral_position(tenm_object *my) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) return; if (strcmp(my->name, "player") != 0) return; my->hit_point = 1; dx_temp = ((double) WINDOW_WIDTH) / 2.0 - my->x; dy_temp = ((double) WINDOW_HEIGHT) * 0.9 - my->y; my->x += dx_temp; my->y += dy_temp; tenm_move_mass(my->mass, dx_temp, dy_temp); /* reset rolling */ my->count[4] = 0; my->count[5] = 0; /* my->count[6] = 1; */ /* reset shoot */ my->count[0] = 0; /* neutral rolling */ my->count[7] = 0; /* reset move speed */ my->count[8] = 0; /* reset chain */ clear_chain(); } static int player_draw_wing(int x, int y, int n, int theta, int red_orig, int green_orig, int blue_orig) { double dx; double dy; int temp; tenm_color color; int status = 0; double length; int red; int green; int blue; while (theta < 0) theta += 360; while (theta >= 360) theta -= 360; /* these magic numbers are chosen so that the rear wings indicate * the path of player shots */ if (n == 0) { length = 35.0; dx = length * 0.8917 * tenm_sin(theta + 180); dy = length * (0.4526 * 0.9659 + 0.8917 * 0.2588 * tenm_cos(theta + 180)); dx *= -1.0; dy *= -1.0; } else { length = 50.0; dx = length * 0.9182 * tenm_sin(theta); dy = length * (0.3961 * 0.9659 + 0.9182 * 0.2588 * tenm_cos(theta)); } if (theta <= 180) temp = 180 - theta; else temp = theta - 180; red = (red_orig * (256 - temp) + DEFAULT_BACKGROUND_RED * temp) / 256; green = (green_orig * (256 - temp) + DEFAULT_BACKGROUND_GREEN * temp) / 256; blue = (blue_orig * (256 - temp) + DEFAULT_BACKGROUND_BLUE * temp) / 256; color = tenm_map_color(red, green, blue); if (tenm_draw_line(x, y, x + (int) dx, y + (int) dy, 1, color) != 0) { status = 1; } return status; } /* return 0 on success, 1 on error */ static int player_shoot(tenm_object *my, int k) { /* sanity check */ if (my == NULL) { /* not an error */ return 0; } if (k < 0) { fprintf(stderr, "player_shoot_: k is negative (%d)\n", k); return 1; } tenm_table_add(player_shot_new(my->x, my->y, player_shoot_direction(k))); my->count[4] = TIME_ROLLING; my->count[0] = -1; /* set rolling direction */ switch (player_shoot_direction(k)) { case 0: my->count[6] *= -1; break; case 1: my->count[6] *= -1; break; case 2: my->count[6] = -1; break; case 3: my->count[6] = 1; break; default: break; } return 0; } static int player_shoot_direction(int k) { /* sanity check */ if (k < 0) { fprintf(stderr, "player_shoot_direction: k is negative (%d)\n", k); return 0; } if ((k & 1) && (k & 2)) { return 0; } else if ((k & 4) && (k & 8)) { return 0; } else { if (k & 4) return 2; else if (k & 8) return 3; else if (k & 2) return 1; else return 0; } /* should not reach here */ fprintf(stderr, "player_shoot_direction: fall off (%d)\n", k); return 0; } static int player_tutorial_input(int t) { /* sanity check */ if (t < 0) { fprintf(stderr, "player_tutorial_input: t is negative (%d)\n", t); return 0; } if ((t >= 160) && (t < 190)) return 8; if ((t >= 200) && (t < 230)) return 1; if ((t >= 240) && (t < 260)) return 6; if ((t >= 260) && (t < 270)) return 4; if ((t >= 270) && (t < 280)) return 10; if ((t >= 280) && (t < 285)) return 8; if ((t >= 340) && (t < 700)) return 16; if ((t >= 700) && (t < 730)) return 17; if ((t >= 730) && (t < 735)) return 16; if ((t >= 770) && (t < 775)) return 16; if ((t >= 775) && (t < 780)) return 24; if ((t >= 780) && (t < 785)) return 16; if ((t >= 2235) && (t < 2240)) return 16; if ((t >= 2240) && (t < 2245)) return 17; if ((t >= 2245) && (t < 2250)) return 16; if ((t >= 2260) && (t < 2278)) return 8; if ((t >= 2295) && (t < 2300)) return 16; if ((t >= 2300) && (t < 2305)) return 17; if ((t >= 2305) && (t < 2310)) return 16; if ((t >= 2320) && (t < 2338)) return 8; if ((t >= 2355) && (t < 2360)) return 16; if ((t >= 2360) && (t < 2365)) return 17; if ((t >= 2365) && (t < 2370)) return 16; if ((t >= 2660) && (t < 2665)) return 16; if ((t >= 2665) && (t < 2670)) return 20; if ((t >= 2670) && (t < 2675)) return 16; if ((t >= 2860) && (t < 2865)) return 16; if ((t >= 2865) && (t < 2870)) return 17; if ((t >= 2870) && (t < 2875)) return 16; if ((t >= 2890) && (t < 2920)) return 4; return 0; } dangen-0.5/spqr/player.h0000644000175000017500000000041310276702741016054 0ustar00ooharaoohara00000000000000/* $Id: player.h,v 1.3 2004/07/06 02:49:29 oohara Exp $ */ #ifndef __DANGEN_PLAYER_H__ #define __DANGEN_PLAYER_H__ #include "tenm_object.h" tenm_object *player_new(int tutorial); void player_neutral_position(tenm_object *my); #endif /* not __DANGEN_PLAYER_H__ */ dangen-0.5/spqr/respiration.c0000644000175000017500000002634110276702741017122 0ustar00ooharaoohara00000000000000/* $Id: respiration.c,v 1.118 2004/09/06 20:25:34 oohara Exp $ */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "score.h" #include "respiration.h" #define NEAR_ZERO 0.0001 static int respiration_move(tenm_object *my, double turn_per_frame); static int respiration_hit(tenm_object *my, tenm_object *your); static int respiration_act(tenm_object *my, const tenm_object *player); static int respiration_draw(tenm_object *my, int priority); static int respiration_green(const tenm_object *my); static int respiration_signal(tenm_object *my, int n); tenm_object * respiration_new(int table_index) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = (double) (WINDOW_WIDTH / 2); double y = -120.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "respiration_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_circle_new(x, y, 45.0); if (p[0] == NULL) { fprintf(stderr, "respiration_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 4); if (count == NULL) { fprintf(stderr, "respiration_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "respiration_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] life timer * [3] more index */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = 0; count[1] = 0; count[2] = -40; count[3] = table_index; count_d[0] = 0.0; count_d[1] = 6.0; new = tenm_object_new("Respiration", ATTR_ENEMY, ATTR_PLAYER_SHOT, 350, x, y, 4, count, 2, count_d, 1, p, (int (*)(tenm_object *, double)) (&respiration_move), (int (*)(tenm_object *, tenm_object *)) (&respiration_hit), (int (*)(tenm_object *, const tenm_object *)) (&respiration_act), (int (*)(tenm_object *, int)) (&respiration_draw)); if (new == NULL) { fprintf(stderr, "respiration_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int respiration_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "respiration_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "respiration_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int respiration_hit(tenm_object *my, tenm_object *your) { int n; /* sanity check */ if (my == NULL) { fprintf(stderr, "respiration_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "respiration_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; deal_damage(my, your, 0); if (respiration_green(my)) add_chain(my, your); my->count[1] = 41; if (my->hit_point <= 0) { add_score(150); tenm_table_apply(my->count[3], (int (*)(tenm_object *, int)) (&respiration_signal), 0); if (respiration_green(my)) n = 8; else n = 7; tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 1, 1000, n, 8.0, 6)); tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 2, 300, n, 5.0, 8)); return 1; } return 0; } static int respiration_act(tenm_object *my, const tenm_object *player) { int i; double x; double dx; double dy; double length; /* sanity check */ if (my == NULL) { fprintf(stderr, "respiration_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; (my->count[2])++; /* encounter */ if (my->count[2] < 0) return 0; /* escape */ if (my->count[2] >= 1200) { my->count_d[0] = 0.0; my->count_d[1] = -6.0; if (my->count[2] >= 1240) return 1; return 0; } /* speed change */ if (my->count[2] % 200 < 40) { my->count_d[0] = -6.0; } else if (my->count[2] % 200 < 60) { my->count_d[0] = 0.0; } else if (my->count[2] % 200 < 140) { my->count_d[0] = 6.0; } else if (my->count[2] % 200 < 160) { my->count_d[0] = 0.0; } else { my->count_d[0] = -6.0; } my->count_d[1] = 0.0; /* shoot */ if (my->count[2] % 13 == 0) { dx = player->x - my->x; dy = player->y - my->y; length = tenm_sqrt((int) (dx * dx + dy * dy)); if (length < NEAR_ZERO) length = 1.0; tenm_table_add(laser_point_new(my->x, my->y, 6.0, player->x, player->y, 25.0, 4)); tenm_table_add(laser_point_new(my->x, my->y, 7.5, player->x + dx * 0.25, player->y - dy * 0.25, 25.0, 4)); tenm_table_add(laser_point_new(my->x, my->y, 9.0, player->x + dx * 0.5, player->y - dy * 0.5, 25.0, 4)); } if (my->count[2] % 46 == 0) { for (i = -19; i <= 37; i += 4) { if (player->x > my->x) { x = my->x - 40.0; dx = 4.0 + ((double) i) * 0.1; } else { x = my->x + 40.0; dx = -(4.0 + ((double) i) * 0.1); } if (player->y > my->y) dy = 4.0 - ((double) (i * i)) / 200.0; else dy = 1.0 - ((double) (i * i)) / 200.0; tenm_table_add(normal_shot_new(x, my->y, dx, dy, 2, -2, 0)); } } if (my->count[2] % 46 == 23) { for (i = -19; i <= 37; i += 4) { if (player->x > my->x) { x = my->x - 40.0; dx = 3.0 + ((double) i) * 0.1; } else { x = my->x + 40.0; dx = -(3.0 + ((double) i) * 0.1); } if (player->y > my->y) dy = 1.0 + ((double) (i * i)) / 200.0; else dy = -1.0 + ((double) (i * i)) / 200.0; tenm_table_add(normal_shot_new(x, my->y, dx, dy, 2, -2, 0)); } } return 0; } static int respiration_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; /* sanity check */ if (my == NULL) { fprintf(stderr, "respiration_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; /* decoration */ if (respiration_green(my)) { if (my->count[1] >= 40) color = tenm_map_color(181, 190, 92); else color = tenm_map_color(157, 182, 123); } else { if (my->count[1] >= 40) color = tenm_map_color(200, 164, 92); else color = tenm_map_color(182, 147, 123); } if (tenm_draw_line(((int) (my->x + 5.0002)), ((int) (my->y - 62.4167)), ((int) (my->x + 48.3334)), ((int) (my->y - 50.8056)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + 48.3334)), ((int) (my->y - 50.8056)), ((int) (my->x + 95.9487)), ((int) (my->y + 31.6667)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + 95.9487)), ((int) (my->y + 31.6667)), ((int) (my->x + 84.3376)), ((int) (my->y + 75.0)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + 84.3376)), ((int) (my->y + 75.0)), ((int) (my->x + 5.0002)), ((int) (my->y - 62.4167)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - 5.0002)), ((int) (my->y - 62.4167)), ((int) (my->x - 48.3334)), ((int) (my->y - 50.8056)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - 48.3334)), ((int) (my->y - 50.8056)), ((int) (my->x - 95.9487)), ((int) (my->y + 31.6667)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - 95.9487)), ((int) (my->y + 31.6667)), ((int) (my->x - 84.3376)), ((int) (my->y + 75.0)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - 84.3376)), ((int) (my->y + 75.0)), ((int) (my->x - 5.0002)), ((int) (my->y - 62.4167)), 1, color) != 0) status = 1; /* body */ if (respiration_green(my)) { if (my->count[1] >= 40) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 40) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (tenm_draw_circle((int) (my->x), (int) (my->y), 45, 3, color) != 0) status = 1; /* hit point stat */ if ((priority == 0) && (my->count[1] > 0)) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 10, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "respiration_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int respiration_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if (my->count[2] < 1160) return 1; return 0; } static int respiration_signal(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "plan 6 more 1") != 0) return 0; my->count[1] = my->count[0]; if (my->count[1] < 0) my->count[1] = 0; return 0; } dangen-0.5/spqr/respiration.h0000644000175000017500000000037010276702741017121 0ustar00ooharaoohara00000000000000/* $Id: respiration.h,v 1.2 2004/09/06 18:05:00 oohara Exp $ */ #ifndef __DANGEN_RESPIRATION_H__ #define __DANGEN_RESPIRATION_H__ #include "tenm_object.h" tenm_object *respiration_new(int table_index); #endif /* not __DANGEN_RESPIRATION_H__ */ dangen-0.5/spqr/result.c0000644000175000017500000000672010276702741016100 0ustar00ooharaoohara00000000000000/* $Id: result.c,v 1.28 2005/07/04 06:26:22 oohara Exp $ */ /* VERSION */ #include #include /* strlen */ #include /* malloc */ #include #include "stage.h" #include "score.h" #include "tenm_graphic.h" #include "util.h" #include "tenm_input.h" #include "tenm_timer.h" #include "esc-ok.h" #include "background.h" #include "pause.h" #include "const.h" #include "option.h" #include "result.h" /* return 1 if the program should quit, 0 if not */ int show_result(void) { int i; int x; int y; char temp[128]; const option *op = NULL; op = get_option(); if (op == NULL) { fprintf(stderr, "game_loop: get_option failed\n"); return 1; } /* no need to detect focus loss */ tenm_set_focus_handler((void (*)(int)) NULL); clear_pause(); tenm_timer_reset(); set_background(0); clear_window_with_background(); if (draw_string(100, 40, "dangen result", 14) != 0) fprintf(stderr, "show_result: draw_string (title) failed\n"); sprintf(temp, "version %.20s", VERSION); if (draw_string(100, 60, temp, (int) strlen(temp)) != 0) fprintf(stderr, "show_result: draw_string (version) failed\n"); if (cheating()) { x = 253; y = 100; if (draw_string(100, y, "cheat option(s):", 16) != 0) fprintf(stderr, "show_result: draw_string (cheat option) failed\n"); if (op->free_select != 0) { if (draw_string(x, y, "--free-select", 13) != 0) fprintf(stderr, "show_result: draw_string (--free-select) failed\n"); x += 126; } if (op->slow != 0) { if (draw_string(x, y, "--slow", 6) != 0) fprintf(stderr, "show_result: draw_string (--slow) failed\n"); x += 63; } } sprintf(temp, "total score: %8d", get_score()); if (draw_string(100, 150, temp, (int) strlen(temp)) != 0) fprintf(stderr, "show_result: draw_string (total score) failed\n"); for (i = 1; i <= 5; i++) { if (i > get_stage_number()) break; if (get_stage_id(i) < 0) break; if (get_stage_name(i) == NULL) break; y = 180 + (i - 1) * 20; sprintf(temp, "%-20.20s %8d", get_stage_name(i), get_stage_score(i)); if (draw_string(100, y, temp, (int) strlen(temp)) != 0) fprintf(stderr, "show_result: draw_string (stage %d) failed\n", i); if (get_stage_cleared(i) != 0) { if (draw_string(82, y, "*", 1) != 0) fprintf(stderr, "show_result: draw_string (stage %d clear mark) " "failed\n", i); } } if (get_stage_cleared(6) != 0) { y = 180 + (6 - 1) * 20; sprintf(temp, "* ship bonus %8d", get_stage_score(6)); if (draw_string(82, y, temp, (int) strlen(temp)) != 0) fprintf(stderr, "show_result: draw_string (ship bonus) " "failed\n"); } if (draw_string(WINDOW_WIDTH / 2 - 76, 440, "press ESC to quit", 17) != 0) fprintf(stderr, "show_result: draw_string (ESC instruction) failed\n"); tenm_redraw_window(); while (1 == 1) { /* quit the program if a SDL_QUIT event happened * (for example, if a SIGINT signal (sent by Ctrl+c) is received) */ if (tenm_event_handle() != 0) { return 1; } /* back to the title if ESC is pressed */ if (tenm_get_key_status() & 32) { if (get_esc_ok()) { set_esc_ok(0); break; } } else { set_esc_ok(1); } /* this wait is necessary to save CPU time */ tenm_wait_next_frame(); } return 0; } dangen-0.5/spqr/result.h0000644000175000017500000000026210276702741016100 0ustar00ooharaoohara00000000000000/* $Id: result.h,v 1.9 2004/08/16 14:54:06 oohara Exp $ */ #ifndef __DANGEN_RESULT_H__ #define __DANGEN_RESULT_H__ int show_result(void); #endif /* not __DANGEN_RESULT_H__ */ dangen-0.5/spqr/scheduler.c0000644000175000017500000000435210276702741016537 0ustar00ooharaoohara00000000000000/* $Id: scheduler.c,v 1.92 2005/07/10 04:49:59 oohara Exp $ */ #include #include "const.h" #include "tenm_table.h" #include "last-boss.h" #include "normal-enemy.h" #include "seiron.h" #include "seiron-fake.h" #include "net-can-howl.h" #include "stage.h" #include "ship.h" #include "plan-0.h" #include "plan-1.h" #include "plan-2.h" #include "plan-3.h" #include "plan-4.h" #include "plan-5.h" #include "plan-6.h" #include "plan-7.h" #include "plan-8.h" #include "plan-9.h" #include "plan-10.h" #include "plan-11.h" #include "plan-12.h" #include "plan-13.h" #include "plan-14.h" #include "plan-15.h" #include "plan-16.h" #include "plan-17.h" #include "plan-18.h" #include "plan-19.h" #include "plan-20.h" #include "scheduler.h" static int this_stage_cleared = 0; int scheduler(int tutorial, int t) { /* sanity check */ if (t < 0) return SCHEDULER_ERROR; if (this_stage_cleared != 0) { this_stage_cleared = 0; if (get_ship() < 0) return SCHEDULER_SUCCESS; return SCHEDULER_NEXT_STAGE; } if (tutorial) return plan_0(t); switch(get_stage_id(get_stage_number())) { case 0: return plan_0(t); break; case 1: return plan_1(t); break; case 2: return plan_2(t); break; case 3: return plan_3(t); break; case 4: return plan_4(t); break; case 5: return plan_5(t); break; case 6: return plan_6(t); break; case 7: return plan_7(t); break; case 8: return plan_8(t); break; case 9: return plan_9(t); break; case 10: return plan_10(t); break; case 11: return plan_11(t); break; case 12: return plan_12(t); break; case 13: return plan_13(t); break; case 14: return plan_14(t); break; case 15: return plan_15(t); break; case 16: return plan_16(t); break; case 17: return plan_17(t); break; case 18: return plan_18(t); break; case 19: return plan_19(t); break; case 20: return plan_20(t); break; default: fprintf(stderr, "scheduler: strange stage_id (%d) (t = %d)\n", get_stage_id(get_stage_number()), t); break; } return SCHEDULER_ERROR; } void set_this_stage_cleared(int n) { this_stage_cleared = n; } dangen-0.5/spqr/scheduler.h0000644000175000017500000000054210276702741016541 0ustar00ooharaoohara00000000000000/* $Id: scheduler.h,v 1.5 2005/07/10 04:49:15 oohara Exp $ */ #ifndef __DANGEN_SCHEDULER_H__ #define __DANGEN_SCHEDULER_H__ /* scheduler return value */ #define SCHEDULER_SUCCESS 0 #define SCHEDULER_ERROR 1 #define SCHEDULER_NEXT_STAGE 2 int scheduler(int tutorial, int t); void set_this_stage_cleared(int n); #endif /* not __DANGEN_SCHEDULER_H__ */ dangen-0.5/spqr/seiron-fake.c0000644000175000017500000006133011625232602016754 0ustar00ooharaoohara00000000000000/* $Id: seiron-fake.c,v 1.58 2011/08/24 17:31:46 oohara Exp $ */ /* [easy] Seiron Fake */ #include /* malloc */ #include /* strlen */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "stage-clear.h" #include "score.h" #include "seiron-fake.h" static int seiron_fake_move(tenm_object *my, double turn_per_frame); static int seiron_fake_hit(tenm_object *my, tenm_object *your); static int seiron_fake_act(tenm_object *my, const tenm_object *player); static void seiron_fake_act_firework(tenm_object *my, const tenm_object *player, int what, int t); static int seiron_fake_draw(tenm_object *my, int priority); static void seiron_fake_explosion(tenm_object *my); tenm_object * seiron_fake_new(void) { int i; tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = (double) (WINDOW_WIDTH / 2); double y = -44.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "seiron_fake_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_circle_new(x, y, 45.0); if (p[0] == NULL) { fprintf(stderr, "seiron_fake_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 13); if (count == NULL) { fprintf(stderr, "seiron_fake_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "seiron_fake_new: malloc(count_d) failed\n"); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] shoot timer * [3 -- 6] firework management * [7] winder theta * [8 -- 10] decoration management * [11] life mode * [12] demo timer */ count[0] = 0; count[1] = 0; count[2] = 0; for (i = 3; i <= 7; i++) count[i] = 0; count[8] = 0; count[9] = -23; count[10] = 1; count[11] = 0; count[12] = 0; /* list of count_d * [0] speed x * [1] speed y */ count_d[0] = 0.0; count_d[1] = (((double) (WINDOW_HEIGHT / 4)) - (-44.0)) / 30.0; new = tenm_object_new("Seiron Fake", ATTR_BOSS, ATTR_PLAYER_SHOT, 750, x, y, 13, count, 2, count_d, 1, p, (int (*)(tenm_object *, double)) (&seiron_fake_move), (int (*)(tenm_object *, tenm_object *)) (&seiron_fake_hit), (int (*)(tenm_object *, const tenm_object *)) (&seiron_fake_act), (int (*)(tenm_object *, int)) (&seiron_fake_draw)); if (new == NULL) { fprintf(stderr, "seiron_fake_new: tenm_object_new failed\n"); free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int seiron_fake_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) return 0; if (turn_per_frame <= 0.5) return 0; dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int seiron_fake_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) return 0; if (your == NULL) return 0; if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if (my->count[11] != 1) return 0; deal_damage(my, your, 0); if ((my->count[2] >= 1992) && (my->count[2] < 3744)) add_chain(my, your); my->count[1] = 2; if (my->hit_point <= 0) { add_score(15000); set_background(1); seiron_fake_explosion(my); return 0; } return 0; } static int seiron_fake_act(tenm_object *my, const tenm_object *player) { int i; int n; int theta; /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; /* encounter */ if (my->count[11] == 0) { (my->count[12])++; if (my->count[12] >= 30) { my->count[11] = 1; my->count[2] = 0; my->count[12] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; } return 0; } /* dead */ if (my->count[11] == 2) { my->count_d[0] = 0.0; my->count_d[1] = 0.5; if ((my->count[2] >= 1992) && (my->count[2] < 3744)) n = 8; else n = 7; if ((my->count[12] <= 75) && (my->count[12] % 15 == 0)) { tenm_table_add(explosion_new(my->x + ((double) (-30 + (rand() % 61))), my->y + ((double) (-30 + (rand() % 61))), 0.0, 0.0, 2, 300, n, 5.0, 8)); } (my->count[12])++; if (my->count[12] >= 120) { tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 3000, n, 10.0, 8)); tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 2, 800, n, 6.0, 8)); tenm_table_add(stage_clear_new(100)); return 1; } return 0; } /* self-destruction */ if (my->count[2] >= 3774) { set_background(2); seiron_fake_explosion(my); clear_chain(); return 0; } /* if we are here, we are fighting, my->count[11] == 1 */ /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; /* decoration */ if ((my->count[2] >= 1992) && (my->count[2] < 3744)) my->count[8] += 9; else my->count[8] -= 3; while (my->count[8] > 360) my->count[8] -= 360; while (my->count[8] < 0) my->count[8] += 360; my->count[9] += my->count[10]; if ((my->count[9] >= 23) || (my->count[9] <= -23)) my->count[10] *= -1; /* winder attack */ if ((my->count[2] >= 1992) && (my->count[2] < 3744) && (my->count[2] % 8 == 0)) { if (my->count[2] % 48 < 24) theta = 90; else theta = 70; for (i = 0; i < 360; i += 40) { tenm_table_add(laser_angle_new(my->x, my->y, 15.0, theta + i, 30.0, 4)); } } /* firework attack */ if ((my->count[2] >= 30) && (my->count[2] <= 30 + 40)) seiron_fake_act_firework(my, player, 0, my->count[2] - 30); if ((my->count[2] >= 230) && (my->count[2] <= 230 + 190)) seiron_fake_act_firework(my, player, 1, my->count[2] - 230); if ((my->count[2] >= 480) && (my->count[2] <= 480 + 30)) seiron_fake_act_firework(my, player, 2, my->count[2] - 480); if ((my->count[2] >= 590) && (my->count[2] <= 590 + 198)) seiron_fake_act_firework(my, player, 3, my->count[2] - 590); if ((my->count[2] >= 840) && (my->count[2] <= 840 + 70)) seiron_fake_act_firework(my, player, 4, my->count[2] - 840); if ((my->count[2] >= 960) && (my->count[2] <= 960 + 40)) seiron_fake_act_firework(my, player, 0, my->count[2] - 960); if ((my->count[2] >= 1160) && (my->count[2] <= 1160 + 198)) seiron_fake_act_firework(my, player, 3, my->count[2] - 1160); if ((my->count[2] >= 1410) && (my->count[2] <= 1410 + 87)) seiron_fake_act_firework(my, player, 5, my->count[2] - 1410); if ((my->count[2] >= 1560) && (my->count[2] <= 1560 + 190)) seiron_fake_act_firework(my, player, 1, my->count[2] - 1560); if ((my->count[2] >= 1810) && (my->count[2] <= 1810 + 70)) seiron_fake_act_firework(my, player, 4, my->count[2] - 1810); if ((my->count[2] >= 2080) && (my->count[2] <= 2080 + 30)) seiron_fake_act_firework(my, player, 6, my->count[2] - 2080); if ((my->count[2] >= 2180) && (my->count[2] <= 2180 + 49)) seiron_fake_act_firework(my, player, 7, my->count[2] - 2180); if ((my->count[2] >= 2470) && (my->count[2] <= 2470 + 20)) seiron_fake_act_firework(my, player, 8, my->count[2] - 2470); if ((my->count[2] >= 2570) && (my->count[2] <= 2570 + 159)) seiron_fake_act_firework(my, player, 9, my->count[2] - 2570); if ((my->count[2] >= 2830) && (my->count[2] <= 2830 + 35)) seiron_fake_act_firework(my, player, 10, my->count[2] - 2830); if ((my->count[2] >= 2910) && (my->count[2] <= 2910 + 30)) seiron_fake_act_firework(my, player, 6, my->count[2] - 2910); if ((my->count[2] >= 3010) && (my->count[2] <= 3010 + 159)) seiron_fake_act_firework(my, player, 9, my->count[2] - 3010); if ((my->count[2] >= 3260) && (my->count[2] <= 3260 + 0)) seiron_fake_act_firework(my, player, 11, my->count[2] - 3260); if ((my->count[2] >= 3360) && (my->count[2] <= 3360 + 49)) seiron_fake_act_firework(my, player, 7, my->count[2] - 3360); if ((my->count[2] >= 3650) && (my->count[2] <= 3650 + 35)) seiron_fake_act_firework(my, player, 10, my->count[2] - 3650); (my->count[2])++; if (my->count[2] > 3870) { /* should not reach here */ my->count[2] = 0; } return 0; } static void seiron_fake_act_firework(tenm_object *my, const tenm_object *player, int what, int t) { int i; int j; int theta; double x; double y; double speed; int suffix = 3; /* sanity check */ if (my == NULL) return; if (player == NULL) return; if (t < 0) return; switch (what) { case 0: if (t > 40) break; /* list of count * [suffix + 0] center x (relative to my->x) * [suffix + 1] center y (relative to my->y) * [suffix + 2] theta */ if (t == 0) { my->count[suffix + 0] = -5 + rand() % 11; my->count[suffix + 1] = -5 + rand() % 11; my->count[suffix + 2] = rand() % 360; } if ((t == 0) || (t == 40)) { x = my->x + (double) (my->count[suffix + 0]); y = my->y + (double) (my->count[suffix + 1]); theta = my->count[suffix + 2]; if (t == 40) theta += 4; for (i = 0; i < 360; i += 8) tenm_table_add(laser_angle_new(x, y, 3.0, theta + i, 25.0, 0)); } break; case 1: if (t > 190) break; if ((t <= 190) && (t % 10 == 0)) { if (t % 20 == 0) { /* list of count * [suffix + 0] center x (relative to my->x) * [suffix + 1] center y (relative to my->y) * [suffix + 2] theta */ my->count[suffix + 0] = -30 + rand() % 61; my->count[suffix + 1] = -30 + rand() % 61; my->count[suffix + 2] = -90 + (-15 + rand() % 31); } x = my->x + (double) (my->count[suffix + 0]); y = my->y + (double) (my->count[suffix + 1]); theta = my->count[suffix + 2]; if (t % 20 == 0) { for (i = 0; i < 360; i += 120) tenm_table_add(laser_angle_new(x, y, 8.0, theta + i, 50.0, 4)); } else if (t % 20 == 10) { theta += 180; for (i = 0; i < 360; i += 72) tenm_table_add(laser_angle_new(x, y, 6.0, theta + i, 50.0, 5)); } } if ((t <= 155) && (t % 10 == 5)) { x = my->x; y = my->y; theta = 15 + rand() % 151; tenm_table_add(laser_angle_new(x, y, 4.0, theta, 25.0, 2)); } break; case 2: if (t > 30) break; /* list of count * [suffix + 0] center x (relative to my->x) * [suffix + 1] center y (relative to my->y) * [suffix + 2] theta * [suffix + 3] dtheta direction */ if (t == 0) { my->count[suffix + 0] = -5 + rand() % 11; my->count[suffix + 1] = -5 + rand() % 11; my->count[suffix + 2] = rand() % 360; if (rand() % 2 == 0) my->count[suffix + 3] = 1; else my->count[suffix + 3] = -1; } if ((t <= 30) && (t % 10 == 0)) { x = my->x + (double) (my->count[suffix + 0]); y = my->y + (double) (my->count[suffix + 1]); theta = my->count[suffix + 2] + my->count[suffix + 3] * 2 * (t / 10); for (i = 0; i < 30; i++) { tenm_table_add(normal_shot_angle_new(x, y, 5.0, theta, 1)); if (i % 2 == 0) theta += my->count[suffix + 3] * 8; else theta += my->count[suffix + 3] * 16; } } break; case 3: if (t > 198) break; if ((t <= 198) && (t % 2 == 0)) { x = my->x + (double) (-30 + rand() % 61); y = my->y + (double) (-30 + rand() % 61); theta = 90 + (-15 + rand() % 31); speed = 4.0 + ((double) (rand() % 8)) / 4.0; tenm_table_add(laser_angle_new(x, y, speed, theta - 15, 25.0, 3)); tenm_table_add(laser_angle_new(x, y, speed, theta + 15, 25.0, 3)); } break; case 4: if (t > 70) break; if (t == 0) { /* list of count * [suffix + 0] center x (relative to my->x) * [suffix + 1] center y (relative to my->y) * [suffix + 2] dtheta direction */ my->count[suffix + 0] = -5 + rand() % 11; my->count[suffix + 1] = -5 + rand() % 11; my->count[suffix + 2] = rand() % 2; } x = my->x + (double) (my->count[suffix + 0]); y = my->y + (double) (my->count[suffix + 1]); if ((t >= 0) && (t < 60) && (t % 2 == 0)) { theta = -81 + (t / 2) * 12; if (my->count[suffix + 2] != 0) theta = 180 - theta; tenm_table_add(laser_angle_new(x, y, 5.0, theta, 25.0, 0)); } if ((t >= 10) && (t < 70) && (t % 2 == 0)) { theta = -81 + ((t - 5) / 2) * 12 - 5; if (my->count[suffix + 2] != 0) theta = 180 - theta; tenm_table_add(laser_angle_new(x, y, 8.0, theta, 25.0, 2)); theta = -81 + ((t - 5) / 2) * 12 + 5; if (my->count[suffix + 2] != 0) theta = 180 - theta; tenm_table_add(laser_angle_new(x, y, 6.5, theta, 25.0, 1)); } break; case 5: if (t > 87) break; /* list of count * [suffix + 0] center x (relative to my->x) * [suffix + 1] center y (relative to my->y) * [suffix + 2] theta * [suffix + 3] dtheta */ if (t == 0) { my->count[suffix + 0] = -5 + rand() % 11; my->count[suffix + 1] = -5 + rand() % 11; my->count[suffix + 2] = rand() % 360; if (rand() % 2 == 0) my->count[suffix + 3] = 1; else my->count[suffix + 3] = -1; } x = my->x + (double) (my->count[suffix + 0]); y = my->y + (double) (my->count[suffix + 1]); if ((t < 90) && (t % 3 == 0)) { theta = my->count[suffix + 2] + 8 * my->count[suffix + 3] * (t / 3); for (i = 0; i < 360; i += 120) tenm_table_add(normal_shot_angle_new(x, y, 6.0, theta + i, 0)); } break; case 6: if (t > 30) break; /* list of count * [suffix + 0] center x (relative to my->x) * [suffix + 1] center y (relative to my->y) * [suffix + 2] theta */ if (t == 0) { my->count[suffix + 0] = -5 + rand() % 11; my->count[suffix + 1] = -5 + rand() % 11; my->count[suffix + 2] = rand() % 360; } x = my->x + (double) (my->count[suffix + 0]); y = my->y + (double) (my->count[suffix + 1]); if ((t == 0) || (t == 10)) { theta = my->count[suffix + 2]; for (i = 0; i < 360; i += 12) tenm_table_add(laser_angle_new(x, y, 5.0, theta + i, 25.0, 0)); } if ((t == 20) || (t == 30)) { theta = my->count[suffix + 2] + 6; for (i = 0; i < 360; i += 12) tenm_table_add(laser_angle_new(x, y, 6.5, theta + i, 25.0, 1)); } break; case 7: if (t > 49) break; if (t <= 49) { for (i = 0; i < 4; i++) { x = my->x + (double) (-5 + rand() % 11); y = my->y + (double) (-5 + rand() % 11); if (t < 25) speed = 2.0 + (double) (rand() % (t + 1)) / 6.0; else speed = 2.0 + (double) (rand() % (50 - t)) / 6.0; theta = rand() % 360; tenm_table_add(normal_shot_angle_new(x, y, speed, theta, 2)); } } break; case 8: if (t > 20) break; /* list of count * [suffix + 0] center x (relative to my->x) * [suffix + 1] center y (relative to my->y) * [suffix + 2] theta */ if (t == 0) { my->count[suffix + 0] = -5 + rand() % 11; my->count[suffix + 1] = -5 + rand() % 11; my->count[suffix + 2] = rand() % 360; } x = my->x + (double) (my->count[suffix + 0]); y = my->y + (double) (my->count[suffix + 1]); if (t == 0) { theta = my->count[suffix + 2]; for (i = 0; i < 360; i += 12) tenm_table_add(normal_shot_angle_new(x, y, 4.0, theta + i, 0)); } if (t == 20) { theta = my->count[suffix + 2] + 6; for (i = 0; i < 360; i += 12) tenm_table_add(normal_shot_angle_new(x + 30.0 * tenm_cos(theta + i), y + 30.0 * tenm_sin(theta + i), 10.0, theta + i + 180, 5)); } break; case 9: if (t > 159) break; /* list of count * [suffix + 0] center x (relative to my->x) * [suffix + 1] center y (relative to my->y) */ if (t == 0) { my->count[suffix + 0] = -5 + rand() % 11; my->count[suffix + 1] = -5 + rand() % 11; } x = my->x + (double) (my->count[suffix + 0]); y = my->y + (double) (my->count[suffix + 1]); if (t <= 159) { theta = 15 + rand() % 151; speed = 4.0 + ((double) (rand() % 8)) / 4.0; tenm_table_add(laser_angle_new(x, y, speed, theta, 25.0, 3)); } break; case 10: if (t > 35) break; /* list of count * [suffix + 0] center x (relative to my->x) * [suffix + 1] center y (relative to my->y) */ if (t == 0) { my->count[suffix + 0] = -5 + rand() % 11; my->count[suffix + 1] = -5 + rand() % 11; } x = my->x + (double) (my->count[suffix + 0]); y = my->y + (double) (my->count[suffix + 1]); if ((t >= 0) && (t < 30)) { theta = -81 + 12 * t - 5; for (i = 0; i < 2; i++) { tenm_table_add(laser_angle_new(x, y, 6.0, theta, 25.0, 0)); theta = 180 - theta; } } if ((t >= 5) && (t < 30 + 5)) { theta = -81 + 12 * (t - 5); for (i = 0; i < 2; i++) { tenm_table_add(laser_angle_new(x, y, 7.5, theta, 25.0, 1)); theta = 180 - theta; } } break; case 11: if (t == 0) { x = my->x + (double) (-5 + rand() % 11); y = my->y + (double) (-5 + rand() % 11); theta = rand() % 360; for (i = 0; i < 360; i += 120) { for (j = 0; j < 360; j += 12) tenm_table_add(normal_shot_angle_new(x + 30.0 * tenm_cos(theta + i), y + 30.0 * tenm_sin(theta + i), 5.5, theta + i + j, 1)); } } break; default: break; } return; } static int seiron_fake_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; /* sanity check */ if (my == NULL) return 0; /* dead enemy has low priority */ if (((my->count[11] != 2) && (priority == 0)) || ((my->count[11] == 2) && (priority == -1))) { if (my->count[11] != 2) { /* decoration */ if ((my->count[2] >= 1992) && (my->count[2] < 3744)) { if (my->count[1] >= 1) color = tenm_map_color(181, 190, 92); else color = tenm_map_color(157, 182, 123); } else { if (my->count[1] >= 1) color = tenm_map_color(200, 164, 92); else color = tenm_map_color(182, 147, 123); } if (tenm_draw_line((int) (my->x + 100.0 * tenm_cos(my->count[8])), (int) (my->y - 30 + 100.0 * tenm_sin(my->count[8]) * tenm_sin(my->count[9])), (int) (my->x + 100.0 * tenm_cos(my->count[8] + 120)), (int) (my->y - 30 + 100.0 * tenm_sin(my->count[8] + 120) * tenm_sin(my->count[9])), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 100.0 * tenm_cos(my->count[8] + 120)), (int) (my->y - 30 + 100.0 * tenm_sin(my->count[8] + 120) * tenm_sin(my->count[9])), (int) (my->x + 100.0 * tenm_cos(my->count[8] + 240)), (int) (my->y - 30 + 100.0 * tenm_sin(my->count[8] + 240) * tenm_sin(my->count[9])), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 100.0 * tenm_cos(my->count[8] + 240)), (int) (my->y - 30 + 100.0 * tenm_sin(my->count[8] + 240) * tenm_sin(my->count[9])), (int) (my->x + 100.0 * tenm_cos(my->count[8])), (int) (my->y - 30 + 100.0 * tenm_sin(my->count[8]) * tenm_sin(my->count[9])), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 100.0 * tenm_cos(60 - my->count[8])), (int) (my->y + 30 + 100.0 * tenm_sin(60 - my->count[8]) * tenm_sin(my->count[9])), (int) (my->x + 100.0 * tenm_cos(300 - my->count[8])), (int) (my->y + 30 + 100.0 * tenm_sin(300 - my->count[8]) * tenm_sin(my->count[9])), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 100.0 * tenm_cos(300 - my->count[8])), (int) (my->y + 30 + 100.0 * tenm_sin(300 - my->count[8]) * tenm_sin(my->count[9])), (int) (my->x + 100.0 * tenm_cos(180 - my->count[8])), (int) (my->y + 30 + 100.0 * tenm_sin(180 - my->count[8]) * tenm_sin(my->count[9])), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 100.0 * tenm_cos(180 - my->count[8])), (int) (my->y + 30 + 100.0 * tenm_sin(180 - my->count[8]) * tenm_sin(my->count[9])), (int) (my->x + 100.0 * tenm_cos(60 - my->count[8])), (int) (my->y + 30 + 100.0 * tenm_sin(60 - my->count[8]) * tenm_sin(my->count[9])), 1, color) != 0) status = 1; } /* body */ if ((my->count[2] >= 1992) && (my->count[2] < 3744)) { if (my->count[1] >= 1) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 1) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (tenm_draw_circle((int) (my->x), (int) (my->y), 45, 3, color) != 0) status = 1; /* hit point stat */ if (my->count[11] == 1) { sprintf(temp, "%d", my->hit_point); if (draw_string((int) my->x, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "seiron_fake_draw: draw_string failed\n"); status = 1; } } } return status; } static void seiron_fake_explosion(tenm_object *my) { int n; double speed_theta; /* sanity check */ if (my == NULL) return; if ((my->count[2] >= 1992) && (my->count[2] < 3744)) { n = 8; speed_theta = 30.0; } else { n = 7; speed_theta = -15.0; } tenm_table_add(fragment_new(my->x, my->y - 30.0, 0.0, -2.0, 50.0, 36, n, 4.0, speed_theta, 20)); tenm_table_add(fragment_new(my->x, my->y + 30.0, 0.0, 2.0, 50.0, 36, n, 4.0, -speed_theta, 20)); tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 3000, n, 5.0, 8)); /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ tenm_mass_delete(my->mass); my->mass = NULL; tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy), 0); my->count[0] = 0; my->count[1] = 0; my->count[11] = 2; my->count[12] = 0; /* don't reset count[2] here */ return; } dangen-0.5/spqr/seiron-fake.h0000644000175000017500000000035510276702741016770 0ustar00ooharaoohara00000000000000/* $Id: seiron-fake.h,v 1.1 2003/08/22 17:09:45 oohara Exp $ */ #ifndef __DANGEN_SEIRON_FAKE_H__ #define __DANGEN_SEIRON_FAKE_H__ #include "tenm_object.h" tenm_object *seiron_fake_new(void); #endif /* not __DANGEN_SEIRON_FAKE_H__ */ dangen-0.5/spqr/seiron.c0000644000175000017500000007670211625232637016071 0ustar00ooharaoohara00000000000000/* $Id: seiron.c,v 1.312 2011/08/24 17:32:15 oohara Exp $ */ /* [hard] Seiron */ #include /* malloc */ #include /* strlen */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "stage-clear.h" #include "score.h" #include "seiron.h" static int seiron_move(tenm_object *my, double turn_per_frame); static int seiron_hit(tenm_object *my, tenm_object *your); static int seiron_act(tenm_object *my, const tenm_object *player); static void seiron_act_firework(tenm_object *my, const tenm_object *player, int what, int t); static int seiron_draw(tenm_object *my, int priority); static void seiron_explosion(tenm_object *my); tenm_object * seiron_new(void) { int i; tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = (double) (WINDOW_WIDTH / 2); double y = -44.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "seiron_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_circle_new(x, y, 45.0); if (p[0] == NULL) { fprintf(stderr, "seiron_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 13); if (count == NULL) { fprintf(stderr, "seiron_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "seiron_new: malloc(count_d) failed\n"); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] shoot timer * [3 -- 6] firework management * [7] winder theta * [8 -- 10] decoration management * [11] life mode * [12] demo timer */ count[0] = 0; count[1] = 0; count[2] = 0; for (i = 3; i <= 7; i++) count[i] = 0; count[8] = 0; count[9] = -23; count[10] = 1; count[11] = 0; count[12] = 0; /* list of count_d * [0] speed x * [1] speed y */ count_d[0] = 0.0; count_d[1] = (((double) (WINDOW_HEIGHT / 4)) - (-44.0)) / 30.0; new = tenm_object_new("Seiron", ATTR_BOSS, ATTR_PLAYER_SHOT, 1500, x, y, 13, count, 2, count_d, 1, p, (int (*)(tenm_object *, double)) (&seiron_move), (int (*)(tenm_object *, tenm_object *)) (&seiron_hit), (int (*)(tenm_object *, const tenm_object *)) (&seiron_act), (int (*)(tenm_object *, int)) (&seiron_draw)); if (new == NULL) { fprintf(stderr, "seiron_new: tenm_object_new failed\n"); free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int seiron_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) return 0; if (turn_per_frame <= 0.5) return 0; dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int seiron_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) return 0; if (your == NULL) return 0; if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if (my->count[11] != 1) return 0; deal_damage(my, your, 0); if ((my->count[2] >= 1752) && (my->count[2] < 3870)) add_chain(my, your); my->count[1] = 2; if (my->hit_point <= 0) { add_score(60000); set_background(1); seiron_explosion(my); return 0; } return 0; } static int seiron_act(tenm_object *my, const tenm_object *player) { int i; int n; int theta; /* sanity check */ if (my == NULL) return 0; if (player == NULL) return 0; /* encounter */ if (my->count[11] == 0) { (my->count[12])++; if (my->count[12] >= 30) { my->count[11] = 1; my->count[2] = 0; my->count[12] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; } return 0; } /* dead */ if (my->count[11] == 2) { my->count_d[0] = 0.0; my->count_d[1] = 0.5; if ((my->count[2] >= 1752) && (my->count[2] < 3870)) n = 8; else n = 7; if ((my->count[12] <= 75) && (my->count[12] % 15 == 0)) { tenm_table_add(explosion_new(my->x + ((double) (-30 + (rand() % 61))), my->y + ((double) (-30 + (rand() % 61))), 0.0, 0.0, 2, 300, n, 5.0, 8)); } (my->count[12])++; if (my->count[12] >= 120) { tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 3000, n, 10.0, 8)); tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 2, 800, n, 6.0, 8)); tenm_table_add(stage_clear_new(100)); return 1; } return 0; } /* self-destruction */ if (my->count[2] >= 3900) { set_background(2); seiron_explosion(my); clear_chain(); return 0; } /* if we are here, we are fighting, my->count[11] == 1 */ /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; /* decoration */ if ((my->count[2] >= 1752) && (my->count[2] < 3870)) my->count[8] -= 9; else my->count[8] += 3; while (my->count[8] > 360) my->count[8] -= 360; while (my->count[8] < 0) my->count[8] += 360; my->count[9] += my->count[10]; if ((my->count[9] >= 23) || (my->count[9] <= -23)) my->count[10] *= -1; /* winder attack */ if ((my->count[2] >= 1752) && (my->count[2] < 3870) && (my->count[2] % 8 == 0)) { if (my->count[2] % 48 < 24) theta = 90; else theta = 70; for (i = 0; i < 360; i += 40) { tenm_table_add(laser_angle_new(my->x, my->y, 15.0, theta + i, 30.0, 4)); } } /* firework attack */ if ((my->count[2] >= 30) && (my->count[2] <= 30 + 60)) seiron_act_firework(my, player, 0, my->count[2] - 30); if ((my->count[2] >= 160) && (my->count[2] <= 160 + 255)) seiron_act_firework(my, player, 1, my->count[2] - 160); if ((my->count[2] >= 450) && (my->count[2] <= 450 + 55)) seiron_act_firework(my, player, 5, my->count[2] - 450); if ((my->count[2] >= 560) && (my->count[2] <= 560 + 219)) seiron_act_firework(my, player, 2, my->count[2] - 560); if ((my->count[2] >= 790) && (my->count[2] <= 790 + 35)) seiron_act_firework(my, player, 3, my->count[2] - 790); if ((my->count[2] >= 870) && (my->count[2] <= 870 + 60)) seiron_act_firework(my, player, 0, my->count[2] - 870); if ((my->count[2] >= 1000) && (my->count[2] <= 1000 + 219)) seiron_act_firework(my, player, 2, my->count[2] - 1000); if ((my->count[2] >= 1230) && (my->count[2] <= 1230 + 179)) seiron_act_firework(my, player, 4, my->count[2] - 1230); if ((my->count[2] >= 1380) && (my->count[2] <= 1380 + 255)) seiron_act_firework(my, player, 1, my->count[2] - 1380); if ((my->count[2] >= 1650) && (my->count[2] <= 1650 + 35)) seiron_act_firework(my, player, 3, my->count[2] - 1650); if ((my->count[2] >= 1840) && (my->count[2] <= 1840 + 18)) seiron_act_firework(my, player, 6, my->count[2] - 1840); if ((my->count[2] >= 1920) && (my->count[2] <= 1920 + 274)) seiron_act_firework(my, player, 8, my->count[2] - 1920); if ((my->count[2] >= 2250) && (my->count[2] <= 2250 + 60)) seiron_act_firework(my, player, 7, my->count[2] - 2250); if ((my->count[2] >= 2400) && (my->count[2] <= 2400 + 299)) seiron_act_firework(my, player, 9, my->count[2] - 2400); if ((my->count[2] >= 2750) && (my->count[2] <= 2750 + 40)) seiron_act_firework(my, player, 10, my->count[2] - 2750); if ((my->count[2] >= 2850) && (my->count[2] <= 2850 + 18)) seiron_act_firework(my, player, 6, my->count[2] - 2850); if ((my->count[2] >= 2930) && (my->count[2] <= 2930 + 299)) seiron_act_firework(my, player, 9, my->count[2] - 2930); if ((my->count[2] >= 3310) && (my->count[2] <= 3310 + 0)) seiron_act_firework(my, player, 11, my->count[2] - 3310); if ((my->count[2] >= 3440) && (my->count[2] <= 3440 + 274)) seiron_act_firework(my, player, 8, my->count[2] - 3440); if ((my->count[2] >= 3770) && (my->count[2] <= 3770 + 40)) seiron_act_firework(my, player, 10, my->count[2] - 3770); (my->count[2])++; if (my->count[2] > 3900) { /* should not reach here */ my->count[2] = 0; } return 0; } static void seiron_act_firework(tenm_object *my, const tenm_object *player, int what, int t) { int i; int j; int n; int theta; double x; double y; double speed; int suffix = 3; /* sanity check */ if (my == NULL) return; if (player == NULL) return; if (t < 0) return; switch (what) { case 0: if (t > 60) break; /* list of count * [suffix + 0] center x (relative to my->x) * [suffix + 1] center y (relative to my->y) * [suffix + 2] theta * [suffix + 3] dtheta */ if (t == 0) { my->count[suffix + 0] = -5 + rand() % 11; my->count[suffix + 1] = -5 + rand() % 11; my->count[suffix + 2] = rand() % 360; if (rand() % 2 == 0) my->count[suffix + 3] = 2; else my->count[suffix + 3] = -2; } if (t % 20 == 0) { x = my->x + (double) (my->count[suffix + 0]); y = my->y + (double) (my->count[suffix + 1]); if (t <= 20) { speed = 3.0; n = 0; } else { speed = 4.5; n = 1; } theta = my->count[suffix + 2] + my->count[suffix + 3] * (t / 20); for (i = 0; i < 360; i += 8) tenm_table_add(laser_angle_new(x, y, speed, theta + i, 25.0, n)); } break; case 1: if (t > 255) break; if (t <= 49) { for (i = 0; i < 4; i++) { x = my->x + (double) (-5 + rand() % 11); y = my->y + (double) (-5 + rand() % 11); if (t < 25) speed = 2.0 + (double) (rand() % (t + 1)) / 6.0; else speed = 2.0 + (double) (rand() % (50 - t)) / 6.0; theta = rand() % 360; n = 2; tenm_table_add(normal_shot_angle_new(x, y, speed, theta, n)); } } if ((t >= 80) && (t <= 255)) { if (t % 10 == 0) { /* list of count * [suffix + 0] center x (relative to my->x) * [suffix + 1] center y (relative to my->y) * [suffix + 2] theta */ my->count[suffix + 0] = -5 + rand() % 11; my->count[suffix + 1] = -5 + rand() % 11; my->count[suffix + 2] = rand() % 360; x = my->x + (double) (my->count[suffix + 0]); y = my->y + (double) (my->count[suffix + 1]); speed = 12.0; n = 4; theta = my->count[suffix + 2]; for (i = 0; i < 360; i += 120) tenm_table_add(laser_angle_new(x, y, speed, theta + i, 50.0, n)); } else if (t % 10 == 5) { x = my->x + (double) (my->count[suffix + 0]); y = my->y + (double) (my->count[suffix + 1]); speed = 15.0; n = 5; theta = my->count[suffix + 2] + 180; for (i = 0; i < 360; i += 72) tenm_table_add(laser_angle_new(x, y, speed, theta + i, 50.0, n)); } } break; case 2: if (t > 219) break; if (t < 60) speed = 2.5; else if (t < 180) speed = 2.5 + ((double) (t - 60)) / 12.0; else speed = 12.5; if (t % 2 == 0) { x = my->x + (double) (-30 + rand() % 61); y = my->y + (double) (-30 + rand() % 61); theta = rand() % 360; if (speed < 8.0) n = 4; else n = 5; for (i = 0; i < 2; i++) { tenm_table_add(laser_angle_new(x, y, speed, theta, 30.0, n)); theta += 60; } } else { x = my->x; y = my->y; speed += 2.0; if (speed < 10.0) n = 2; else n = 3; theta = rand() % 360; tenm_table_add(normal_shot_angle_new(x, y, speed, theta, n)); } break; case 3: if (t > 35) break; if (t == 0) { /* list of count * [suffix + 0] center x (relative to my->x) * [suffix + 1] center y (relative to my->y) */ my->count[suffix + 0] = -5 + rand() % 11; my->count[suffix + 1] = -5 + rand() % 11; } x = my->x + (double) (my->count[suffix + 0]); y = my->y + (double) (my->count[suffix + 1]); if (t == 35) { theta = 90; switch (rand() % 3) { case 0: theta += 6; break; case 1: theta += 12; break; default: break; } for (i = 0; i < 40; i++) { tenm_table_add(laser_angle_new(x, y, 10.0, theta, 25.0, 3)); if (i % 2 == 0) theta += 6; else theta += 12; } } if ((t >= 0) && (t < 30)) { theta = -81 + t * 12; for (i = 0; i < 2; i++) { tenm_table_add(laser_angle_new(x, y, 5.0, theta, 25.0, 0)); theta = 180 - theta; } } if ((t >= 5) && (t < 35)) { theta = -81 + (t - 5) * 12 - 5; for (i = 0; i < 2; i++) { tenm_table_add(laser_angle_new(x, y, 8.0, theta, 25.0, 2)); theta = 180 - theta; } theta = -81 + (t - 5) * 12 + 5; for (i = 0; i < 2; i++) { tenm_table_add(laser_angle_new(x, y, 6.5, theta, 25.0, 1)); theta = 180 - theta; } } break; case 4: if (t > 87) break; /* list of count * [suffix + 0] center x (relative to my->x) * [suffix + 1] center y (relative to my->y) * [suffix + 2] theta * [suffix + 3] dtheta */ if (t == 0) { my->count[suffix + 0] = -5 + rand() % 11; my->count[suffix + 1] = -5 + rand() % 11; my->count[suffix + 2] = rand() % 360; if (rand() % 2 == 0) my->count[suffix + 3] = 1; else my->count[suffix + 3] = -1; } x = my->x + (double) (my->count[suffix + 0]); y = my->y + (double) (my->count[suffix + 1]); if (t % 3 == 0) { if (t < 45) { speed = 2.0 + ((double) (t)) / 15.0; theta = my->count[suffix + 2] + 8 * my->count[suffix + 3] * (t / 3); for (i = 0; i < 360; i += 120) tenm_table_add(normal_shot_angle_new(x, y, speed, theta + i, 0)); theta = my->count[suffix + 2] + (-8) * my->count[suffix + 3] * (t / 3) + 60; for (i = 0; i < 360; i += 120) tenm_table_add(normal_shot_angle_new(x, y, speed, theta + i, 4)); } else if (t < 90) { speed = 7.0 - ((double) (t - 45)) / 15.0; theta = my->count[suffix + 2] + 8 * my->count[suffix + 3] * ((t - 45)/ 3) + 2 * my->count[suffix + 3]; for (i = 0; i < 360; i += 120) tenm_table_add(normal_shot_angle_new(x, y, speed, theta + i, 0)); theta = my->count[suffix + 2] + (-8) * my->count[suffix + 3] * ((t - 45)/ 3) + 60 - 4 * my->count[suffix + 3]; for (i = 0; i < 360; i += 120) tenm_table_add(normal_shot_angle_new(x, y, speed, theta + i, 4)); } } break; case 5: if (t > 55) break; /* list of count * [suffix + 0] center x (relative to my->x) * [suffix + 1] center y (relative to my->y) * [suffix + 2] theta * [suffix + 3] dtheta */ if (t == 0) { my->count[suffix + 0] = -5 + rand() % 11; my->count[suffix + 1] = -5 + rand() % 11; my->count[suffix + 2] = rand() % 360; if (rand() % 2 == 0) my->count[suffix + 3] = 2; else my->count[suffix + 3] = -2; } x = my->x + (double) (my->count[suffix + 0]); y = my->y + (double) (my->count[suffix + 1]); if ((t <= 30) && (t % 10 == 0)) { theta = my->count[suffix + 2] + my->count[suffix + 3] * (t / 10); for (i = 0; i < 360; i += 10) tenm_table_add(normal_shot_angle_new(x, y, 4.0, theta + i, 5)); } if (t == 55) { theta = my->count[suffix + 2] + my->count[suffix + 3] * 4; for (i = 0; i < 360; i += 10) tenm_table_add(normal_shot_angle_new(x, y, 8.0, theta + i, 1)); } break; case 6: if (t > 18) break; /* list of count * [suffix + 0] center x (relative to my->x) * [suffix + 1] center y (relative to my->y) * [suffix + 2] theta */ if (t == 0) { my->count[suffix + 0] = -5 + rand() % 11; my->count[suffix + 1] = -5 + rand() % 11; my->count[suffix + 2] = rand() % 360; } x = my->x + (double) (my->count[suffix + 0]); y = my->y + (double) (my->count[suffix + 1]); if ((t <= 18) && (t % 6 == 0)) { theta = my->count[suffix + 2] + (t / 6) * 3; if ((t == 0) || (t == 18)) i = 20; else i = 40; for (; i > 0; i--) { tenm_table_add(laser_angle_new(x, y, 8.0, theta, 25.0, 2)); if ((t == 0) || (t == 18)) { theta += 18; } else if (t == 6) { if (i % 2 == 0) theta += 12; else theta += 6; } else { if (i % 2 == 0) theta += 6; else theta += 12; } } } break; case 7: if (t > 60) break; /* list of count * [suffix + 0] center x (relative to my->x) * [suffix + 1] center y (relative to my->y) * [suffix + 2] theta * [suffix + 3] dtheta */ if (t == 0) { my->count[suffix + 0] = -5 + rand() % 11; my->count[suffix + 1] = -5 + rand() % 11; my->count[suffix + 2] = rand() % 360; if (rand() % 2 == 0) my->count[suffix + 3] = 9; else my->count[suffix + 3] = -9; } x = my->x + (double) (my->count[suffix + 0]); y = my->y + (double) (my->count[suffix + 1]); if (t == 0) { theta = my->count[suffix + 2]; for (i = 0; i < 5; i++) { for (j = 0; j < 360; j += 15) { tenm_table_add(laser_angle_new(x, y, 3.0 + ((double) i) * 0.45, theta + j, 25.0, 3)); } theta += my->count[suffix + 3]; } } if ((t == 40) || (t == 60)) { if (rand() % 2 == 0) my->count[suffix + 3] = 140; else my->count[suffix + 3] = -140; theta = rand() % 360; for (i = 0; i < 360; i += 8) { tenm_table_add(normal_shot_angle_new(x + 30.0 * tenm_cos(theta + i), y + 30.0 * tenm_sin(theta + i), 10.0, theta + i + my->count[suffix + 3], 0)); } } break; case 8: if (t > 274) break; /* list of count * [suffix + 0] center x (relative to my->x) * [suffix + 1] center y (relative to my->y) * [suffix + 2] theta * [suffix + 3] dtheta */ if (t == 0) { my->count[suffix + 0] = -5 + rand() % 11; my->count[suffix + 1] = -5 + rand() % 11; my->count[suffix + 2] = rand() % 360; if (rand() % 2 == 0) my->count[suffix + 3] = 8; else my->count[suffix + 3] = -8; } x = my->x + (double) (my->count[suffix + 0]); y = my->y + (double) (my->count[suffix + 1]); if (t == 0) { theta = my->count[suffix + 2]; for (i = 0; i < 360; i += 8) tenm_table_add(normal_shot_angle_new(x, y, 1.5, theta + i, 3)); } if (t == 30) { theta = my->count[suffix + 2] + 4; for (i = 0; i < 360; i += 8) tenm_table_add(normal_shot_angle_new(x, y, 1.6, theta + i, 3)); } if ((t >= 140) && (t < 275)) { speed = 9.0 + ((double) (rand() % 13)) / 3.0; theta = my->count[suffix + 2] + 2 + my->count[suffix + 3] * (t - 140); tenm_table_add(laser_angle_new(x, y, speed, theta, 25.0, 5)); tenm_table_add(laser_angle_new(x, y, speed, theta + 180, 25.0, 5)); } break; case 9: if (t > 300) break; /* list of count * [suffix + 0] center x (relative to my->x) * [suffix + 1] center y (relative to my->y) * [suffix + 2] theta * [suffix + 3] dtheta */ if (t == 0) { my->count[suffix + 0] = -5 + rand() % 11; my->count[suffix + 1] = -5 + rand() % 11; my->count[suffix + 2] = rand() % 360; if (rand() % 2 == 0) my->count[suffix + 3] = 51; else my->count[suffix + 3] = -51; } x = my->x + (double) (my->count[suffix + 0]); y = my->y + (double) (my->count[suffix + 1]); if (t == 0) { theta = my->count[suffix + 2] + 180; for (i = 0; i < 360; i += 18) for (j = 0; j < 360; j += 120) tenm_table_add(laser_angle_new(x + 15.0 * tenm_cos(theta + i), y + 15.0 * tenm_sin(theta + i), 1.5, theta + i + j + 180, 50.0, 2)); } if ((t >= 60) && (t < 300) && (t % 2 == 0)) { theta = my->count[suffix + 2] + my->count[suffix + 3] * ((t - 60) / 2); if (t % 6 == 0) speed = 10.0; else speed = 12.0; for (i = 0; i < 5; i++) { tenm_table_add(laser_angle_new(x + 30.0 * tenm_cos(theta), y + 30.0 * tenm_sin(theta), speed, theta + i * 72 + 36, 50.0, 0)); } } break; case 10: if (t > 40) break; /* list of count * [suffix + 0] center x (relative to my->x) * [suffix + 1] center y (relative to my->y) * [suffix + 2] speed period */ if (t == 0) { my->count[suffix + 0] = -5 + rand() % 11; my->count[suffix + 1] = -5 + rand() % 11; my->count[suffix + 2] = rand() % 3; } x = my->x + (double) (my->count[suffix + 0]); y = my->y + (double) (my->count[suffix + 1]); if ((t >= 0) && (t < 30)) { if (my->count[suffix + 2] == 0) n = 3; else n = 5; theta = -81 + 12 * t - 8; speed = 8.0 + 1.0 * tenm_cos(theta * n + 89); for (i = 0; i < 2; i++) { tenm_table_add(laser_angle_new(x, y, speed, theta, 25.0, 0)); theta = 180 - theta; } } if ((t >= 5) && (t < 30 + 5)) { if (my->count[suffix + 2] == 1) n = 3; else n = 5; theta = -81 + 12 * (t - 5) - 2; speed = 8.5 + 1.5 * tenm_cos(theta * n + 83); for (i = 0; i < 2; i++) { tenm_table_add(laser_angle_new(x, y, speed, theta, 25.0, 1)); theta = 180 - theta; } } if ((t >= 10) && (t < 30 + 10)) { if (my->count[suffix + 2] == 2) n = 3; else n = 5; theta = -81 + 12 * (t - 10); speed = 9.0 + 2.0 * tenm_cos(theta * n + 81); for (i = 0; i < 2; i++) { tenm_table_add(laser_angle_new(x, y, speed, theta, 25.0, 2)); theta = 180 - theta; } } break; case 11: if (t > 0) break; /* list of count * [suffix + 0] center x (relative to my->x) * [suffix + 1] center y (relative to my->y) * [suffix + 2] theta */ if (t == 0) { my->count[suffix + 0] = -5 + rand() % 11; my->count[suffix + 1] = -5 + rand() % 11; my->count[suffix + 2] = rand() % 360; } x = my->x + (double) (my->count[suffix + 0]); y = my->y + (double) (my->count[suffix + 1]); if (t == 0) { for (i = 0; i < 360; i += 12) { theta = my->count[suffix + 2]; tenm_table_add(normal_shot_angle_new(x + 30.0 * tenm_cos(theta + i), y + 30.0 * tenm_sin(theta + i), 7.0, theta + i + 180, 5)); tenm_table_add(normal_shot_angle_new(x + 30.0 * tenm_cos(theta + i), y + 30.0 * tenm_sin(theta + i), 8.0, theta + i + 180, 5)); tenm_table_add(normal_shot_angle_new(x + 30.0 * tenm_cos(theta + i), y + 30.0 * tenm_sin(theta + i), 6.5, theta + i + 180 - 20, 3)); tenm_table_add(normal_shot_angle_new(x + 30.0 * tenm_cos(theta + i), y + 30.0 * tenm_sin(theta + i), 7.5, theta + i + 180 - 40, 3)); tenm_table_add(normal_shot_angle_new(x + 30.0 * tenm_cos(theta + i), y + 30.0 * tenm_sin(theta + i), 6.5, theta + i + 180 + 20, 3)); tenm_table_add(normal_shot_angle_new(x + 30.0 * tenm_cos(theta + i), y + 30.0 * tenm_sin(theta + i), 7.5, theta + i + 180 + 40, 3)); } } break; default: fprintf(stderr, "seiron_act_firework: strange what (%d)\n", what); break; } return; } static int seiron_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; /* sanity check */ if (my == NULL) return 0; /* dead enemy has low priority */ if (((my->count[11] != 2) && (priority == 0)) || ((my->count[11] == 2) && (priority == -1))) { if (my->count[11] != 2) { /* decoration */ if ((my->count[2] >= 1752) && (my->count[2] < 3870)) { if (my->count[1] >= 1) color = tenm_map_color(181, 190, 92); else color = tenm_map_color(157, 182, 123); } else { if (my->count[1] >= 1) color = tenm_map_color(200, 164, 92); else color = tenm_map_color(182, 147, 123); } if (tenm_draw_line((int) (my->x + 100.0 * tenm_cos(my->count[8])), (int) (my->y - 30 + 100.0 * tenm_sin(my->count[8]) * tenm_sin(my->count[9])), (int) (my->x + 100.0 * tenm_cos(my->count[8] + 120)), (int) (my->y - 30 + 100.0 * tenm_sin(my->count[8] + 120) * tenm_sin(my->count[9])), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 100.0 * tenm_cos(my->count[8] + 120)), (int) (my->y - 30 + 100.0 * tenm_sin(my->count[8] + 120) * tenm_sin(my->count[9])), (int) (my->x + 100.0 * tenm_cos(my->count[8] + 240)), (int) (my->y - 30 + 100.0 * tenm_sin(my->count[8] + 240) * tenm_sin(my->count[9])), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 100.0 * tenm_cos(my->count[8] + 240)), (int) (my->y - 30 + 100.0 * tenm_sin(my->count[8] + 240) * tenm_sin(my->count[9])), (int) (my->x + 100.0 * tenm_cos(my->count[8])), (int) (my->y - 30 + 100.0 * tenm_sin(my->count[8]) * tenm_sin(my->count[9])), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 100.0 * tenm_cos(60 - my->count[8])), (int) (my->y + 30 + 100.0 * tenm_sin(60 - my->count[8]) * tenm_sin(my->count[9])), (int) (my->x + 100.0 * tenm_cos(300 - my->count[8])), (int) (my->y + 30 + 100.0 * tenm_sin(300 - my->count[8]) * tenm_sin(my->count[9])), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 100.0 * tenm_cos(300 - my->count[8])), (int) (my->y + 30 + 100.0 * tenm_sin(300 - my->count[8]) * tenm_sin(my->count[9])), (int) (my->x + 100.0 * tenm_cos(180 - my->count[8])), (int) (my->y + 30 + 100.0 * tenm_sin(180 - my->count[8]) * tenm_sin(my->count[9])), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 100.0 * tenm_cos(180 - my->count[8])), (int) (my->y + 30 + 100.0 * tenm_sin(180 - my->count[8]) * tenm_sin(my->count[9])), (int) (my->x + 100.0 * tenm_cos(60 - my->count[8])), (int) (my->y + 30 + 100.0 * tenm_sin(60 - my->count[8]) * tenm_sin(my->count[9])), 1, color) != 0) status = 1; } /* body */ if ((my->count[2] >= 1752) && (my->count[2] < 3870)) { if (my->count[1] >= 1) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 1) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (tenm_draw_circle((int) (my->x), (int) (my->y), 45, 3, color) != 0) status = 1; /* hit point stat */ if (my->count[11] == 1) { sprintf(temp, "%d", my->hit_point); if (draw_string((int) my->x, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "seiron_draw: draw_string failed\n"); status = 1; } } } return status; } static void seiron_explosion(tenm_object *my) { int n; double speed_theta; /* sanity check */ if (my == NULL) return; if ((my->count[2] >= 1752) && (my->count[2] < 3870)) { n = 8; speed_theta = -30.0; } else { n = 7; speed_theta = 15.0; } tenm_table_add(fragment_new(my->x, my->y - 30.0, 0.0, -2.0, 50.0, 36, n, 4.0, speed_theta, 20)); tenm_table_add(fragment_new(my->x, my->y + 30.0, 0.0, 2.0, 50.0, 36, n, 4.0, -speed_theta, 20)); tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 3000, n, 5.0, 8)); /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ tenm_mass_delete(my->mass); my->mass = NULL; tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy), 0); my->count[0] = 0; my->count[1] = 0; my->count[11] = 2; my->count[12] = 0; /* don't reset count[2] here */ return; } dangen-0.5/spqr/seiron.h0000644000175000017500000000032410276702741016060 0ustar00ooharaoohara00000000000000/* $Id: seiron.h,v 1.1 2003/08/18 11:09:29 oohara Exp $ */ #ifndef __DANGEN_SEIRON_H__ #define __DANGEN_SEIRON_H__ #include "tenm_object.h" tenm_object *seiron_new(void); #endif /* not __DANGEN_SEIRON_H__ */ dangen-0.5/spqr/show-record.c0000644000175000017500000004767110276702741017030 0ustar00ooharaoohara00000000000000/* $Id: show-record.c,v 1.69 2005/07/13 16:02:41 oohara Exp $ */ /* VERSION */ #include #include /* strlen */ #include /* malloc */ #include /* localtime */ #include #include "tenm_graphic.h" #include "util.h" #include "tenm_input.h" #include "tenm_timer.h" #include "esc-ok.h" #include "background.h" #include "pause.h" #include "const.h" #include "record_data.h" #include "record_io.h" #include "option.h" #include "show-record.h" #define MENU_SIZE 5 static int show_result_rule(stage_plan *p, void *data); static int draw_timestamp(int x, int y, int timestamp); /* return 1 if the program should quit, 0 if not */ int show_record(void) { int i; char temp[128]; stage_list *list = NULL; stage_list *list_full = NULL; game_record *record = NULL; int head = 0; int cursor = 0; int delay = 6; int delay_next = 6; int last_move = 0; plan_record *p_rec = NULL; int menu_size; int n1; int n2; int show_list = 0; int max_id; const option *op = NULL; int space_ok = 0; int n; op = get_option(); if (op == NULL) { fprintf(stderr, "show_record: get_option failed\n"); return 1; } record = game_record_load(); if (record == NULL) { fprintf(stderr, "show_record: game_record_load failed\n"); return 1; } if (!game_record_valid(record, 0)) { fprintf(stderr, "show_record: record is invalid\n"); game_record_delete(record); return 1; } if (op->free_select != 0) list = stage_list_new((int (*)(stage_plan *, void *)) NULL, NULL); else list = stage_list_new((int (*)(stage_plan *, void *)) (&show_result_rule), record); if (list == NULL) { fprintf(stderr, "show_record: stage_list_new (list) failed\n"); game_record_delete(record); return 1; } if (list->n > 0) qsort((void *) list->p, (size_t) (list->n), sizeof(stage_plan *), (int (*)(const void *, const void *)) stage_compare); max_id = -1; for (i = 0; i < list->n; i++) { if (max_id < (list->p[i])->stage_id) max_id = (list->p[i])->stage_id; } if (max_id > record->plan_n) { fprintf(stderr, "show_record: max_id > record->plan_n (%d > %d)\n", max_id, record->plan_n); stage_list_delete(list); game_record_delete(record); return 1; } list_full = stage_list_new((int (*)(stage_plan *, void *)) NULL, NULL); if (list_full == NULL) { fprintf(stderr, "show_record: stage_list_new (list_full) failed\n"); stage_list_delete(list); game_record_delete(record); return 1; } max_id = -1; for (i = 0; i < record->total_p->stage_n; i++) { if (max_id < record->total_p->stage_id[i]) max_id = record->total_p->stage_id[i]; } if (max_id > list_full->n) { fprintf(stderr, "show_record: max_id > list_full->n (%d > %d)\n", max_id, list_full->n); stage_list_delete(list_full); stage_list_delete(list); game_record_delete(record); return 1; } menu_size = MENU_SIZE; if (menu_size > list->n + 1) menu_size = list->n + 1; if (menu_size <= 0) menu_size = 1; /* no need to detect focus loss */ tenm_set_focus_handler((void (*)(int)) NULL); clear_pause(); tenm_timer_reset(); set_background(0); while (1 == 1) { /* quit the program if a SDL_QUIT event happened * (for example, if a SIGINT signal (sent by Ctrl+c) is received) */ if (tenm_event_handle() != 0) { stage_list_delete(list_full); stage_list_delete(list); game_record_delete(record); return 1; } /* back to the title if ESC is pressed */ if (tenm_get_key_status() & 32) { if (get_esc_ok()) { set_esc_ok(0); break; } } else { set_esc_ok(1); } /* space */ if (tenm_get_key_status() & 16) { if (space_ok) { if (show_list) show_list = 0; else show_list = 1; space_ok = 0; } } else { space_ok = 1; } switch (tenm_get_key_status() & 15) { case 1: /* up */ if (delay <= 0) { if (head + cursor <= 0) { head = list->n - menu_size + 1; cursor = menu_size - 1; } else if (cursor <= 0) { head--; } else { cursor--; } if (last_move == 1) { delay_next -= 2; if (delay_next < 0) delay_next = 0; } delay = delay_next; last_move = 1; } else { delay--; } break; case 2: /* down */ if (delay <= 0) { if (head + cursor >= list->n) { head = 0; cursor = 0; } else if (cursor >= menu_size - 1) { head++; } else { cursor++; } if (last_move == 2) { delay_next -= 2; if (delay_next < 0) delay_next = 0; } delay = delay_next; last_move = 2; } else { delay--; } break; case 4: /* right */ if (delay <= 0) { for (i = 1; i <= list->n; i++) { n1 = head + cursor + i; n2 = head + cursor; if (n1 > list->n) { head = 0; cursor = 0; break; } if (n2 <= 0) { head = 1; cursor = 0; if (head + menu_size - 1 > list->n) { cursor = head + menu_size - list->n - 1; head = list->n + 1 - menu_size; } break; } while (n1 >= list->n + 1) n1 -= list->n; while (n1 < 1) n1 += list->n; while (n2 >= list->n + 1) n2 -= list->n; while (n2 < 1) n2 += list->n; if ((list->p[n1 - 1])->difficulty != (list->p[n2 - 1])->difficulty) { head = n1; cursor = 0; if (head + menu_size - 1> list->n) { cursor = head + menu_size - list->n - 1; head = list->n + 1 - menu_size; } break; } } delay = 6; delay_next = 6; last_move = 4; } else { delay--; } break; case 8: /* left */ if (delay <= 0) { for (i = 1; i <= list->n; i++) { if (head + cursor <= 0) { head = list->n - menu_size + 1; cursor = menu_size - 1; break; } n1 = head + cursor - i - 1; n2 = head + cursor - i; if (n2 <= 0) { head = 0; cursor = 0; break; } if (n1 <= 0) { head = 1; cursor = 0; if (head + menu_size - 1 > list->n) { cursor = head + menu_size - list->n - 1; head = list->n + 1 - menu_size; } break; } while (n1 >= list->n + 1) n1 -= list->n; while (n1 < 1) n1 += list->n; while (n2 >= list->n + 1) n2 -= list->n; while (n2 < 1) n2 += list->n; if ((list->p[n1 - 1])->difficulty != (list->p[n2 - 1])->difficulty) { head = n2; cursor = 0; if (head + menu_size - 1 > list->n) { cursor = head + menu_size - list->n - 1; head = list->n + 1 - menu_size; } break; } } delay = 6; delay_next = 6; last_move = 8; } else { delay--; } break; default: delay = 0; delay_next = 6; last_move = 0; break; } if ((head < 0) || (head + menu_size - 1 > list->n)) { fprintf(stderr, "show_result: strange head (%d)\n", head); head = 0; } if ((cursor < 0) || (cursor >= menu_size)) { fprintf(stderr, "show_result: strange cursor (%d)\n", cursor); cursor = 0; } clear_window_with_background(); if (draw_string(100, 40, "dangen play record", 18) != 0) fprintf(stderr, "show_record: draw_string (title) failed\n"); sprintf(temp, "version %.20s", VERSION); if (draw_string(100, 60, temp, (int) strlen(temp)) != 0) fprintf(stderr, "show_record: draw_string (version) failed\n"); if (draw_string(WINDOW_WIDTH / 2 - 256, 420, "use cursor keys to choose, " "press space to toggle the list", 57) != 0) fprintf(stderr, "show_record: draw_string " "(cursor/space instruction) failed\n"); if (draw_string(WINDOW_WIDTH / 2 - 76, 440, "press ESC to quit", 17) != 0) fprintf(stderr, "show_record: draw_string (ESC instruction) failed\n"); if ((head + cursor - 1 >= 0) && (head + cursor - 1 <= list->n - 1)) p_rec = record->plan_p[(list->p[head + cursor - 1])->stage_id]; else p_rec = NULL; if (show_list) { /* draw the list */ for (i = 0; i < menu_size; i++) { if (head + i > list->n) break; if (head + i <= 0) sprintf(temp, "total"); else sprintf(temp, "[%.10s] %.50s", stage_difficulty_string((list->p[head + i - 1])->difficulty), (list->p[head + i - 1])->name); if (draw_string(80, 120 + 20 * i, temp, (int) strlen(temp)) != 0) fprintf(stderr, "show_record: draw_string (list %d) failed\n", i); if (i == cursor) { if (draw_string(60, 120 + 20 * i, ">", 1) != 0) fprintf(stderr, "show_record: draw_string (cursor) failed\n"); } } /* draw the play record */ if (draw_string(480, 140, "record", 6) != 0) fprintf(stderr, "show_record: draw_string (record title) failed\n"); if (draw_string(480, 160, "max", 3) != 0) fprintf(stderr, "show_record: draw_string (record score max title) " "failed\n"); if (p_rec != NULL) { if (p_rec->number_play > 0) sprintf(temp, "%8d", p_rec->score_max); else sprintf(temp, " ---"); } else { if (record->total_p->number_play > 0) sprintf(temp, "%8d", record->total_p->total_score); else sprintf(temp, " ---"); } if (draw_string(510, 180, temp, (int) strlen(temp)) != 0) fprintf(stderr, "show_record: draw_string (record score max value) " "failed\n"); if (p_rec != NULL) { if (draw_string(480, 200, "min cleared", 11) != 0) fprintf(stderr, "show_record: draw_string (record score min cleared " "title) " "failed\n"); if (p_rec->number_clear > 0) sprintf(temp, "%8d", p_rec->score_min_cleared); else sprintf(temp, " ---"); if (draw_string(510, 220, temp, (int) strlen(temp)) != 0) fprintf(stderr, "show_record: draw_string (record score min cleared " "value) " "failed\n"); } if (draw_string(480, 240, "play", 11) != 0) fprintf(stderr, "show_record: draw_string (record play title) " "failed\n"); if (p_rec != NULL) { if (p_rec->number_play >= 0) sprintf(temp, "%8d", p_rec->number_play); else sprintf(temp, " ---"); } else { if (record->total_p->number_play >= 0) sprintf(temp, "%8d", record->total_p->number_play); else sprintf(temp, " ---"); } if (draw_string(510, 260, temp, (int) strlen(temp)) != 0) fprintf(stderr, "show_record: draw_string (record play value) " "failed\n"); } else { n = head + cursor; if (n <= 0) sprintf(temp, "total"); else sprintf(temp, "[%.10s] %.50s", stage_difficulty_string((list->p[n - 1])->difficulty), (list->p[n - 1])->name); if (draw_string(80, 120, temp, (int) strlen(temp)) != 0) fprintf(stderr, "show_record: draw_string (plan name) failed\n"); if (draw_string(80, 150, "max", 3) != 0) fprintf(stderr, "show_record: draw_string (record score max title) " "failed\n"); if (p_rec != NULL) { if (p_rec->number_play > 0) sprintf(temp, "%8d", p_rec->score_max); else sprintf(temp, " ---"); if (draw_string(200, 150, temp, (int) strlen(temp)) != 0) fprintf(stderr, "show_record: draw_string (record score max value) " "failed\n"); if ((p_rec->number_play > 0) && (p_rec->score_max_when > 0)) { if (draw_timestamp(300, 150, p_rec->score_max_when) != 0) fprintf(stderr, "show_record: draw_timestamp (record score max) " "failed\n"); } if (draw_string(80, 170, "min cleared", 11) != 0) fprintf(stderr, "show_record: draw_string (record score min cleared " "title) " "failed\n"); if (p_rec->number_clear > 0) sprintf(temp, "%8d", p_rec->score_min_cleared); else sprintf(temp, " ---"); if (draw_string(200, 170, temp, (int) strlen(temp)) != 0) fprintf(stderr, "show_record: draw_string (record score min cleared " "value) " "failed\n"); if ((p_rec->number_clear > 0) && (p_rec->score_min_cleared_when > 0)) { if (draw_timestamp(300, 170, p_rec->score_min_cleared_when) != 0) fprintf(stderr, "show_record: draw_timestamp " "(record score mon cleared) " "failed\n"); } if (draw_string(80, 190, "play", 4) != 0) fprintf(stderr, "show_record: draw_string (record play " "title) " "failed\n"); sprintf(temp, "%8d", p_rec->number_play); if (draw_string(200, 190, temp, (int) strlen(temp)) != 0) fprintf(stderr, "show_record: draw_string (record play " "value) " "failed\n"); if ((p_rec->number_play > 0) && (p_rec->number_play_when > 0)) { if (draw_timestamp(300, 190, p_rec->number_play_when) != 0) fprintf(stderr, "show_record: draw_timestamp " "(record play) " "failed\n"); } if (draw_string(80, 210, "clear", 5) != 0) fprintf(stderr, "show_record: draw_string (record clear " "title) " "failed\n"); sprintf(temp, "%8d", p_rec->number_clear); if (draw_string(200, 210, temp, (int) strlen(temp)) != 0) fprintf(stderr, "show_record: draw_string (record clear " "value) " "failed\n"); if ((p_rec->number_clear > 0) && (p_rec->number_clear_when > 0)) { if (draw_timestamp(300, 210, p_rec->number_clear_when) != 0) fprintf(stderr, "show_record: draw_timestamp " "(record clear) " "failed\n"); } } else { if (record->total_p->number_play > 0) sprintf(temp, "%8d", record->total_p->total_score); else sprintf(temp, " ---"); if (draw_string(200, 150, temp, (int) strlen(temp)) != 0) fprintf(stderr, "show_record: draw_string (record score max value) " "failed\n"); if ((record->total_p->number_play > 0) && (record->total_p->total_score_when > 0)) { if (draw_timestamp(300, 150, record->total_p->total_score_when) != 0) fprintf(stderr, "show_record: draw_timestamp (record score max) " "failed\n"); } if (record->total_p->number_play > 0) { for (i = 0; i < record->total_p->stage_n; i++) { n = record->total_p->stage_id[i]; if (n < 0) break; if ((i >= 5) || (list_full->p[n])->stage_id == record->total_p->stage_id[i]) { if (i >= 5) { sprintf(temp, "ship bonus"); } else { /* sprintf(temp, "[%s] %s", stage_difficulty_string((list_full->p[n])->difficulty), (list_full->p[n])->name); */ sprintf(temp, "%s", (list_full->p[n])->name); } if (draw_string(100, 200 + 20 * i, temp, (int) strlen(temp)) != 0) fprintf(stderr, "show_record: draw_string (record stage %d) " "failed\n", i + 1); if (record->total_p->stage_cleared[i] != 0) { if (draw_string(82, 200 + 20 * i, "*", 1) != 0) fprintf(stderr, "show_record: draw_string (record stage %d " "clear mark) " "failed\n", i + 1); } sprintf(temp, "%8d", record->total_p->stage_score[i]); if (draw_string(316, 200 + 20 * i, temp, (int) strlen(temp)) != 0) fprintf(stderr, "show_record: draw_string (record stage %d " "score) " "failed\n", i + 1); } } } if (draw_string(80, 350, "play", 4) != 0) fprintf(stderr, "show_record: draw_string (record play " "title) " "failed\n"); if (record->total_p->number_play >= 0) sprintf(temp, "%8d", record->total_p->number_play); else sprintf(temp, " ---"); if (draw_string(200, 350, temp, (int) strlen(temp)) != 0) fprintf(stderr, "show_record: draw_string (record play " "value) " "failed\n"); if ((record->total_p->number_play > 0) && (record->total_p->number_play_when > 0)) { if (draw_timestamp(300, 350, record->total_p->number_play_when) != 0) fprintf(stderr, "show_record: draw_timestamp " "(record play) " "failed\n"); } } } tenm_redraw_window(); /* this wait is necessary to save CPU time */ tenm_wait_next_frame(); } stage_list_delete(list_full); stage_list_delete(list); game_record_delete(record); return 0; } /* return 1 (true) or 0 (false) */ static int show_result_rule(stage_plan *p, void *data) { game_record *record = (game_record *) data; /* sanity check */ if (p == NULL) return 0; if (record == NULL) return 0; if (p->stage_id < 0) return 0; if (p->stage_id > record->plan_n) return 0; if ((record->plan_p[p->stage_id])->number_play > 0) return 1; return 0; } /* return 0 on success, 1 on error */ static int draw_timestamp(int x, int y, int timestamp) { time_t t_temp; struct tm *lt; char temp[128]; /* sanity check */ if (timestamp < 0) { fprintf(stderr, "draw_timestamp: timestamp is negative (%d)\n", timestamp); return 1; } t_temp = (time_t) timestamp; lt = localtime(&t_temp); sprintf(temp, "%4d/%2d/%2d %2d:%2d", lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min); if (draw_string(x, y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "draw_timestamp: draw_string failed\n"); return 1; } return 0; } dangen-0.5/spqr/show-record.h0000644000175000017500000000030610276702741017015 0ustar00ooharaoohara00000000000000/* $Id: show-record.h,v 1.1 2005/07/02 12:51:25 oohara Exp $ */ #ifndef __DANGEN_SHOW_RECORD_H__ #define __DANGEN_SHOW_RECORD_H__ int show_record(void); #endif /* not __DANGEN_SHOW_RECORD_H__ */ dangen-0.5/spqr/silver-chimera.c0000644000175000017500000012134310276702741017473 0ustar00ooharaoohara00000000000000/* $Id: silver-chimera.c,v 1.172 2005/06/24 14:42:42 oohara Exp $ */ /* [hard] Silver Chimera */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "stage-clear.h" #include "score.h" #include "silver-chimera.h" static int silver_chimera_move(tenm_object *my, double turn_per_frame); static int silver_chimera_hit(tenm_object *my, tenm_object *your); static void silver_chimera_explode(tenm_object *my); static int silver_chimera_act(tenm_object *my, const tenm_object *player); static int silver_chimera_draw(tenm_object *my, int priority); static int silver_chimera_green(const tenm_object *my); static tenm_object *silver_chimera_spread_new(double x, double y, double speed_x, double speed_y, int t_spread); static int silver_chimera_spread_move(tenm_object *my, double turn_per_frame); static int silver_chimera_spread_hit(tenm_object *my, tenm_object *your); static int silver_chimera_spread_act(tenm_object *my, const tenm_object *player); static int silver_chimera_spread_draw(tenm_object *my, int priority); static tenm_object *silver_chimera_lock_on_new(double x, double y); static int silver_chimera_lock_on_act(tenm_object *my, const tenm_object *player); static int silver_chimera_lock_on_draw(tenm_object *my, int priority); static int silver_chimera_lock_on_draw_square(int x, int y, int length, tenm_color color); static tenm_object *silver_chimera_bit_new(int table_index, int n); static int silver_chimera_bit_move(tenm_object *my, double turn_per_frame); static int silver_chimera_bit_hit(tenm_object *my, tenm_object *your); static int silver_chimera_bit_signal(tenm_object *my, int n); static int silver_chimera_bit_act(tenm_object *my, const tenm_object *player); static int silver_chimera_bit_draw(tenm_object *my, int priority); static int silver_chimera_bit_green(const tenm_object *my); tenm_object * silver_chimera_new(void) { int i; tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = (double) (WINDOW_WIDTH / 2); double y = -53.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 2); if (p == NULL) { fprintf(stderr, "silver_chimera_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 96.0, y - 54.0, x - 48.0, y + 54.0, x - 65.28, y + 30.96, x + 78.72, y - 77.04); if (p[0] == NULL) { fprintf(stderr, "silver_chimera_new: cannot set p[0]\n"); free(p); return NULL; } p[1] = (tenm_primitive *) tenm_polygon_new(4, x - 96.0, y - 54.0, x + 48.0, y + 54.0, x + 65.28, y + 30.96, x - 78.72, y - 77.04); if (p[1] == NULL) { fprintf(stderr, "silver_chimera_new: cannot set p[1]\n"); (p[0])->delete(p[0]); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 6); if (count == NULL) { fprintf(stderr, "silver_chimera_new: malloc(count) failed\n"); for (i = 0; i < 2; i++) (p[i])->delete(p[i]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "silver_chimera_new: malloc(count_d) failed\n"); free(count); for (i = 0; i < 2; i++) (p[i])->delete(p[i]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] move mode * [3] move timer * [4] number of bits dead * [5] "was green when killed" flag */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 0; count[4] = 0; count[5] = 0; count_d[0] = 0.0; count_d[1] = (((double) (WINDOW_HEIGHT / 4)) - y) / 120.0; new = tenm_object_new("Silver Chimera", ATTR_BOSS, ATTR_PLAYER_SHOT, 1000, x, y, 6, count, 2, count_d, 2, p, (int (*)(tenm_object *, double)) (&silver_chimera_move), (int (*)(tenm_object *, tenm_object *)) (&silver_chimera_hit), (int (*)(tenm_object *, const tenm_object *)) (&silver_chimera_act), (int (*)(tenm_object *, int)) (&silver_chimera_draw)); if (new == NULL) { fprintf(stderr, "silver_chimera_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); for (i = 0; i < 2; i++) (p[i])->delete(p[i]); free(p); return NULL; } return new; } static int silver_chimera_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "silver_chimera_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "silver_chimera_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int silver_chimera_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "silver_chimera_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "silver_chimera_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if (my->count[2] != 1) return 0; deal_damage(my, your, 0); if (silver_chimera_green(my)) add_chain(my, your); my->count[1] = 2; if (my->hit_point <= 0) { set_background(1); silver_chimera_explode(my); add_score(30000); return 0; } return 0; } static void silver_chimera_explode(tenm_object *my) { int n; if (my == NULL) { fprintf(stderr, "silver_chimera_explode: my is NULL\n"); return; } tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy), 0); /* set "was green" flag before we change the life mode */ if (silver_chimera_green(my)) { my->count[5] = 1; n = 8; } else { my->count[5] = 0; n = 7; } my->count[2] = 2; my->count[3] = 0; my->count[1] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.5; tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 5000, n, 10.0, 6)); /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ tenm_mass_delete(my->mass); my->mass = NULL; } static int silver_chimera_act(tenm_object *my, const tenm_object *player) { int i; int theta; int t_spread; double x; double y; /* sanity check */ if (my == NULL) { fprintf(stderr, "silver_chimera_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; (my->count[3])++; /* encounter */ if (my->count[2] == 0) { if (my->count[3] == 60) { for (i = 0; i < 2; i++) tenm_table_add(silver_chimera_bit_new(my->table_index, i)); return 0; } if (my->count[3] >= 120) { my->count[2] = 1; my->count[3] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; return 0; } return 0; } /* dead */ if (my->count[2] == 2) { if (silver_chimera_green(my)) i = 8; else i = 7; if ((my->count[3] >= 30) && (my->count[3] <= 75) && (my->count[3] % 15 == 0)) { theta = rand() % 360; tenm_table_add(explosion_new(my->x + 30.0 * tenm_cos(theta), my->y + 30.0 * tenm_sin(theta), 0.0, 0.0, 2, 300, i, 5.0, 8)); } if (my->count[3] > 120) { tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 5000, i, 10.0, 8)); tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 2, 1000, i, 7.5, 12)); tenm_table_add(fragment_new(my->x + 48.0, my->y - 36.0, 2.8, -2.1, 30.0, 30, i, 5.0, 0.0, 16)); tenm_table_add(fragment_new(my->x + 48.0, my->y + 36.0, 2.8, 2.1, 30.0, 30, i, 5.0, 0.0, 16)); tenm_table_add(fragment_new(my->x - 48.0, my->y - 36.0, -2.8, -2.1, 30.0, 30, i, 5.0, 0.0, 16)); tenm_table_add(fragment_new(my->x - 48.0, my->y + 36.0, -2.8, 2.1, 30.0, 30, i, 5.0, 0.0, 16)); tenm_table_add(stage_clear_new(100)); return 1; } return 0; } /* self-destruction */ if ((my->count[2] == 1) && (my->count[3] >= 5610)) { set_background(2); clear_chain(); silver_chimera_explode(my); return 0; } /* speed change */ if (my->count[3] < 180) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if ((my->count[3] == 180) || (my->count[3] == 2880)) { my->count_d[0] = (((double) (WINDOW_WIDTH / 2)) - my->x) / 90.0; my->count_d[1] = (20.0 - my->y) / 90.0; } if (((my->count[3] > 180) && (my->count[3] < 270)) || ((my->count[3] > 2880) && (my->count[3] < 2970))) { ; } if (((my->count[3] >= 270) && (my->count[3] < 990)) || ((my->count[3] >= 2970) && (my->count[3] < 3690))) { x = (double) (WINDOW_WIDTH / 2); x += ((double) (WINDOW_WIDTH / 2)) * tenm_cos(my->count[3] * 2) * tenm_cos(my->count[3]); my->count_d[0] = x - my->x; my->count_d[1] = 0.0; } if (((my->count[3] >= 990) && (my->count[3] < 1080)) || ((my->count[3] >= 3690) && (my->count[3] < 3780))) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if ((my->count[3] == 1080) || (my->count[3] == 4680)) { my->count_d[0] = (((double) (WINDOW_WIDTH / 2)) - my->x) / 90.0; my->count_d[1] = (((double) (WINDOW_HEIGHT / 2)) - my->y) / 90.0; } if (((my->count[3] > 1080) && (my->count[3] < 1170)) || ((my->count[3] > 4680) && (my->count[3] < 4770))) { ; } if (((my->count[3] >= 1170) && (my->count[3] < 1890)) || (my->count[3] >= 4770)) { x = (double) (WINDOW_WIDTH / 2); x += ((double) (WINDOW_WIDTH / 2)) * tenm_cos(my->count[3] * 2) * tenm_cos(my->count[3]); y = (double) (WINDOW_HEIGHT / 4); y += ((double) (WINDOW_HEIGHT / 4)) * tenm_sin(my->count[3]); my->count_d[0] = x - my->x; my->count_d[1] = y - my->y; } if ((my->count[3] >= 1890) && (my->count[3] < 1980)) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if ((my->count[3] == 1980) || (my->count[3] == 3780)) { my->count_d[0] = (((double) (WINDOW_WIDTH / 2)) - my->x) / 90.0; my->count_d[1] = (((double) (WINDOW_HEIGHT / 4)) - my->y) / 90.0; } if (((my->count[3] > 1980) && (my->count[3] < 2070)) || ((my->count[3] > 3780) && (my->count[3] < 3870))) { ; } if (((my->count[3] >= 2070) && (my->count[3] < 2880)) || ((my->count[3] >= 3870) && (my->count[3] < 4680))) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[2] != 1) return 0; /* shoot */ if (((my->count[3] >= 360) && (my->count[3] < 990)) || ((my->count[3] >= 2970) && (my->count[3] < 3690))) { if (my->count[3] % 7 == 0) { if ((my->count[3] + 90) % 360 < 180) theta = 80; else theta = 100; if (my->count[4] >= 2) { tenm_table_add(laser_angle_new(my->x, my->y + 18.0, 12.0, theta, 30.0, 1)); tenm_table_add(laser_angle_new(my->x + 9.0, my->y + 18.0, 9.0, theta, 30.0, 1)); tenm_table_add(laser_angle_new(my->x - 9.0, my->y + 18.0, 9.0, theta, 30.0, 1)); tenm_table_add(laser_angle_new(my->x + 27.0, my->y + 18.0, 7.0, theta, 30.0, 1)); tenm_table_add(laser_angle_new(my->x - 27.0, my->y + 18.0, 7.0, theta, 30.0, 1)); tenm_table_add(laser_angle_new(my->x + 45.0, my->y + 18.0, 5.0, theta, 30.0, 1)); tenm_table_add(laser_angle_new(my->x - 45.0, my->y + 18.0, 5.0, theta, 30.0, 1)); } else { tenm_table_add(laser_angle_new(my->x, my->y + 18.0, 8.0, theta, 30.0, 1)); if (my->count[4] >= 1) { tenm_table_add(laser_angle_new(my->x + 15.0, my->y + 18.0, 6.5, theta, 30.0, 1)); tenm_table_add(laser_angle_new(my->x - 15.0, my->y + 18.0, 6.5, theta, 30.0, 1)); } tenm_table_add(laser_angle_new(my->x + 45.0, my->y + 18.0, 5.0, theta, 30.0, 1)); tenm_table_add(laser_angle_new(my->x - 45.0, my->y + 18.0, 5.0, theta, 30.0, 1)); } } } if (((my->count[3] >= 1170) && (my->count[3] < 1890)) || ((my->count[3] >= 4770) && (my->count[3] < 5490))) { if (my->count[3] % 46 == 0) { if (my->count[4] >= 2) t_spread = 20; else if (my->count[4] == 1) t_spread = 55; else t_spread = 70; tenm_table_add(silver_chimera_spread_new(my->x + 36.0, my->y + 30.96, -6.0, 2.5, t_spread + rand() % 31)); tenm_table_add(silver_chimera_spread_new(my->x - 36.0, my->y + 30.96, 6.0, 2.5, t_spread + rand() % 31)); } if (my->count[3] % 46 == 23) { if (my->count[4] >= 2) t_spread = 20; else if (my->count[4] == 1) t_spread = 50; else t_spread = 80; tenm_table_add(silver_chimera_spread_new(my->x, my->y, 0.0, 6.5, t_spread + rand() % 31)); } } if (((my->count[3] >= 2070) && (my->count[3] < 2790)) || ((my->count[3] >= 3840) && (my->count[3] < 4590))) { if ((my->count[3] % 37 == 0) && ((my->count[4] >= 2) || ((my->count[4] >= 1) && (my->count[3] % 148 < 74)) || (my->count[3] % 148 == 0))) { tenm_table_add(silver_chimera_lock_on_new(player->x, player->y)); } } return 0; } static int silver_chimera_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; /* sanity check */ if (my == NULL) { fprintf(stderr, "silver_chimera_draw: my is NULL\n"); return 0; } /* body */ if (priority == 0) { if (silver_chimera_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 1) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (tenm_draw_line((int) (my->x), (int) (my->y - 18.0), (int) (my->x + 78.72), (int) (my->y - 77.04), 3, color)) status = 1; if (tenm_draw_line((int) (my->x + 78.72), (int) (my->y - 77.04), (int) (my->x + 96.0), (int) (my->y - 54.0), 3, color)) status = 1; if (tenm_draw_line((int) (my->x + 96.0), (int) (my->y - 54.0), (int) (my->x + 24.0), (int) (my->y), 3, color)) status = 1; if (tenm_draw_line((int) (my->x + 24.0), (int) (my->y), (int) (my->x + 65.28), (int) (my->y + 30.96), 3, color)) status = 1; if (tenm_draw_line((int) (my->x + 65.28), (int) (my->y + 30.96), (int) (my->x + 48.0), (int) (my->y + 54.0), 3, color)) status = 1; if (tenm_draw_line((int) (my->x + 48.0), (int) (my->y + 54.0), (int) (my->x), (int) (my->y + 18.0), 3, color)) status = 1; if (tenm_draw_line((int) (my->x), (int) (my->y - 18.0), (int) (my->x - 78.72), (int) (my->y - 77.04), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - 78.72), (int) (my->y - 77.04), (int) (my->x - 96.0), (int) (my->y - 54.0), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - 96.0), (int) (my->y - 54.0), (int) (my->x - 24.0), (int) (my->y), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - 24.0), (int) (my->y), (int) (my->x - 65.28), (int) (my->y + 30.96), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - 65.28), (int) (my->y + 30.96), (int) (my->x - 48.0), (int) (my->y + 54.0), 3, color)) status = 1; if (tenm_draw_line((int) (my->x - 48.0), (int) (my->y + 54.0), (int) (my->x), (int) (my->y + 18.0), 3, color)) status = 1; } /* hit point stat */ if ((priority == 0) && (my->count[2] == 1)) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 10, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "silver_chimera_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int silver_chimera_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if ((my->count[2] == 1) && (my->count[3] >= 270) && (my->count[3] < 5580)) return 1; if ((my->count[2] == 2) && (my->count[5] != 0)) return 1; return 0; } static tenm_object * silver_chimera_spread_new(double x, double y, double speed_x, double speed_y, int t_spread) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; /* sanity check */ if (t_spread <= 0) { fprintf(stderr, "silver_chimera_spread_new: t_spread is non-positive " "(%d)\n", t_spread); return NULL; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "silver_chimera_spread_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_circle_new(x, y, 10.0); if (p[0] == NULL) { fprintf(stderr, "silver_chimera_spread_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 3); if (count == NULL) { fprintf(stderr, "silver_chimera_spread_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "silver_chimera_spread_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] color (for delete_enemy_shot) * [1] spread mode * [2] spread timer */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = 2; count[1] = 0; count[2] = -t_spread; count_d[0] = speed_x; count_d[1] = speed_y; new = tenm_object_new("Silver Chimera spread", ATTR_ENEMY_SHOT, ATTR_OPAQUE, 1, x, y, 3, count, 2, count_d, 1, p, (int (*)(tenm_object *, double)) (&silver_chimera_spread_move), (int (*)(tenm_object *, tenm_object *)) (&silver_chimera_spread_hit), (int (*)(tenm_object *, const tenm_object *)) (&silver_chimera_spread_act), (int (*)(tenm_object *, int)) (&silver_chimera_spread_draw)); if (new == NULL) { fprintf(stderr, "silver_chimera_spread_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int silver_chimera_spread_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "silver_chimera_spread_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "silver_chimera_spread_move: " "strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); /* shape change */ if ((my->count[1] == 1) && (my->mass != NULL)) ((tenm_circle *)(my->mass->p[0]))->r += 2.0 / turn_per_frame; if (!in_window_object(my)) return 1; return 0; } static int silver_chimera_spread_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "silver_chimera_spread_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "silver_chimera_spread_hit: your is NULL\n"); return 0; } if (your->attr & ATTR_OPAQUE) return 1; return 0; } static int silver_chimera_spread_act(tenm_object *my, const tenm_object *player) { int i; int theta; /* sanity check */ if (my == NULL) { fprintf(stderr, "silver_chimera_spread_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[2])++; switch (my->count[1]) { case 0: if (my->count[2] >= 0) { my->count[1] = 1; my->count[2] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; } break; case 1: if (my->count[2] == 10) { tenm_table_add(laser_point_new(my->x, my->y, 5.0, player->x, player->y, 25.0, 2)); } if (my->count[2] >= 20) { my->count[0] = 3; my->count[1] = 2; my->count[2] = 0; } break; case 2: if (my->count[2] % 5 == 0) { theta = rand() % 360; for (i = 0; i < 360; i += 120) tenm_table_add(laser_angle_new(my->x, my->y, 7.0, theta + i, 25.0, 3)); } if (my->count[2] >= 20) { return 1; } break; default: fprintf(stderr, "silver_chimera_spread_act: strange my->count[1] (%d)\n", my->count[1]); break; } return 0; } static int silver_chimera_spread_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; int r = 1; /* sanity check */ if (my == NULL) { fprintf(stderr, "silver_chimera_spread_draw: my is NULL\n"); return 0; } if ((priority == 0) && (my->count[1] == 0)) { color = tenm_map_color(99, 143, 158); color = tenm_map_color(0, 167, 223); color = tenm_map_color(167, 196, 206); if (tenm_draw_line((int) (my->x), (int) (my->y), (int) (my->x + my->count_d[0] * (double)(my->count[2])), (int) (my->y + my->count_d[1] * (double)(my->count[2])), 1, color)) status = 1; } if (priority == 1) { switch (my->count[1]) { case 0: r = 10; color = tenm_map_color(0, 167, 223); break; case 1: r = 10 + my->count[2] * 2; color = tenm_map_color(0, 167, 223); break; case 2: r = 50; color = tenm_map_color(0, 111, 223); break; default: fprintf(stderr, "silver_chimera_spread_draw: strange my->count[1] " "(%d)\n", my->count[1]); r = 1; color = tenm_map_color(0, 0, 0); break; } if (tenm_draw_circle((int) (my->x), (int) (my->y), r, 3, color) != 0) status = 1; } return status; } static tenm_object * silver_chimera_lock_on_new(double x, double y) { tenm_object *new = NULL; int *count = NULL; count = (int *) malloc(sizeof(int) * 4); if (count == NULL) { fprintf(stderr, "silver_chimera_spread_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] color (for delete_enemy_shot) * [1] shoot mode * [2] shoot timer * [3] shoot direction */ count[0] = 6; count[1] = 0; count[2] = 1; count[3] = rand() % 2; /* ATTR_ENEMY_SHOT is only to clear it when the player is killed */ new = tenm_object_new("Silver Chimera lock on", ATTR_ENEMY_SHOT, 0, 1, x, y, 4, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&silver_chimera_lock_on_act), (int (*)(tenm_object *, int)) (&silver_chimera_lock_on_draw)); if (new == NULL) { fprintf(stderr, "silver_chimera_lock_on_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int silver_chimera_lock_on_act(tenm_object *my, const tenm_object *player) { double length; /* sanity check */ if (my == NULL) { fprintf(stderr, "silver_chimera_lock_on_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[2])++; switch (my->count[1]) { case 0: if (my->count[2] >= 20) { my->count[1] = 1; my->count[2] = 0; } break; case 1: length = 5.0 * (double) (140 - my->count[2]); if (my->count[2] % 10 == 0) { if (my->count[2] % 20 == 10 * my->count[3]) { tenm_table_add(laser_angle_new(my->x + length, my->y + length, 9.0, 180, 25.0, 0)); tenm_table_add(laser_angle_new(my->x + length, my->y + length, 9.0, -90, 25.0, 0)); tenm_table_add(laser_angle_new(my->x - length, my->y - length, 9.0, 0, 25.0, 0)); tenm_table_add(laser_angle_new(my->x - length, my->y - length, 9.0, 90, 25.0, 0)); } else { tenm_table_add(laser_angle_new(my->x + length, my->y - length, 9.0, 180, 25.0, 0)); tenm_table_add(laser_angle_new(my->x + length, my->y - length, 9.0, 90, 25.0, 0)); tenm_table_add(laser_angle_new(my->x - length, my->y + length, 9.0, 0, 25.0, 0)); tenm_table_add(laser_angle_new(my->x - length, my->y + length, 9.0, -90, 25.0, 0)); } } if (my->count[2] >= 140) { return 1; } break; default: fprintf(stderr, "silver_chimera_lock_on_act: strange my->count[1] (%d)\n", my->count[1]); break; } return 0; } static int silver_chimera_lock_on_draw(tenm_object *my, int priority) { int status = 0; /* sanity check */ if (my == NULL) { fprintf(stderr, "silver_chimera_lock_on_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; switch (my->count[1]) { case 0: if (silver_chimera_lock_on_draw_square((int) my->x, (int) my->y, 200 + 25 * my->count[2], tenm_map_color(158, 158, 158)) != 0) status = 1; if (silver_chimera_lock_on_draw_square((int) my->x, (int) my->y, 200 - 10 * my->count[2], tenm_map_color(158, 158, 158)) != 0) status = 1; break; case 1: if (silver_chimera_lock_on_draw_square((int) my->x, (int) my->y, 5 * (140 - my->count[2]), tenm_map_color(99, 158, 114)) != 0) status = 1; if (tenm_draw_line(((int) (my->x)) - 25, ((int) (my->y)), ((int) (my->x)) + 25, ((int) (my->y)), 1, tenm_map_color(158, 158, 158)) != 0) status = 1; if (tenm_draw_line(((int) (my->x)), ((int) (my->y)) - 25, ((int) (my->x)), ((int) (my->y)) + 25, 1, tenm_map_color(158, 158, 158)) != 0) status = 1; break; default: fprintf(stderr, "silver_chimera_lock_on_draw: strange my->count[1] " "(%d)\n", my->count[1]); break; } return status; } static int silver_chimera_lock_on_draw_square(int x, int y, int length, tenm_color color) { int status = 0; /* sanity check */ if (length <= 0) { fprintf(stderr, "silver_chimera_lock_on_draw_square: length is " "non-positive (%d)\n", length); return 1; } if (tenm_draw_line(x + length, y + length, x - length, y + length, 1, color) != 0) status = 1; if (tenm_draw_line(x - length, y + length, x - length, y - length, 1, color) != 0) status = 1; if (tenm_draw_line(x - length, y - length, x + length, y - length, 1, color) != 0) status = 1; if (tenm_draw_line(x + length, y - length, x + length, y + length, 1, color) != 0) status = 1; return status; } static tenm_object * silver_chimera_bit_new(int table_index, int n) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x; double y; /* sanity check */ if ((n < 0) || (n > 1)) { fprintf(stderr, "silver_chimera_bit_new: strange n (%d)\n", n); return NULL; } if (n == 0) x = (double) (WINDOW_WIDTH / 8); else x = (double) (WINDOW_WIDTH * 7 / 8); y = -19.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "silver_chimera_bit_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 20.0, y + 20.0, x - 20.0, y + 20.0, x - 20.0, y - 20.0, x + 20.0, y - 20.0); if (p[0] == NULL) { fprintf(stderr, "silver_chimera_bit_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 6); if (count == NULL) { fprintf(stderr, "silver_chimera_bit_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "silver_chimera_bit_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] move mode * [3] move timer * [4] n * [5] core index */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 60; count[4] = n; count[5] = table_index; count_d[0] = 0.0; count_d[1] = (((double) (WINDOW_HEIGHT / 4)) - y) / 60.0; new = tenm_object_new("Silver Chimera bit", ATTR_ENEMY, ATTR_PLAYER_SHOT, 750, x, y, 6, count, 2, count_d, 1, p, (int (*)(tenm_object *, double)) (&silver_chimera_bit_move), (int (*)(tenm_object *, tenm_object *)) (&silver_chimera_bit_hit), (int (*)(tenm_object *, const tenm_object *)) (&silver_chimera_bit_act), (int (*)(tenm_object *, int)) (&silver_chimera_bit_draw)); if (new == NULL) { fprintf(stderr, "silver_chimera_bit_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int silver_chimera_bit_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "silver_chimera_bit_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "silver_chimera_bit_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int silver_chimera_bit_hit(tenm_object *my, tenm_object *your) { int n; /* sanity check */ if (my == NULL) { fprintf(stderr, "silver_chimera_bit_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "silver_chimera_bit_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if (my->count[2] != 1) return 0; deal_damage(my, your, 0); if (silver_chimera_bit_green(my)) add_chain(my, your); my->count[1] = 41; if (my->hit_point <= 0) { add_score(20000); tenm_table_apply(my->count[5], (int (*)(tenm_object *, int)) (&silver_chimera_bit_signal), 0); if (silver_chimera_bit_green(my)) n = 8; else n = 7; tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 1, 1000, n, 8.0, 6)); tenm_table_add(fragment_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 30.0, 30, n, 5.0, 0.0, 20)); return 1; } return 0; } static int silver_chimera_bit_signal(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "Silver Chimera") != 0) return 0; (my->count[4])++; return 0; } static int silver_chimera_bit_act(tenm_object *my, const tenm_object *player) { double x; double y; /* sanity check */ if (my == NULL) { fprintf(stderr, "silver_chimera_bit_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; (my->count[3])++; /* encounter */ if (my->count[2] == 0) { if (my->count[3] >= 120) { my->count[2] = 1; my->count[3] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; return 0; } return 0; } /* speed change */ if ((my->count[3] == 1080) || (my->count[3] == 4680)) { x = (double) (WINDOW_WIDTH / 2); if (my->count[4] == 0) x -= 96.0; else x += 96.0; my->count_d[0] = (x - my->x) / 90.0; my->count_d[1] = (((double) (WINDOW_HEIGHT / 2)) - my->y) / 90.0; } if (((my->count[3] > 1080) && (my->count[3] < 1170)) || ((my->count[3] > 4680) && (my->count[3] < 4770))) { ; } if (((my->count[3] >= 1170) && (my->count[3] < 1890)) || (my->count[3] >= 4770)) { x = (double) (WINDOW_WIDTH / 2); x += ((double) (WINDOW_WIDTH / 2)) * tenm_cos(my->count[3] * 2) * tenm_cos(my->count[3]); if (my->count[4] == 0) x -= 96.0; else x += 96.0; y = (double) (WINDOW_HEIGHT / 4); y += ((double) (WINDOW_HEIGHT / 4)) * tenm_sin(my->count[3]); my->count_d[0] = x - my->x; my->count_d[1] = y - my->y; } if (my->count[3] == 1890) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[3] == 1980) { if (my->count[4] == 0) x = (double) (WINDOW_WIDTH / 8); else x = (double) (WINDOW_WIDTH * 7 / 8); my->count_d[0] = (x - my->x) / 90.0; my->count_d[1] = (((double) (WINDOW_HEIGHT / 4)) - my->y) / 90.0; } if (my->count[3] == 2070) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[2] != 1) return 0; /* shoot */ if ((my->count[3] >= 35) && (my->count[3] < 5490) && (my->count[3] % 14 == my->count[4] * 7)) tenm_table_add(normal_shot_point_new(my->x, my->y, 7.0, player->x +((double)(rand()%101))-50.0, player->y +((double)(rand()%101))-50.0, 4)); return 0; } static int silver_chimera_bit_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; /* sanity check */ if (my == NULL) { fprintf(stderr, "silver_chimera_bit_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; /* decoration */ if (silver_chimera_bit_green(my)) { if (my->count[1] >= 40) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 40) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (tenm_draw_line((int) (my->x + 10.0), (int) (my->y - 20.0), (int) (my->x + 20.0), (int) (my->y - 30.0), 1, color)) status = 1; if (tenm_draw_line((int) (my->x + 20.0), (int) (my->y - 30.0), (int) (my->x - 20.0), (int) (my->y - 30.0), 1, color)) status = 1; if (tenm_draw_line((int) (my->x - 20.0), (int) (my->y - 30.0), (int) (my->x - 10.0), (int) (my->y - 20.0), 1, color)) status = 1; /* body */ /* if (tenm_draw_mass(my->mass, tenm_map_color(0, 0, 0)) != 0) status = 1; */ if (silver_chimera_bit_green(my)) { if (my->count[1] >= 40) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 40) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (tenm_draw_line((int) (my->x + 20.0), (int) (my->y + 20.0), (int) (my->x - 20.0), (int) (my->y + 20.0), 2, color)) status = 1; if (tenm_draw_line((int) (my->x - 20.0), (int) (my->y + 20.0), (int) (my->x - 20.0), (int) (my->y - 20.0), 2, color)) status = 1; if (tenm_draw_line((int) (my->x - 20.0), (int) (my->y - 20.0), (int) (my->x + 20.0), (int) (my->y - 20.0), 2, color)) status = 1; if (tenm_draw_line((int) (my->x + 20.0), (int) (my->y - 20.0), (int) (my->x + 20.0), (int) (my->y + 20.0), 2, color)) status = 1; /* hit point stat */ if ((my->count[2] == 1) && (my->count[1] >= 1)) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 5, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "silver_chimera_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int silver_chimera_bit_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if ((my->count[2] == 1) && (my->count[3] >= 35) && (my->count[3] < 5580)) return 1; return 0; } dangen-0.5/spqr/silver-chimera.h0000644000175000017500000000037410276702741017500 0ustar00ooharaoohara00000000000000/* $Id: silver-chimera.h,v 1.1 2004/04/14 09:03:30 oohara Exp $ */ #ifndef __DANGEN_SILVER_CHIMERA_H__ #define __DANGEN_SILVER_CHIMERA_H__ #include "tenm_object.h" tenm_object *silver_chimera_new(void); #endif /* not __DANGEN_SILVER_CHIMERA_H__ */ dangen-0.5/spqr/spellbook.c0000644000175000017500000003502510276702741016554 0ustar00ooharaoohara00000000000000/* $Id: spellbook.c,v 1.30 2005/06/08 12:05:51 oohara Exp $ */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "score.h" #include "spellbook.h" static int spellbook_move(tenm_object *my, double turn_per_frame); static int spellbook_hit(tenm_object *my, tenm_object *your); static int spellbook_signal(tenm_object *my, int n); static int spellbook_act(tenm_object *my, const tenm_object *player); static int spellbook_draw(tenm_object *my, int priority); static int spellbook_green(const tenm_object *my); tenm_object * spellbook_new(int table_index) { int i; tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = 72.0; double y = -72.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 2); if (p == NULL) { fprintf(stderr, "spellbook_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 24.0, y - 72.0, x + 24.0, y + 72.0, x - 24.0, y + 72.0, x - 24.0, y - 72.0); if (p[0] == NULL) { fprintf(stderr, "spellbook_new: cannot set p[0]\n"); free(p); return NULL; } p[1] = (tenm_primitive *) tenm_polygon_new(4, x + 72.0, y - 24.0, x + 72.0, y + 24.0, x - 72.0, y + 24.0, x - 72.0, y - 24.0); if (p[1] == NULL) { fprintf(stderr, "spellbook_new: cannot set p[1]\n"); (p[0])->delete(p[0]); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 10); if (count == NULL) { fprintf(stderr, "spellbook_new: malloc(count) failed\n"); for (i = 0; i < 2; i++) (p[i])->delete(p[i]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "spellbook_new: malloc(count_d) failed\n"); free(count); for (i = 0; i < 2; i++) (p[i])->delete(p[i]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] life mode * [3] life timer * [4] parent index */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 0; count[4] = table_index; count_d[0] = 0.0; count_d[1] = 4.0; new = tenm_object_new("Spellbook", ATTR_ENEMY, ATTR_PLAYER_SHOT, 600, x, y, 10, count, 2, count_d, 2, p, (int (*)(tenm_object *, double)) (&spellbook_move), (int (*)(tenm_object *, tenm_object *)) (&spellbook_hit), (int (*)(tenm_object *, const tenm_object *)) (&spellbook_act), (int (*)(tenm_object *, int)) (&spellbook_draw)); if (new == NULL) { fprintf(stderr, "spellbook_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); for (i = 0; i < 2; i++) (p[i])->delete(p[i]); free(p); return NULL; } return new; } static int spellbook_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "spellbook_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "spellbook_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); if ((my->count[3] >= 868) && (my->y - 72.0 > ((double) WINDOW_WIDTH))) { tenm_table_apply(my->count[4], (int (*)(tenm_object *, int)) (&spellbook_signal), spellbook_green(my)); return 1; } return 0; } static int spellbook_hit(tenm_object *my, tenm_object *your) { int n; /* sanity check */ if (my == NULL) { fprintf(stderr, "spellbook_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "spellbook_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; deal_damage(my, your, 0); if (spellbook_green(my)) add_chain(my, your); my->count[1] = 41; if (my->hit_point <= 0) { add_score(75); if (spellbook_green(my)) n = 8; else n = 7; tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 1, 1000, n, 8.0, 6)); tenm_table_add(fragment_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 30.0, 30, n, 5.0, 0.0, 20)); tenm_table_apply(my->count[4], (int (*)(tenm_object *, int)) (&spellbook_signal), spellbook_green(my)); return 1; } return 0; } static int spellbook_signal(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "plan 16 more 1") != 0) return 0; (my->count[2])++; if (n) (my->count[3])++; return 0; } static int spellbook_act(tenm_object *my, const tenm_object *player) { int theta; double v[2]; double from[2]; double speed[2]; /* sanity check */ if (my == NULL) { fprintf(stderr, "spellbook_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; (my->count[3])++; /* speed change */ if (my->count[3] == 120) { my->count_d[0] = 4.0; my->count_d[1] = 0.0; } if ((my->count[3] > 120) && (my->count[3] < 952)) { if ((my->count[3] - 120) % 416 == 124) { my->count_d[0] = 0.0; my->count_d[1] = -4.0; } else if ((my->count[3] - 120) % 416 == 208) { my->count_d[0] = -4.0; my->count_d[1] = 0.0; } else if ((my->count[3] - 120) % 416 == 332) { my->count_d[0] = 0.0; my->count_d[1] = 4.0; } else if ((my->count[3] - 120) % 416 == 0) { my->count_d[0] = 4.0; my->count_d[1] = 0.0; } } /* shoot */ if (my->count[3] % 23 == 0) { tenm_table_add(laser_point_new(my->x, my->y, 4.5, player->x, player->y, 25.0, 0)); } if (my->count[3] % 62 == 0) { theta = ((my->count[3] % 248) / 62) * 90; v[0] = 0.0; v[1] = -60.0; from[0] = v[0]; from[1] = v[1]; vector_rotate(from, v, theta); v[0] = 3.0; v[1] = 1.0; speed[0] = v[0]; speed[1] = v[1]; vector_rotate(speed, v, theta); tenm_table_add(normal_shot_new(my->x + from[0], my->y + from[1], speed[0], speed[1], 4, -2, 0)); v[0] = 0.0; v[1] = 60.0; from[0] = v[0]; from[1] = v[1]; vector_rotate(from, v, theta); v[0] = 3.0; v[1] = -1.0; speed[0] = v[0]; speed[1] = v[1]; vector_rotate(speed, v, theta); tenm_table_add(normal_shot_new(my->x + from[0], my->y + from[1], speed[0], speed[1], 4, -2, 0)); v[0] = 0.0; v[1] = -60.0; from[0] = v[0]; from[1] = v[1]; vector_rotate(from, v, theta); v[0] = 5.0; v[1] = 1.0; speed[0] = v[0]; speed[1] = v[1]; vector_rotate(speed, v, theta); tenm_table_add(normal_shot_new(my->x + from[0], my->y + from[1], speed[0], speed[1], 4, -2, 0)); v[0] = 0.0; v[1] = 60.0; from[0] = v[0]; from[1] = v[1]; vector_rotate(from, v, theta); v[0] = 5.0; v[1] = -1.0; speed[0] = v[0]; speed[1] = v[1]; vector_rotate(speed, v, theta); tenm_table_add(normal_shot_new(my->x + from[0], my->y + from[1], speed[0], speed[1], 4, -2, 0)); } if (my->count[3] % 62 == 31) { theta = (((my->count[3] - 31) % 248) / 62) * 90; v[0] = 60.0; v[1] = 0.0; from[0] = v[0]; from[1] = v[1]; vector_rotate(from, v, theta); v[0] = 3.0; v[1] = 1.0; speed[0] = v[0]; speed[1] = v[1]; vector_rotate(speed, v, theta + 45); tenm_table_add(normal_shot_new(my->x + from[0], my->y + from[1], speed[0], speed[1], 4, -2, 0)); v[0] = 0.0; v[1] = 60.0; from[0] = v[0]; from[1] = v[1]; vector_rotate(from, v, theta); v[0] = 3.0; v[1] = -1.0; speed[0] = v[0]; speed[1] = v[1]; vector_rotate(speed, v, theta + 45); tenm_table_add(normal_shot_new(my->x + from[0], my->y + from[1], speed[0], speed[1], 4, -2, 0)); v[0] = 60.0; v[1] = 0.0; from[0] = v[0]; from[1] = v[1]; vector_rotate(from, v, theta); v[0] = 5.0; v[1] = 1.0; speed[0] = v[0]; speed[1] = v[1]; vector_rotate(speed, v, theta + 45); tenm_table_add(normal_shot_new(my->x + from[0], my->y + from[1], speed[0], speed[1], 4, -2, 0)); v[0] = 0.0; v[1] = 60.0; from[0] = v[0]; from[1] = v[1]; vector_rotate(from, v, theta); v[0] = 5.0; v[1] = -1.0; speed[0] = v[0]; speed[1] = v[1]; vector_rotate(speed, v, theta + 45); tenm_table_add(normal_shot_new(my->x + from[0], my->y + from[1], speed[0], speed[1], 4, -2, 0)); } return 0; } static int spellbook_draw(tenm_object *my, int priority) { double size; int status = 0; tenm_color color; char temp[32]; /* sanity check */ if (my == NULL) { fprintf(stderr, "spellbook_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; /* body */ if (spellbook_green(my)) { if (my->count[1] >= 40) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 40) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } size = 24.0; if (tenm_draw_line(((int) (my->x + size)), ((int) (my->y - size * 3.0)), ((int) (my->x + size)), ((int) (my->y - size)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + size)), ((int) (my->y - size)), ((int) (my->x + size * 3.0)), ((int) (my->y - size)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + size * 3.0)), ((int) (my->y - size)), ((int) (my->x + size * 3.0)), ((int) (my->y + size)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + size * 3.0)), ((int) (my->y + size)), ((int) (my->x + size)), ((int) (my->y + size)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + size)), ((int) (my->y + size)), ((int) (my->x + size)), ((int) (my->y + size * 3.0)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + size)), ((int) (my->y + size * 3.0)), ((int) (my->x - size)), ((int) (my->y + size * 3.0)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - size)), ((int) (my->y + size * 3.0)), ((int) (my->x - size)), ((int) (my->y + size)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - size)), ((int) (my->y + size)), ((int) (my->x - size * 3.0)), ((int) (my->y + size)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - size * 3.0)), ((int) (my->y + size)), ((int) (my->x - size * 3.0)), ((int) (my->y - size)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - size * 3.0)), ((int) (my->y - size)), ((int) (my->x - size)), ((int) (my->y - size)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - size)), ((int) (my->y - size)), ((int) (my->x - size)), ((int) (my->y - size * 3.0)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - size)), ((int) (my->y - size * 3.0)), ((int) (my->x + size)), ((int) (my->y - size * 3.0)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + size)), ((int) (my->y - size * 3.0)), ((int) (my->x + size)), ((int) (my->y - size)), 3, color) != 0) status = 1; /* hit point stat */ if ((priority == 0) && (my->count[1] > 0)) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 10, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "spellbook_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int spellbook_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if (my->count[3] < 868) return 1; return 0; } dangen-0.5/spqr/spellbook.h0000644000175000017500000000035610276702741016560 0ustar00ooharaoohara00000000000000/* $Id: spellbook.h,v 1.3 2005/06/07 15:15:17 oohara Exp $ */ #ifndef __DANGEN_SPELLBOOK_H__ #define __DANGEN_SPELLBOOK_H__ #include "tenm_object.h" tenm_object *spellbook_new(int table_index); #endif /* not __DANGEN_SPELLBOOK_H__ */ dangen-0.5/spqr/stage-clear.c0000644000175000017500000000622010276702741016744 0ustar00ooharaoohara00000000000000/* $Id: stage-clear.c,v 1.9 2005/07/10 04:32:37 oohara Exp $ */ #include /* malloc */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "util.h" #include "tenm_table.h" #include "stage.h" #include "score.h" #include "scheduler.h" #include "ship.h" #include "stage-clear.h" static int stage_clear_act(tenm_object *my, const tenm_object *player); static int stage_clear_draw(tenm_object *my, int priority); tenm_object * stage_clear_new(int t) { tenm_object *new = NULL; int *count = NULL; /* sanity check */ if (t < 0) { fprintf(stderr, "stage_clear_new: t is negative (%d)\n", t); return NULL; } count = (int *) malloc(sizeof(int) * 2); if (count == NULL) { fprintf(stderr, "stage_clear_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] timer * [1] message delay */ count[0] = -1; count[1] = t; new = tenm_object_new("stage clear", 0, 0, 1, 0.0, 0.0, 2, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&stage_clear_act), (int (*)(tenm_object *, int)) (&stage_clear_draw)); if (new == NULL) { fprintf(stderr, "stage_clear_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int stage_clear_act(tenm_object *my, const tenm_object *player) { int stage; /* sanity check */ if (my == NULL) { fprintf(stderr, "stage_clear_act: my is NULL\n"); return 0; } if (player == NULL) return 0; if (get_ship() < 0) return 1; (my->count[0])++; if (my->count[0] == 0) { stage = get_stage_number(); if ((stage >= 1) && (stage <= 5)) set_stage_cleared(stage, 1); } if (my->count[0] >= my->count[1] + 100) { set_this_stage_cleared(1); return 1; } return 0; } static int stage_clear_draw(tenm_object *my, int priority) { int status = 0; char temp[32]; /* sanity check */ if ((get_stage_number() < 1) || (get_stage_number() > 5)) return 0; if (priority != 1) return 0; if (my->count[0] < my->count[1]) return 0; if (get_ship() < 0) return 0; if (get_stage_number() <= 4) sprintf(temp, "stage %d cleared", get_stage_number()); else sprintf(temp, "final stage cleared"); if (draw_string(WINDOW_WIDTH / 2 - ((int) strlen(temp)) * 9 / 2, 190, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "stage_clear_draw: draw_string (stage number) failed\n"); status = 1; } sprintf(temp, "stage score: %8d", get_stage_score(get_stage_number())); if (draw_string(WINDOW_WIDTH / 2 - ((int) strlen(temp)) * 9 / 2, 220, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "stage_title_draw: draw_string (stage score) failed\n"); status = 1; } return status; } dangen-0.5/spqr/stage-clear.h0000644000175000017500000000035610276702741016755 0ustar00ooharaoohara00000000000000/* $Id: stage-clear.h,v 1.2 2004/08/18 02:49:54 oohara Exp $ */ #ifndef __DANGEN_STAGE_CLEAR_H__ #define __DANGEN_STAGE_CLEAR_H__ #include "tenm_object.h" tenm_object *stage_clear_new(int t); #endif /* not __DANGEN_STAGE_CLEAR_H__ */ dangen-0.5/spqr/stage-list.c0000644000175000017500000001327210276702741016636 0ustar00ooharaoohara00000000000000/* $Id: stage-list.c,v 1.8 2005/07/01 19:24:16 oohara Exp $ */ #include /* malloc */ #include /* strdup, strcmp */ #include #include "stage-list.h" static int stage_list_add(stage_list *p, stage_plan *new_plan); stage_plan * stage_plan_new(int stage_id) { stage_plan *new = NULL; const char *name = NULL; int difficulty; new = (stage_plan *) malloc(sizeof(stage_plan)); if (new == NULL) { fprintf(stderr, "stage_plan_new: malloc failed\n"); return NULL; } switch(stage_id) { case 0: name = "dangen tutorial"; difficulty = PLAN_TUTORIAL; break; case 1: name = "L"; difficulty = PLAN_HARDEST; break; case 2: name = "Senators"; difficulty = PLAN_VERY_HARD; break; case 3: name = "Seiron"; difficulty = PLAN_HARD; break; case 4: name = "Seiron Fake"; difficulty = PLAN_EASY; break; case 5: name = "Perpeki"; difficulty = PLAN_VERY_HARD; break; case 6: name = "Empty Wind"; difficulty = PLAN_VERY_HARD; break; case 7: name = "cat tail (grep mix)"; difficulty = PLAN_HARD; break; case 8: name = "Silver Chimera"; difficulty = PLAN_HARD; break; case 9: name = "0x82da3104"; difficulty = PLAN_HARD; break; case 10: name = "Tadashi"; difficulty = PLAN_NORMAL; break; case 11: name = "Theorem Weapon"; difficulty = PLAN_NORMAL; break; case 12: name = "W-KO"; difficulty = PLAN_NORMAL; break; case 13: name = "Hell Salvage"; difficulty = PLAN_NORMAL; break; case 14: name = "Strikers 1341"; difficulty = PLAN_EASY; break; case 15: name = "Watcher Below"; difficulty = PLAN_EASY; break; case 16: name = "cat tail"; difficulty = PLAN_EASY; break; case 17: name = "Afterdeath"; difficulty = PLAN_VERY_EASY; break; case 18: name = "Hugin"; difficulty = PLAN_VERY_EASY; break; case 19: name = "Gosanpachi"; difficulty = PLAN_VERY_EASY; break; case 20: name = "P-can"; difficulty = PLAN_EASIEST; break; default: name = "default"; difficulty = PLAN_NORMAL; break; } new->stage_id = stage_id; new->name = name; new->difficulty = difficulty; return new; } void stage_plan_delete(stage_plan *p) { if (p == NULL) return; /* don't free p->name */ free(p); } /* if match_func (arg 1) is not NULL, an stage_plan *p is * added to the return value only if (*match_func)(p, data) * returns true (non-zero) * set match_func (arg 1) to NULL to get the full list (including the tutorial) */ stage_list * stage_list_new(int (*match_func)(stage_plan *, void *), void *data) { int i; stage_list *new = NULL; stage_plan *new_plan = NULL; new = (stage_list *) malloc(sizeof(stage_list)); if (new == NULL) { fprintf(stderr, "stage_list_new: malloc failed\n"); return NULL; } new->n = 0; new->p = NULL; for (i = 0; i <= NUMBER_PLAN; i++) { new_plan = stage_plan_new(i); if (new_plan == NULL) { fprintf(stderr, "stage_list_new: plan %d is NULL\n", i); continue; } if ((match_func != NULL) && (!((*match_func)(new_plan, data)))) continue; stage_list_add(new, new_plan); } return new; } /* return 0 on success, 1 on error */ static int stage_list_add(stage_list *p, stage_plan *new_plan) { stage_plan **temp = NULL; /* sanity check */ if (p == NULL) { fprintf(stderr, "stage_list_add: p is NULL\n"); return 1; } if (new_plan == NULL) if (p == NULL) { fprintf(stderr, "stage_list_add: new_plan is NULL\n"); return 1; } if (p->p == NULL) { p->n = 0; temp = (stage_plan **) malloc(sizeof(stage_plan *)); } else { temp = (stage_plan **) realloc(p->p, sizeof(stage_plan *) * (p->n + 1)); } if (temp == NULL) { fprintf(stderr, "stage_list_add: cannot allocate memory for p->p\n"); return 1; } p->p = temp; p->p[p->n] = new_plan; (p->n)++; return 0; } void stage_list_delete(stage_list *p) { int i; if (p == NULL) return; if (p->p != NULL) { for (i = 0; i < p->n; i++) stage_plan_delete(p->p[i]); free(p->p); } free(p); } /* don't free the pointer returned by this function */ const char * stage_difficulty_string(int n) { const char *p = NULL; switch(n) { case PLAN_TUTORIAL: p = "tutorial"; break; case PLAN_EASIEST: p = "easiest"; break; case PLAN_VERY_EASY: p = "very easy"; break; case PLAN_EASY: p = "easy"; break; case PLAN_NORMAL: p = "normal"; break; case PLAN_HARD: p = "hard"; break; case PLAN_VERY_HARD: p = "very hard"; break; case PLAN_HARDEST: p = "hardest"; break; default: fprintf(stderr, "stage_difficulty_string: strange n (%d)\n", n); p = "unknown"; break; } return p; } /* for qsort() * return a positive value if a (arg 1) should be after b (arg 2) * a negative value if a (arg 1) should be before b (arg 2) * 0 if a (arg 1) and b (arg 2) are the same */ /* this void * should be stage_plan ** */ int stage_compare(const void *a, const void *b) { const stage_plan *a_temp = *((const stage_plan * const *) a); const stage_plan *b_temp = *((const stage_plan * const *) b); if (a_temp->difficulty > b_temp->difficulty) return 1; else if (a_temp->difficulty < b_temp->difficulty) return -1; if ((a_temp->name != NULL) && (b_temp->name != NULL)) { if (strcmp(a_temp->name, b_temp->name) != 0) return strcmp(a_temp->name, b_temp->name); } if (a_temp->stage_id > b_temp->stage_id) return 1; else if (a_temp->stage_id < b_temp->stage_id) return -1; return 0; } dangen-0.5/spqr/stage-list.h0000644000175000017500000000177310276702741016646 0ustar00ooharaoohara00000000000000/* $Id: stage-list.h,v 1.4 2005/07/01 19:19:10 oohara Exp $ */ #ifndef __DANGEN_STAGE_LIST_H__ #define __DANGEN_STAGE_LIST_H__ struct _stage_plan { int stage_id; const char *name; int difficulty; }; typedef struct _stage_plan stage_plan; struct _stage_list { /* number of stage_plan */ int n; stage_plan **p; }; typedef struct _stage_list stage_list; /* total number of stage plans (excluding the tutorial) */ #define NUMBER_PLAN 20 /* stage difficulty */ #define PLAN_TUTORIAL 0 #define PLAN_EASIEST 1 #define PLAN_VERY_EASY 2 #define PLAN_EASY 3 #define PLAN_NORMAL 4 #define PLAN_HARD 5 #define PLAN_VERY_HARD 6 #define PLAN_HARDEST 7 stage_plan *stage_plan_new(int stage_id); void stage_plan_delete(stage_plan *p); stage_list *stage_list_new(int (*match_func)(stage_plan *, void *), void *data); void stage_list_delete(stage_list *p); const char *stage_difficulty_string(int n); int stage_compare(const void *a, const void *b); #endif /* not __DANGEN_STAGE_LIST_H__ */ dangen-0.5/spqr/stage-select.c0000644000175000017500000003143210276702741017140 0ustar00ooharaoohara00000000000000/* $Id: stage-select.c,v 1.159 2005/07/02 18:27:02 oohara Exp $ */ #include /* malloc */ #include /* strdup, strcmp */ #include #include "stage.h" #include "tenm_input.h" #include "tenm_graphic.h" #include "util.h" #include "tenm_timer.h" #include "background.h" #include "const.h" #include "score.h" #include "ship.h" #include "esc-ok.h" #include "pause.h" #include "option.h" #include "info.h" #include "stage-list.h" #include "record_data.h" #include "stage-select.h" #define MENU_SIZE 5 #define TITLE_MOVE_BEGIN 30 #define TITLE_MOVE_END 45 static int stage_select_rule(stage_plan *p, void *data); /* return * 0 if a stage is selected * 1 if the game should be over * 2 if the program should quit */ int stage_select(game_record *record) { int i; int x; int y; int head = 0; int cursor = 0; int delay = 6; int delay_next = 6; int t = 0; int chosen = 0; int last_move = 0; int t_demo = 0; stage_list *list = NULL; char temp[64]; plan_record *p_rec = NULL; int menu_size; int n1; int n2; int max_id; /* to skip stage select */ /* set_stage_id(1); return 0; */ /* sanity check */ if (TITLE_MOVE_BEGIN >= TITLE_MOVE_END) { fprintf(stderr, "stage_select: TITLE_MOVE_BEGIN >= TITLE_MOVE_END " "(%d, %d)\n", TITLE_MOVE_BEGIN, TITLE_MOVE_END); return 2; } if (record == NULL) { fprintf(stderr, "stage_select: record is NULL\n"); return 2; } if (!game_record_valid(record, 0)) { fprintf(stderr, "stage_select: record is invalid\n"); return 2; } list = stage_list_new((int (*)(stage_plan *, void *)) (&stage_select_rule), NULL); if (list == NULL) { fprintf(stderr, "stage_select: stage_list_new failed\n"); return 2; } if (list->n <= 0) { if (get_stage_number() > 4) return 1; fprintf(stderr, "stage_select: list->n is non-positive (%d)\n", list->n); return 2; } qsort((void *) list->p, (size_t) (list->n), sizeof(stage_plan *), (int (*)(const void *, const void *)) stage_compare); max_id = -1; for (i = 0; i < list->n; i++) { if (max_id < (list->p[i])->stage_id) max_id = (list->p[i])->stage_id; } if (max_id > record->plan_n) { fprintf(stderr, "show_record: max_id > record->plan_n (%d > %d)\n", max_id, record->plan_n); stage_list_delete(list); return 1; } menu_size = MENU_SIZE; if (menu_size > list->n) menu_size = list->n; if (menu_size <= 0) menu_size = 1; /* we don't need to pause in the stage select */ tenm_set_focus_handler((void (*)(int)) NULL); clear_pause(); set_background(0); tenm_timer_reset(); while (1 == 1) { /* quit the program if a SDL_QUIT event happened * (for example, if a SIGINT signal (sent by Ctrl+c) is received) */ if (tenm_event_handle() != 0) { stage_list_delete(list); return 2; } /* quit the game if ESC is pressed */ if (tenm_get_key_status() & 32) { if (get_esc_ok()) { set_esc_ok(0); stage_list_delete(list); return 1; } } else { set_esc_ok(1); } /* space */ if ((t_demo > TITLE_MOVE_END) && (!(chosen)) && (tenm_get_key_status() & 16)) { chosen = 1; } if (chosen) { t++; if (t > 50) break; } else if (t_demo > TITLE_MOVE_END) { switch (tenm_get_key_status() & 15) { case 1: /* up */ if (delay <= 0) { if (head + cursor <= 0) { head = list->n - menu_size; cursor = menu_size - 1; } else if (cursor <= 0) { head--; } else { cursor--; } if (last_move == 1) { delay_next -= 2; if (delay_next < 0) delay_next = 0; } delay = delay_next; last_move = 1; } else { delay--; } break; case 2: /* down */ if (delay <= 0) { if (head + cursor >= list->n - 1) { head = 0; cursor = 0; } else if (cursor >= menu_size - 1) { head++; } else { cursor++; } if (last_move == 2) { delay_next -= 2; if (delay_next < 0) delay_next = 0; } delay = delay_next; last_move = 2; } else { delay--; } break; case 4: /* right */ if (delay <= 0) { for (i = 1; i < list->n; i++) { n1 = head + cursor + i; n2 = head + cursor; while (n1 >= list->n) n1 -= list->n; while (n1 < 0) n1 += list->n; while (n2 >= list->n) n2 -= list->n; while (n2 < 0) n2 += list->n; if ((list->p[n1])->difficulty != (list->p[n2])->difficulty) { head = n1; cursor = 0; if (head + menu_size - 1 > list->n - 1) { cursor = head + menu_size - list->n; head = list->n - menu_size; } break; } } delay = 6; delay_next = 6; last_move = 4; } else { delay--; } break; case 8: /* left */ if (delay <= 0) { for (i = 1; i < list->n; i++) { n1 = head + cursor - i - 1; n2 = head + cursor - i; while (n1 >= list->n) n1 -= list->n; while (n1 < 0) n1 += list->n; while (n2 >= list->n) n2 -= list->n; while (n2 < 0) n2 += list->n; if ((list->p[n1])->difficulty != (list->p[n2])->difficulty) { head = n2; cursor = 0; if (head + menu_size - 1 > list->n - 1) { cursor = head + menu_size - list->n; head = list->n - menu_size; } break; } } delay = 6; delay_next = 6; last_move = 8; } else { delay--; } break; default: delay = 0; delay_next = 6; last_move = 0; break; } } if ((head < 0) || (head + menu_size - 1 > list->n - 1)) { fprintf(stderr, "stage_select: strange head (%d)\n", head); head = 0; } if ((cursor < 0) || (cursor >= menu_size)) { fprintf(stderr, "stage_select: strange cursor (%d)\n", cursor); cursor = 0; } clear_window_with_background(); /* draw the list */ if (t_demo > TITLE_MOVE_END) { for (i = 0; i < menu_size; i++) { if (head + i >= list->n) break; sprintf(temp, "[%.10s] %.50s", stage_difficulty_string((list->p[head + i])->difficulty), (list->p[head + i])->name); if (draw_string(80, 120 + 20 * i, temp, (int) strlen(temp)) != 0) fprintf(stderr, "stage_select: draw_string (list %d) failed\n", i); if (i == cursor) { /* a bit too noisy */ /* sprintf(temp, "%2d", head + i + 1); if (draw_string(30, 120 + 20 * i, temp, (int) strlen(temp)) != 0) fprintf(stderr, "stage_select: draw_string (list #) failed\n"); */ if (t % 10 < 5) { if (draw_string(60, 120 + 20 * i, ">", 1) != 0) fprintf(stderr, "stage_select: draw_string (cursor) failed\n"); } } } } else if (t_demo < TITLE_MOVE_BEGIN) { if (draw_string(266, 190, "stage select", 12) != 0) fprintf(stderr, "stage_select: draw_string (title) failed\n"); } show_score(NULL); show_ship(NULL); if (get_stage_number() <= 4) sprintf(temp, "stage %d", get_stage_number()); else sprintf(temp, "final stage"); if (t_demo > TITLE_MOVE_END) { x = WINDOW_WIDTH - 10 - ((int) strlen(temp)) * 9; y = 30; } else if (t_demo < TITLE_MOVE_BEGIN) { x = WINDOW_WIDTH / 2 - ((int) strlen(temp)) * 9 / 2; y = 210; } else { x = (WINDOW_WIDTH - 10 - ((int) strlen(temp)) * 9) * (t_demo - TITLE_MOVE_BEGIN); y = 30 * (t_demo - TITLE_MOVE_BEGIN); x += (WINDOW_WIDTH / 2 - ((int) strlen(temp)) * 9 / 2) * (TITLE_MOVE_END - t_demo); y += 210 * (TITLE_MOVE_END - t_demo); x /= TITLE_MOVE_END - TITLE_MOVE_BEGIN; y /= TITLE_MOVE_END - TITLE_MOVE_BEGIN; } if (draw_string(x, y, temp, (int) strlen(temp)) != 0) fprintf(stderr, "stage_select: draw_string (stage number) " "failed\n"); if (t_demo > TITLE_MOVE_END) { if (draw_string(WINDOW_WIDTH / 2 - 292, 400, "up/down to move the cursor, left/right for " "difficulty-based move", 65) != 0) fprintf(stderr, "stage_select: draw_string (instruction line 1) " "failed\n"); if (draw_string(WINDOW_WIDTH / 2 - 166, 420, "press space to decide, or ESC to quit", 37) != 0) fprintf(stderr, "stage_select: draw_string (instruction line 2) " "failed\n"); } /* draw the play record */ if (t_demo > TITLE_MOVE_END) { p_rec = record->plan_p[(list->p[head + cursor])->stage_id]; if (draw_string(480, 140, "record", 6) != 0) fprintf(stderr, "stage_select: draw_string (record title) failed\n"); if (draw_string(480, 160, "max", 3) != 0) fprintf(stderr, "stage_select: draw_string (record score max title) " "failed\n"); if (p_rec->number_play > 0) sprintf(temp, "%8d", p_rec->score_max); else sprintf(temp, " ---"); if (draw_string(510, 180, temp, (int) strlen(temp)) != 0) fprintf(stderr, "stage_select: draw_string (record score max value) " "failed\n"); if (draw_string(480, 200, "min cleared", 11) != 0) fprintf(stderr, "stage_select: draw_string (record score min cleared " "title) " "failed\n"); if (p_rec->number_clear > 0) sprintf(temp, "%8d", p_rec->score_min_cleared); else sprintf(temp, " ---"); if (draw_string(510, 220, temp, (int) strlen(temp)) != 0) fprintf(stderr, "stage_select: draw_string (record score min cleared " "value) " "failed\n"); if (draw_string(480, 240, "play", 11) != 0) fprintf(stderr, "stage_select: draw_string (record play title) " "failed\n"); if (p_rec->number_play >= 0) sprintf(temp, "%8d", p_rec->number_play); else sprintf(temp, " ---"); if (draw_string(510, 260, temp, (int) strlen(temp)) != 0) fprintf(stderr, "stage_select: draw_string (record play value) " "failed\n"); } tenm_redraw_window(); if (t_demo <= TITLE_MOVE_END) t_demo++; tenm_wait_next_frame(); } set_stage_id(get_stage_number(), (list->p[head + cursor])->stage_id); set_stage_name(get_stage_number(), (list->p[head + cursor])->name); set_stage_difficulty(get_stage_number(), (list->p[head + cursor])->difficulty); stage_list_delete(list); return 0; } /* return 1 (true) or 0 (false) */ static int stage_select_rule(stage_plan *p, void *data) { int i; int ok_very_hard = 0; int ok_hardest = 0; const option *op = NULL; /* sanity check */ if (p == NULL) return 0; op = get_option(); if (op == NULL) return 0; if (p->difficulty == PLAN_TUTORIAL) return 0; if (op->free_select != 0) return 1; for (i = 1; i < get_stage_number(); i++) { if (get_stage_difficulty(i) >= PLAN_NORMAL) { ok_very_hard = 1; break; } } if (get_stage_number() == 5) { for (i = 1; i < get_stage_number(); i++) { if (get_stage_difficulty(i) >= PLAN_HARD) { ok_hardest = 1; break; } } } if (get_stage_number() == 5) { if ((p->difficulty == PLAN_HARDEST) && (ok_hardest)) return 1; return 0; } if ((p->difficulty == PLAN_VERY_HARD) && (!ok_very_hard)) return 0; if ((p->difficulty == PLAN_HARDEST) && (!ok_hardest)) return 0; for (i = 1; i <= 5; i++) { if (get_stage_id(i) == p->stage_id) return 0; } return 1; } dangen-0.5/spqr/stage-select.h0000644000175000017500000000036510276702741017146 0ustar00ooharaoohara00000000000000/* $Id: stage-select.h,v 1.25 2005/06/30 18:44:58 oohara Exp $ */ #ifndef __DANGEN_STAGE_SELECT_H__ #define __DANGEN_STAGE_SELECT_H__ #include "record_data.h" int stage_select(game_record *record); #endif /* not __DANGEN_STAGE_SELECT_H__ */ dangen-0.5/spqr/stage-title.c0000644000175000017500000000520711625011142016766 0ustar00ooharaoohara00000000000000/* $Id: stage-title.c,v 1.7 2011/08/23 20:49:38 oohara Exp $ */ #include /* malloc */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "util.h" #include "tenm_table.h" #include "stage.h" #include "stage-title.h" static int stage_title_act(tenm_object *my, const tenm_object *player); static int stage_title_draw(tenm_object *my, int priority); tenm_object * stage_title_new(void) { tenm_object *new = NULL; int *count = NULL; count = (int *) malloc(sizeof(int) * 1); if (count == NULL) { fprintf(stderr, "stage_title_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] timer */ count[0] = 0; new = tenm_object_new("stage title", 0, 0, 1, 0.0, 0.0, 1, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&stage_title_act), (int (*)(tenm_object *, int)) (&stage_title_draw)); if (new == NULL) { fprintf(stderr, "stage_title_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int stage_title_act(tenm_object *my, const tenm_object *player) { /* sanity check */ if (my == NULL) { fprintf(stderr, "stage_title_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[0])++; if (my->count[0] >= 100) return 1; return 0; } static int stage_title_draw(tenm_object *my, int priority) { int status = 0; char temp[32]; /* sanity check */ if ((get_stage_number() < 1) || (get_stage_number() > 5)) return 0; if (get_stage_name(get_stage_number()) == NULL) return 0; if (priority != 1) return 0; if (get_stage_number() <= 4) sprintf(temp, "stage %d", get_stage_number()); else sprintf(temp, "final stage"); if (draw_string(WINDOW_WIDTH / 2 - ((int) strlen(temp)) * 9 / 2, 190, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "stage_title_draw: draw_string (stage number) failed\n"); status = 1; } sprintf(temp, "%.20s", get_stage_name(get_stage_number())); if (draw_string(WINDOW_WIDTH / 2 - ((int) strlen(temp)) * 9 / 2, 220, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "stage_title_draw: draw_string (stage name) failed\n"); status = 1; } return status; } dangen-0.5/spqr/stage-title.h0000644000175000017500000000035510276702741017007 0ustar00ooharaoohara00000000000000/* $Id: stage-title.h,v 1.1 2004/08/17 14:53:12 oohara Exp $ */ #ifndef __DANGEN_STAGE_TITLE_H__ #define __DANGEN_STAGE_TITLE_H__ #include "tenm_object.h" tenm_object *stage_title_new(void); #endif /* not __DANGEN_STAGE_TITLE_H__ */ dangen-0.5/spqr/strikers.c0000644000175000017500000014125710276702741016435 0ustar00ooharaoohara00000000000000/* $Id: strikers.c,v 1.119 2005/05/27 00:36:07 oohara Exp $ */ /* [easy] Strikers 1341 */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "stage-clear.h" #include "score.h" #include "strikers.h" static int strikers_act(tenm_object *my, const tenm_object *player); static int strikers_draw(tenm_object *my, int priority); static int strikers_striker_signal(tenm_object *my, int n); static tenm_object *striker_505_new(int table_index); static int striker_505_move(tenm_object *my, double turn_per_frame); static int striker_505_hit(tenm_object *my, tenm_object *your); static void striker_505_next(tenm_object *my); static int striker_505_act(tenm_object *my, const tenm_object *player); static int striker_505_draw(tenm_object *my, int priority); static int striker_505_draw_bit(double x, double y, tenm_color color); static int striker_505_green(const tenm_object *my); static tenm_object *striker_446_new(int table_index); static int striker_446_move(tenm_object *my, double turn_per_frame); static int striker_446_hit(tenm_object *my, tenm_object *your); static void striker_446_next(tenm_object *my); static int striker_446_act(tenm_object *my, const tenm_object *player); static int striker_446_draw(tenm_object *my, int priority); static int striker_446_draw_bit(double x, double y, tenm_color color); static int striker_446_green(const tenm_object *my); static tenm_object *striker_1341_new(int table_index); static int striker_1341_move(tenm_object *my, double turn_per_frame); static int striker_1341_hit(tenm_object *my, tenm_object *your); static void striker_1341_next(tenm_object *my); static int striker_1341_act(tenm_object *my, const tenm_object *player); static int striker_1341_draw(tenm_object *my, int priority); static int striker_1341_draw_bit(double x, double y, tenm_color color); static int striker_1341_green(const tenm_object *my); tenm_object * strikers_new(void) { tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; count = (int *) malloc(sizeof(int) * 8); if (count == NULL) { fprintf(stderr, "strikers_new: malloc(count) failed\n"); return NULL; } count_d = (double *) malloc(sizeof(double) * 4); if (count_d == NULL) { fprintf(stderr, "strikers_new: malloc(count_d) failed\n"); free(count); return NULL; } /* list of count * [0] number of strikers killed * [1] timer */ /* list of count_d */ count[0] = 0; count[1] = -30; new = tenm_object_new("Strikers 1341 manager", 0, 0, 1, 0.0, 0.0, 8, count, 4, count_d, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&strikers_act), (int (*)(tenm_object *, int)) (&strikers_draw)); if (new == NULL) { fprintf(stderr, "strikers_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); return NULL; } return new; } static int strikers_act(tenm_object *my, const tenm_object *player) { /* sanity check */ if (my == NULL) { fprintf(stderr, "strikers_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[1])++; if ((my->count[0] == 0) && (my->count[1] == 180)) tenm_table_add(striker_505_new(my->table_index)); if ((my->count[0] == 1) && (my->count[1] == 180)) tenm_table_add(striker_446_new(my->table_index)); if ((my->count[0] == 2) && (my->count[1] == 30)) tenm_table_add(striker_1341_new(my->table_index)); if (my->count[0] >= 3) { if (my->count[1] >= 0) { tenm_table_add(stage_clear_new(100)); return 1; } } return 0; } static int strikers_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; int i; int j; int theta; double x; double y; /* sanity check */ if (my == NULL) { fprintf(stderr, "strikers_draw: my is NULL\n"); return 0; } if (priority != -1) return 0; if (my->count[0] >= 2) return 0; if ((my->count[1] < 0) || (my->count[1] >= 150)) return 0; for (i = 0; i < 3; i++) { if (i > 2 - my->count[0]) continue; theta = -10; color = tenm_map_color(182, 147, 123); if (my->count[1] < 50) { x = -15.0 + 6.0 * tenm_cos(-10) * ((double) (my->count[1])); y = 300.0 + 6.0 * tenm_sin(-10) * ((double) (my->count[1])); } else if (my->count[1] < 100) { x = -15.0 + 3.0 * tenm_cos(-10) * ((double) (my->count[1] + 50)); y = 300.0 + 3.0 * tenm_sin(-10) * ((double) (my->count[1] + 50)); } else if (i == 2 - my->count[0]) { x = -15.0 + 6.0 * tenm_cos(-10) * 75.0 + 250.0 * tenm_cos(-100); y = 300.0 + 6.0 * tenm_sin(-10) * 75.0 + 250.0 * tenm_sin(-100); x += 250.0 * tenm_cos(80 - (my->count[1] - 100) * 3); y += 250.0 * tenm_sin(80 - (my->count[1] - 100) * 3); theta -= (my->count[1] - 100) * 3; color = tenm_map_color(95, 47, 13); } else { x = -15.0 + 6.0 * tenm_cos(-10) * ((double) (my->count[1] - 25)); y = 300.0 + 6.0 * tenm_sin(-10) * ((double) (my->count[1] - 25)); } if (i == 1) { x += 45.0 * tenm_cos(-160); y += 45.0 * tenm_sin(-160); } else if (i == 2) { x += 45.0 * tenm_cos(140); y += 45.0 * tenm_sin(140); } if (my->count[0] == 1) { x = ((double) WINDOW_WIDTH) - x; theta = 180 - theta; } for (j = 0; j < 360; j += 120) if (tenm_draw_line((int) (x + 15.0 * tenm_cos(theta + j)), (int) (y + 15.0 * tenm_sin(theta + j)), (int) (x + 15.0 * tenm_cos(theta + 120 + j)), (int) (y + 15.0 * tenm_sin(theta + 120 + j)), 1, color) != 0) status = 1; } return status; } static int strikers_striker_signal(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "Strikers 1341 manager") != 0) return 0; (my->count[0])++; my->count[1] = -30; return 0; } static tenm_object * striker_505_new(int table_index) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = (double) (WINDOW_WIDTH / 2); double y = -59.0; /* sanity check */ if (table_index < 0) { fprintf(stderr, "striker_505_new: table_index is negative (%d)\n", table_index); return NULL; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "striker_505_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(3, x + 51.9615, y - 30.0, x, y + 60.0, x - 51.9615, y - 30.0); if (p[0] == NULL) { fprintf(stderr, "striker_505_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 9); if (count == NULL) { fprintf(stderr, "striker_505_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "striker_505_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] manager index * [3] life mode * [4] life timer * [5] move mode * [6] move timer * [7] bit theta * [8] "was green when killed" flag */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = 0; count[1] = 0; count[2] = table_index; count[3] = 0; count[4] = 0; count[5] = 0; count[6] = 0; count[7] = 0; count[8] = 0; count_d[0] = 0.0; count_d[1] = (34.0 - y) / 30.0; new = tenm_object_new("Striker 505", ATTR_BOSS, ATTR_PLAYER_SHOT, 505, x, y, 9, count, 2, count_d, 1, p, (int (*)(tenm_object *, double)) (&striker_505_move), (int (*)(tenm_object *, tenm_object *)) (&striker_505_hit), (int (*)(tenm_object *, const tenm_object *)) (&striker_505_act), (int (*)(tenm_object *, int)) (&striker_505_draw)); if (new == NULL) { fprintf(stderr, "striker_505_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int striker_505_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "striker_505_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "striker_505_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int striker_505_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "striker_505_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "striker_505_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if (my->count[3] != 1) return 0; deal_damage(my, your, 0); if (striker_505_green(my)) add_chain(my, your); my->count[1] = 2; if (my->hit_point <= 0) { add_score(3000); set_background(1); striker_505_next(my); return 0; } return 0; } static void striker_505_next(tenm_object *my) { int n; /* sanity check */ if (my == NULL) { fprintf(stderr, "striker_505_next: my is NULL\n"); return; } /* set "was green" flag before we change the life mode */ if (striker_505_green(my)) { n = 8; my->count[8] = 1; } else { n = 7; my->count[8] = 0; } tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 3000, n, 6.0, 8)); tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 2, 800, n, 3.5, 8)); my->count[1] = 0; my->count[3] = 2; my->count[4] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; tenm_table_apply(my->count[2], (int (*)(tenm_object *, int)) (&strikers_striker_signal), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy), 0); } static int striker_505_act(tenm_object *my, const tenm_object *player) { int n; double speed; /* sanity check */ if (my == NULL) { fprintf(stderr, "striker_505_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; (my->count[4])++; /* encounter */ if (my->count[3] == 0) { if (my->count[4] == 30) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[4] >= 90) { my->count[3] = 1; my->count[4] = 0; } return 0; } /* dead */ if (my->count[3] == 2) { if ((my->count[4] <= 9) && (my->count[4] % 3 == 0)) { if (striker_505_green(my)) n = 8; else n = 7; tenm_table_add(explosion_new(my->x + ((double) (my->count[4]/3)) * 60.0, my->y, 0.0, 0.0, 1, 200, n, 2.0, 8)); tenm_table_add(explosion_new(my->x - ((double) (my->count[4]/3)) * 60.0, my->y, 0.0, 0.0, 1, 200, n, 2.0, 8)); } if (my->count[4] >= 9) return 1; return 0; } /* self-destruction */ if ((my->count[3] == 1) && (my->count[4] >= 1075)) { set_background(2); clear_chain(); striker_505_next(my); return 0; } /* move */ speed = 6.0; if (my->count[7] == 75) speed = 3.0; if ((my->x + 120.0 > player->x) && (my->x - 120.0 < player->x) && (my->y + 60.0 < player->y)) { my->count[7] += 15; if (my->count[7] > 75) my->count[7] = 75; speed = 3.0; } else { my->count[7] -= 15; if (my->count[7] < 0) my->count[7] = 0; } (my->count[6])++; if (my->count[5] == 0) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; if ((my->count[6] >= 0) && ((my->x + speed * 15.0 < player->x) || (my->x - speed * 15.0 > player->x))) { my->count[5] = 1; my->count[6] = 0; } else if ((my->count[6] >= 0) && ((my->x + speed < player->x) || (my->x - speed > player->x))) { my->count[5] = 1; my->count[6] = 50; } } else if (my->count[5] == 1) { my->count_d[1] = 0.0; if (my->x - speed > player->x) my->count_d[0] = -speed; else if (my->x + speed < player->x) my->count_d[0] = speed; else my->count_d[0] = player->x - my->x; if (my->count[6] >= 60) { my->count[5] = 0; my->count[6] = -60; } } if (my->count[4] <= 95) { my->count[5] = 0; my->count[6] = 0; my->count[7] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if ((my->count[3] != 1) || (my->count[4] > 950)) return 0; /* shoot */ if ((my->count[7] == 0) && (my->count[4] % 19 == 0)) { tenm_table_add(normal_shot_point_new(my->x + 100.0*tenm_cos(my->count[7]), my->y + 100.0*tenm_sin(my->count[7]), 5.5, player->x, player->y, 2)); tenm_table_add(normal_shot_point_new(my->x - 100.0*tenm_cos(my->count[7]), my->y + 100.0*tenm_sin(my->count[7]), 5.5, player->x, player->y, 2)); tenm_table_add(normal_shot_angle_new(my->x + 30.0, my->y, 4.5, 75, 0)); tenm_table_add(normal_shot_angle_new(my->x + 30.0, my->y, 4.5, 90, 0)); tenm_table_add(normal_shot_angle_new(my->x - 30.0, my->y, 4.5, 90, 0)); tenm_table_add(normal_shot_angle_new(my->x - 30.0, my->y, 4.5, 105, 0)); } if ((my->count[7] == 75) && (my->count[4] % 19 == 0)) { tenm_table_add(normal_shot_angle_new(my->x + 100.0*tenm_cos(my->count[7]), my->y + 100.0*tenm_sin(my->count[7]), 4.5, 70, 3)); tenm_table_add(normal_shot_angle_new(my->x + 100.0*tenm_cos(my->count[7]), my->y + 100.0*tenm_sin(my->count[7]), 4.5, 100, 3)); tenm_table_add(normal_shot_angle_new(my->x - 100.0*tenm_cos(my->count[7]), my->y + 100.0*tenm_sin(my->count[7]), 4.5, 110, 3)); tenm_table_add(normal_shot_angle_new(my->x - 100.0*tenm_cos(my->count[7]), my->y + 100.0*tenm_sin(my->count[7]), 4.5, 80, 3)); tenm_table_add(normal_shot_angle_new(my->x, my->y, 5.5, 75, 1)); tenm_table_add(normal_shot_angle_new(my->x, my->y, 5.5, 90, 1)); tenm_table_add(normal_shot_angle_new(my->x, my->y, 5.5, 105, 1)); } return 0; } static int striker_505_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; double c; /* sanity check */ if (my == NULL) { fprintf(stderr, "striker_505_draw: my is NULL\n"); return 0; } /* decoration */ if (priority == 0) { if (striker_505_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(181, 190, 92); else color = tenm_map_color(157, 182, 123); } else { if (my->count[1] >= 1) color = tenm_map_color(200, 164, 92); else color = tenm_map_color(182, 147, 123); } } /* body */ if (priority == 0) { if (striker_505_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 1) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (((my->count[3] == 0) && (my->count[4] >= 45)) || (my->count[3] == 1)) { if (my->count[3] == 0) { if (my->count[4] >= 75) c = 100.0; else c = 100.0 * ((double) (my->count[4] - 45)) / 30.0; } else { c = 100.0; } if (striker_505_draw_bit(my->x + c * tenm_cos(my->count[7]), my->y + c * tenm_sin(my->count[7]), color) != 0) status = 1; if (striker_505_draw_bit(my->x - c * tenm_cos(my->count[7]), my->y + c * tenm_sin(my->count[7]), color) != 0) status = 1; } if (my->count[3] <= 1) { if (tenm_draw_line((int) (my->x + 51.9615), (int) (my->y - 30.0), (int) (my->x), (int) (my->y + 60.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x), (int) (my->y + 60.0), (int) (my->x - 51.9615), (int) (my->y - 30.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 51.9615), (int) (my->y - 30.0), (int) (my->x + 51.9615), (int) (my->y - 30.0), 3, color) != 0) status = 1; } } /* hit point stat */ if ((priority == 0) && (my->count[3] == 1)) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 10, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "striker_505_draw: draw_string failed\n"); status = 1; } } return status; } static int striker_505_draw_bit(double x, double y, tenm_color color) { int status = 0; if (tenm_draw_line((int) (x + 25.9808), (int) (y - 15.0), (int) (x + 8.6603), (int) (y + 15.0), 1, color) != 0) status = 1; if (tenm_draw_line((int) (x + 8.6603), (int) (y + 15.0), (int) (x - 8.6603), (int) (y + 15.0), 1, color) != 0) status = 1; if (tenm_draw_line((int) (x - 8.6603), (int) (y + 15.0), (int) (x - 25.9808), (int) (y - 15.0), 1, color) != 0) status = 1; if (tenm_draw_line((int) (x - 25.9808), (int) (y - 15.0), (int) (x + 25.9808), (int) (y - 15.0), 1, color) != 0) status = 1; return status; } /* return 1 (true) or 0 (false) */ static int striker_505_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if ((my->count[3] == 1) && (my->count[4] > 95) && (my->count[4] < 1045)) return 1; if ((my->count[3] == 2) && (my->count[8] != 0)) return 1; return 0; } static tenm_object * striker_446_new(int table_index) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = (double) (WINDOW_WIDTH / 2); double y = -59.0; /* sanity check */ if (table_index < 0) { fprintf(stderr, "striker_446_new: table_index is negative (%d)\n", table_index); return NULL; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "striker_446_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(3, x + 51.9615, y - 30.0, x, y + 60.0, x - 51.9615, y - 30.0); if (p[0] == NULL) { fprintf(stderr, "striker_446_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 9); if (count == NULL) { fprintf(stderr, "striker_446_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "striker_446_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] manager index * [3] life mode * [4] life timer * [5] move mode * [6] move timer * [7] bit theta * [8] "was green when killed" flag */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = 0; count[1] = 0; count[2] = table_index; count[3] = 0; count[4] = 0; count[5] = 0; count[6] = 0; count[7] = 0; count[8] = 0; count_d[0] = 0.0; count_d[1] = (34.0 - y) / 30.0; new = tenm_object_new("Striker 446", ATTR_BOSS, ATTR_PLAYER_SHOT, 446, x, y, 9, count, 2, count_d, 1, p, (int (*)(tenm_object *, double)) (&striker_446_move), (int (*)(tenm_object *, tenm_object *)) (&striker_446_hit), (int (*)(tenm_object *, const tenm_object *)) (&striker_446_act), (int (*)(tenm_object *, int)) (&striker_446_draw)); if (new == NULL) { fprintf(stderr, "striker_446_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int striker_446_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "striker_446_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "striker_446_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int striker_446_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "striker_446_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "striker_446_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if (my->count[3] != 1) return 0; deal_damage(my, your, 0); if (striker_446_green(my)) add_chain(my, your); my->count[1] = 2; if (my->hit_point <= 0) { add_score(3000); set_background(1); striker_446_next(my); return 0; } return 0; } static void striker_446_next(tenm_object *my) { int n; /* sanity check */ if (my == NULL) { fprintf(stderr, "striker_446_next: my is NULL\n"); return; } /* set "was green" flag before we change the life mode */ if (striker_446_green(my)) { n = 8; my->count[8] = 1; } else { n = 7; my->count[8] = 0; } tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 3000, n, 6.0, 8)); tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 2, 800, n, 3.5, 8)); my->count[1] = 0; my->count[3] = 2; my->count[4] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; tenm_table_apply(my->count[2], (int (*)(tenm_object *, int)) (&strikers_striker_signal), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy), 0); } static int striker_446_act(tenm_object *my, const tenm_object *player) { int n; double speed; int i; /* sanity check */ if (my == NULL) { fprintf(stderr, "striker_446_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; (my->count[4])++; /* encounter */ if (my->count[3] == 0) { if (my->count[4] == 30) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[4] >= 90) { my->count[3] = 1; my->count[4] = 0; } return 0; } /* dead */ if (my->count[3] == 2) { if ((my->count[4] <= 9) && (my->count[4] % 3 == 0)) { if (striker_505_green(my)) n = 8; else n = 7; tenm_table_add(explosion_new(my->x + ((double) (my->count[4]/3)) * 60.0, my->y, 0.0, 0.0, 1, 200, n, 2.0, 8)); tenm_table_add(explosion_new(my->x - ((double) (my->count[4]/3)) * 60.0, my->y, 0.0, 0.0, 1, 200, n, 2.0, 8)); } if (my->count[4] >= 9) return 1; return 0; } /* self-destruction */ if ((my->count[3] == 1) && (my->count[4] >= 1065)) { set_background(2); clear_chain(); striker_446_next(my); return 0; } /* move */ speed = 6.0; if (my->count[7] == 75) speed = 3.0; if ((my->x + 120.0 > player->x) && (my->x - 120.0 < player->x) && (my->y + 60.0 < player->y)) { my->count[7] += 15; if (my->count[7] > 75) my->count[7] = 75; speed = 3.0; } else { my->count[7] -= 15; if (my->count[7] < 0) my->count[7] = 0; } (my->count[6])++; if (my->count[5] == 0) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; if ((my->count[6] >= 0) && ((my->x + speed * 15.0 < player->x) || (my->x - speed * 15.0 > player->x))) { my->count[5] = 1; my->count[6] = 0; } else if ((my->count[6] >= 0) && ((my->x + speed < player->x) || (my->x - speed > player->x))) { my->count[5] = 1; my->count[6] = 50; } } else if (my->count[5] == 1) { my->count_d[1] = 0.0; if (my->x - speed > player->x) my->count_d[0] = -speed; else if (my->x + speed < player->x) my->count_d[0] = speed; else my->count_d[0] = player->x - my->x; if (my->count[6] >= 60) { my->count[5] = 0; my->count[6] = -60; } } if (my->count[4] <= 92) { my->count[5] = 0; my->count[6] = 0; my->count[7] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if ((my->count[3] != 1) || (my->count[4] > 943)) return 0; /* shoot */ if (((my->count[7] == 0) || (my->count[7] == 75)) && (my->count[4] % 23 == 19)) { tenm_table_add(laser_angle_new(my->x + 13.0 * tenm_cos(0), my->y + 13.0 * tenm_sin(0), 5.5, 90, 25.0, 2)); tenm_table_add(laser_angle_new(my->x + 13.0 * tenm_cos(180), my->y + 13.0 * tenm_sin(180), 5.5, 90, 25.0, 2)); } if (((my->count[7] == 0) || (my->count[7] == 75)) && (my->count[4] % 23 == 0)) { for (i = -1; i <= 1; i += 2) { tenm_table_add(laser_angle_new(my->x + 13.0 * tenm_cos(i * 7), my->y + 13.0 * tenm_sin(i * 7), 5.5, 90 + i * 7, 25.0, 2)); tenm_table_add(laser_angle_new(my->x + 13.0 * tenm_cos(180 + i * 7), my->y + 13.0 * tenm_sin(180 + i * 7), 5.5, 90 + i * 7, 25.0, 2)); } } if ((my->count[7] == 0) && (my->count[4] % 23 == 0)) { tenm_table_add(laser_angle_new(my->x + 100.0 * tenm_cos(my->count[7]), my->y + 100.0 * tenm_sin(my->count[7]), 7.5, 90, 50.0, 0)); tenm_table_add(laser_angle_new(my->x - 100.0 * tenm_cos(my->count[7]), my->y + 100.0 * tenm_sin(my->count[7]), 7.5, 90, 50.0, 0)); } if ((my->count[7] == 75) && (my->count[4] % 11 == 0)) { tenm_table_add(normal_shot_angle_new(my->x, my->y + 100.0*tenm_sin(my->count[7]), 7.5, 90, 1)); } return 0; } static int striker_446_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; double c; /* sanity check */ if (my == NULL) { fprintf(stderr, "striker_446_draw: my is NULL\n"); return 0; } /* decoration */ if (priority == 0) { if (striker_446_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(181, 190, 92); else color = tenm_map_color(157, 182, 123); } else { if (my->count[1] >= 1) color = tenm_map_color(200, 164, 92); else color = tenm_map_color(182, 147, 123); } } /* body */ if (priority == 0) { if (striker_446_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 1) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (((my->count[3] == 0) && (my->count[4] >= 45)) || (my->count[3] == 1)) { if (my->count[3] == 0) { if (my->count[4] >= 75) c = 100.0; else c = 100.0 * ((double) (my->count[4] - 45)) / 30.0; } else { c = 100.0; } if (striker_446_draw_bit(my->x + c * tenm_cos(my->count[7]), my->y + c * tenm_sin(my->count[7]), color) != 0) status = 1; if (striker_446_draw_bit(my->x - c * tenm_cos(my->count[7]), my->y + c * tenm_sin(my->count[7]), color) != 0) status = 1; } if (my->count[3] <= 1) { if (tenm_draw_line((int) (my->x + 51.9615), (int) (my->y - 30.0), (int) (my->x), (int) (my->y + 60.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x), (int) (my->y + 60.0), (int) (my->x - 51.9615), (int) (my->y - 30.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 51.9615), (int) (my->y - 30.0), (int) (my->x + 51.9615), (int) (my->y - 30.0), 3, color) != 0) status = 1; } } /* hit point stat */ if ((priority == 0) && (my->count[3] == 1)) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 10, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "striker_446_draw: draw_string failed\n"); status = 1; } } return status; } static int striker_446_draw_bit(double x, double y, tenm_color color) { int status = 0; if (tenm_draw_line((int) (x + 8.6603), (int) (y - 15.0), (int) (x + 8.6603), (int) (y + 15.0), 1, color) != 0) status = 1; if (tenm_draw_line((int) (x + 8.6603), (int) (y + 15.0), (int) (x - 8.6603), (int) (y + 15.0), 1, color) != 0) status = 1; if (tenm_draw_line((int) (x - 8.6603), (int) (y + 15.0), (int) (x - 8.6603), (int) (y - 15.0), 1, color) != 0) status = 1; if (tenm_draw_line((int) (x - 25.9808), (int) (y - 15.0), (int) (x + 25.9808), (int) (y - 15.0), 1, color) != 0) status = 1; return status; } /* return 1 (true) or 0 (false) */ static int striker_446_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if ((my->count[3] == 1) && (my->count[4] > 92) && (my->count[4] < 1035)) return 1; if ((my->count[3] == 2) && (my->count[8] != 0)) return 1; return 0; } static tenm_object * striker_1341_new(int table_index) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = (double) (WINDOW_WIDTH / 2); double y = -59.0; /* sanity check */ if (table_index < 0) { fprintf(stderr, "striker_1341_new: table_index is negative (%d)\n", table_index); return NULL; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "striker_1341_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(3, x + 51.9615, y - 30.0, x, y + 60.0, x - 51.9615, y - 30.0); if (p[0] == NULL) { fprintf(stderr, "striker_1341_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 9); if (count == NULL) { fprintf(stderr, "striker_1341_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 4); if (count_d == NULL) { fprintf(stderr, "striker_1341_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] manager index * [3] life mode * [4] life timer * [5] move mode * [6] move timer * [7] bit theta * [8] "was green when killed" flag */ /* list of count_d * [0] speed x * [1] speed y * [2] aim x * [3] aim y */ count[0] = 0; count[1] = 0; count[2] = table_index; count[3] = 0; count[4] = 0; count[5] = 0; count[6] = 0; count[7] = 0; count[8] = 0; count_d[0] = 0.0; count_d[1] = (34.0 - y) / 30.0; count_d[2] = 0.0; count_d[3] = 25.0; /* 1341 HP is too many for an [easy] boss */ new = tenm_object_new("Striker 1341", ATTR_BOSS, ATTR_PLAYER_SHOT, 712, x, y, 9, count, 4, count_d, 1, p, (int (*)(tenm_object *, double)) (&striker_1341_move), (int (*)(tenm_object *, tenm_object *)) (&striker_1341_hit), (int (*)(tenm_object *, const tenm_object *)) (&striker_1341_act), (int (*)(tenm_object *, int)) (&striker_1341_draw)); if (new == NULL) { fprintf(stderr, "striker_1341_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int striker_1341_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "striker_1341_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "striker_1341_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int striker_1341_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "striker_1341_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "striker_1341_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if (my->count[3] != 1) return 0; deal_damage(my, your, 0); if (striker_1341_green(my)) add_chain(my, your); my->count[1] = 2; if (my->hit_point <= 0) { add_score(9000); set_background(1); striker_1341_next(my); return 0; } return 0; } static void striker_1341_next(tenm_object *my) { int n; /* sanity check */ if (my == NULL) { fprintf(stderr, "striker_1341_next: my is NULL\n"); return; } /* set "was green" flag before we change the life mode */ if (striker_1341_green(my)) { n = 8; my->count[8] = 1; } else { n = 7; my->count[8] = 0; } tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 3000, n, 6.0, 8)); tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 2, 800, n, 3.5, 8)); my->count[1] = 0; my->count[3] = 2; my->count[4] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; tenm_table_apply(my->count[2], (int (*)(tenm_object *, int)) (&strikers_striker_signal), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy), 0); } static int striker_1341_act(tenm_object *my, const tenm_object *player) { int n; double speed; int theta; double result[2]; double v[2]; int i; double x; double y; /* sanity check */ if (my == NULL) { fprintf(stderr, "striker_1341_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; (my->count[4])++; /* encounter */ if (my->count[3] == 0) { if (my->count[4] == 30) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[4] >= 90) { my->count[3] = 1; my->count[4] = 0; } return 0; } /* dead */ if (my->count[3] == 2) { if ((my->count[4] <= 9) && (my->count[4] % 3 == 0)) { if (striker_1341_green(my)) n = 8; else n = 7; tenm_table_add(explosion_new(my->x + ((double) (my->count[4]/3)) * 60.0, my->y, 0.0, 0.0, 1, 200, n, 2.0, 8)); tenm_table_add(explosion_new(my->x - ((double) (my->count[4]/3)) * 60.0, my->y, 0.0, 0.0, 1, 200, n, 2.0, 8)); } if (my->count[4] >= 9) return 1; return 0; } /* self-destruction */ if ((my->count[3] == 1) && (my->count[4] >= 1377)) { set_background(2); clear_chain(); striker_1341_next(my); return 0; } /* move */ speed = 6.0; if (my->count[7] == 75) speed = 3.0; if ((my->x + 120.0 > player->x) && (my->x - 120.0 < player->x) && (my->y + 60.0 < player->y)) { my->count[7] += 15; if (my->count[7] > 75) my->count[7] = 75; speed = 3.0; } else { my->count[7] -= 15; if (my->count[7] < 0) my->count[7] = 0; } theta = 0; (my->count[6])++; if (my->count[5] == 0) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; if ((my->count[6] >= 0) && ((my->x + speed * 15.0 < player->x) || (my->x - speed * 15.0 > player->x))) { my->count[5] = 1; my->count[6] = 0; } else if ((my->count[6] >= 0) && ((my->x + speed < player->x) || (my->x - speed > player->x))) { my->count[5] = 1; my->count[6] = 50; } } else if (my->count[5] == 1) { if (my->x > player->x) theta = 1; else theta = -1; my->count_d[1] = 0.0; if (my->x - speed > player->x) my->count_d[0] = -speed; else if (my->x + speed < player->x) my->count_d[0] = speed; else my->count_d[0] = player->x - my->x; if (my->count[6] >= 60) { my->count[5] = 0; my->count[6] = -60; } } if (my->count[4] <= 87) { my->count[5] = 0; my->count[6] = 0; my->count[7] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if ((my->count[3] != 1) || (my->count[4] > 1247)) return 0; /* aim */ if (speed > 5.9) { v[0] = my->count_d[2]; v[1] = my->count_d[3]; result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, theta); my->count_d[2] = result[0]; my->count_d[3] = result[1]; if (my->count_d[3] < 25.0 * tenm_cos(45)) { if (my->count_d[2] > 0.0) { my->count_d[2] = 25.0 * tenm_cos(45); my->count_d[3] = 25.0 * tenm_sin(45); } else { my->count_d[2] = 25.0 * tenm_cos(135); my->count_d[3] = 25.0 * tenm_sin(135); } } } /* shoot */ if ((my->count[7] == 0) && (my->count[4] % 58 == 0)) { for (i = 0; i < 6; i ++) { if (i == 1) continue; x = my->x + 100.0 * tenm_cos(my->count[7]) * ((double) i); y = my->y + 100.0 * tenm_sin(my->count[7]); tenm_table_add(laser_angle_new(my->x + 100.0 * tenm_cos(my->count[7]), my->y + 100.0 * tenm_sin(my->count[7]), 3.5, 101 - 11 * i, 25.0, 5)); tenm_table_add(laser_angle_new(my->x - 100.0 * tenm_cos(my->count[7]), my->y + 100.0 * tenm_sin(my->count[7]), 3.5, 79 + 11 * i, 25.0, 5)); } } if ((my->count[7] == 0) && (my->count[4] % 58 == 29)) { for (i = -2; i <= 2; i ++) { tenm_table_add(laser_angle_new(my->x, my->y, 3.5, 90 + 9 * i, 25.0, 4)); } } if ((my->count[7] == 75) && (my->count[4] % 23 == 0)) { for (i = -1; i <= 1; i ++) { if (i == 0) { if (my->count[4] % 46 == 0) continue; } else { if (my->count[4] % 46 == 23) continue; } tenm_table_add(laser_angle_new(my->x + 40.0 * ((double) i), my->y - 30.0, 6.5, 90, 25.0, 2)); } tenm_table_add(laser_point_new(my->x + 100.0 * tenm_cos(my->count[7]), my->y + 100.0 * tenm_sin(my->count[7]), 3.5, player->x, player->y, 25.0, 1)); tenm_table_add(laser_point_new(my->x - 100.0 * tenm_cos(my->count[7]), my->y + 100.0 * tenm_sin(my->count[7]), 3.5, player->x, player->y, 25.0, 1)); } if (((my->count[7] == 0) && (my->count[4] % 13 == 0)) || ((my->count[7] == 75) && (my->count[4] % 19 == 0))) { if ((my->count[5] == 0) && (speed > 5.9)) { my->count_d[2] = 0.0; my->count_d[3] = 25.0; } for (i = -1; i <= 1; i += 2) { x = my->x + 100.0 * tenm_cos(my->count[7]) * ((double) i); y = my->y + 100.0 * tenm_sin(my->count[7]); tenm_table_add(laser_point_new(x, y, 4.5, x + my->count_d[2], y + my->count_d[3], 25.0, 3)); } } return 0; } static int striker_1341_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; double c; /* sanity check */ if (my == NULL) { fprintf(stderr, "striker_1341_draw: my is NULL\n"); return 0; } /* decoration */ if (priority == 0) { if (striker_1341_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(181, 190, 92); else color = tenm_map_color(157, 182, 123); } else { if (my->count[1] >= 1) color = tenm_map_color(200, 164, 92); else color = tenm_map_color(182, 147, 123); } } /* body */ if (priority == 0) { if (striker_1341_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 1) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (((my->count[3] == 0) && (my->count[4] >= 45)) || (my->count[3] == 1)) { if (my->count[3] == 0) { if (my->count[4] >= 75) c = 100.0; else c = 100.0 * ((double) (my->count[4] - 45)) / 30.0; } else { c = 100.0; } if (striker_1341_draw_bit(my->x + c * tenm_cos(my->count[7]), my->y + c * tenm_sin(my->count[7]), color) != 0) status = 1; if (striker_1341_draw_bit(my->x - c * tenm_cos(my->count[7]), my->y + c * tenm_sin(my->count[7]), color) != 0) status = 1; } if (my->count[3] <= 1) { if (tenm_draw_line((int) (my->x + 51.9615), (int) (my->y - 30.0), (int) (my->x), (int) (my->y + 60.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x), (int) (my->y + 60.0), (int) (my->x - 51.9615), (int) (my->y - 30.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 51.9615), (int) (my->y - 30.0), (int) (my->x + 51.9615), (int) (my->y - 30.0), 3, color) != 0) status = 1; } } /* hit point stat */ if ((priority == 0) && (my->count[3] == 1)) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 10, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "striker_1341_draw: draw_string failed\n"); status = 1; } } return status; } static int striker_1341_draw_bit(double x, double y, tenm_color color) { int status = 0; if (tenm_draw_line((int) (x + 8.6603), (int) (y - 15.0), (int) (x + 25.9808), (int) (y + 15.0), 1, color) != 0) status = 1; if (tenm_draw_line((int) (x + 25.9808), (int) (y + 15.0), (int) (x - 25.9808), (int) (y + 15.0), 1, color) != 0) status = 1; if (tenm_draw_line((int) (x - 25.9808), (int) (y + 15.0), (int) (x - 8.6603), (int) (y - 15.0), 1, color) != 0) status = 1; if (tenm_draw_line((int) (x - 8.6603), (int) (y - 15.0), (int) (x + 8.6603), (int) (y - 15.0), 1, color) != 0) status = 1; return status; } /* return 1 (true) or 0 (false) */ static int striker_1341_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if ((my->count[3] == 1) && (my->count[4] > 87) && (my->count[4] < 1347)) return 1; if ((my->count[3] == 2) && (my->count[8] != 0)) return 1; return 0; } dangen-0.5/spqr/strikers.h0000644000175000017500000000033610276702741016432 0ustar00ooharaoohara00000000000000/* $Id: strikers.h,v 1.1 2004/07/08 13:25:23 oohara Exp $ */ #ifndef __DANGEN_STRIKERS_H__ #define __DANGEN_STRIKERS_H__ #include "tenm_object.h" tenm_object *strikers_new(void); #endif /* not __DANGEN_STRIKERS_H__ */ dangen-0.5/spqr/tadashi.c0000644000175000017500000007262010276702741016201 0ustar00ooharaoohara00000000000000/* $Id: tadashi.c,v 1.132 2005/01/01 17:03:47 oohara Exp $ */ /* [normal] Tadashi */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "stage-clear.h" #include "score.h" #include "tadashi.h" #define NEAR_ZERO 0.0001 static int tadashi_move(tenm_object *my, double turn_per_frame); static int tadashi_hit(tenm_object *my, tenm_object *your); static void tadashi_explode(tenm_object *my); static int tadashi_act(tenm_object *my, const tenm_object *player); static int tadashi_draw(tenm_object *my, int priority); static int tadashi_green(const tenm_object *my); static tenm_object *tadashi_square_new(double x, int what); static int tadashi_square_act(tenm_object *my, const tenm_object *player); static int tadashi_square_draw(tenm_object *my, int priority); tenm_object * tadashi_new(void) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = (double) (WINDOW_WIDTH / 2); double y = -160.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "tadashi_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_circle_new(x, y, 30.0); if (p[0] == NULL) { fprintf(stderr, "tadashi_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 9); if (count == NULL) { fprintf(stderr, "tadashi_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 4); if (count_d == NULL) { fprintf(stderr, "tadashi_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] life mode * [3] shoot timer * [4] move timer * [5] main attack base * [6] main attack direction * [7] decoration management * [8] "was green when killed" flag */ /* list of count_d * [0] speed x * [1] speed y * [2] main attack x * [3] main attack y */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 0; count[4] = 0; count[5] = 0; count[6] = 1; count[7] = 45; count[8] = 0; count_d[0] = 0.0; count_d[1] = (((double) (WINDOW_HEIGHT * 2 / 5)) - y) / 60.0; count_d[2] = 0.0; count_d[3] = 0.0; new = tenm_object_new("Tadashi", ATTR_BOSS, ATTR_PLAYER_SHOT, 750, x, y, 9, count, 4, count_d, 1, p, (int (*)(tenm_object *, double)) (&tadashi_move), (int (*)(tenm_object *, tenm_object *)) (&tadashi_hit), (int (*)(tenm_object *, const tenm_object *)) (&tadashi_act), (int (*)(tenm_object *, int)) (&tadashi_draw)); if (new == NULL) { fprintf(stderr, "tadashi_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int tadashi_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "tadashi_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "tadashi_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int tadashi_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "tadashi_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "tadashi_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if (my->count[2] != 1) return 0; deal_damage(my, your, 0); if (tadashi_green(my)) add_chain(my, your); my->count[1] = 2; if (my->hit_point <= 0) { add_score(30000); set_background(1); tadashi_explode(my); return 0; } return 0; } static void tadashi_explode(tenm_object *my) { int n; /* sanity check */ if (my == NULL) return; tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy), 0); /* set "was green" flag before we change the life mode */ if (tadashi_green(my)) { n = 8; my->count[8] = 1; } else { n = 7; my->count[8] = 0; } tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 5000, n, 10.0, 6)); tenm_table_add(fragment_new(my->x, my->y + 80.0, 0.0, 0.0, 50.0, 12, n, 4.0, 0.0, 20)); my->count[2] = 2; my->count[3] = 0; my->count[1] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.5; /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ tenm_mass_delete(my->mass); my->mass = NULL; } static int tadashi_act(tenm_object *my, const tenm_object *player) { double dx; double dy; double length; int theta; double speed; int i; int t; int phi; int what; /* sanity check */ if (my == NULL) { fprintf(stderr, "tadashi_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; /* decoration management */ if (my->count_d[1] > 2.0) { my->count[7] = 45; } else { (my->count[7])--; } if (my->count[7] > 45) my->count[7] = 45; if (my->count[7] < 10) my->count[7] = 10; (my->count[3])++; /* encounter */ if (my->count[2] == 0) { if (my->count[3] == 60) { my->count_d[0] = 0.0; my->count_d[1] = (((double) (WINDOW_HEIGHT * 3 / 5)) - my->y) / 60.0; } if (my->count[3] >= 120) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; my->count[2] = 1; my->count[3] = -30; } return 0; } /* dead */ if (my->count[2] == 2) { if (tadashi_green(my)) i = 8; else i = 7; if ((my->count[3] >= 30) && (my->count[3] <= 75) && (my->count[3] % 15 == 0)) { theta = rand() % 360; tenm_table_add(explosion_new(my->x + 30.0 * tenm_cos(theta), my->y + 30.0 * tenm_sin(theta), 0.0, 0.0, 2, 300, i, 5.0, 8)); } if (my->count[3] > 120) { tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 3000, i, 10.0, 8)); tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 2, 800, i, 6.0, 8)); tenm_table_add(stage_clear_new(100)); return 1; } return 0; } /* self-destruction */ if ((my->count[2] == 1) && (my->count[3] >= 4050)) { set_background(2); clear_chain(); tadashi_explode(my); return 0; } /* spped change */ if (my->count[4] < 0) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; (my->count[4])++; } if ((my->count[4] == 0) && ((my->x - 100.0 > player->x) || (my->x + 100.0 < player->x))) my->count[4] = 60; if (my->count[4] > 0) { if (my->x - 6.0 > player->x) my->count_d[0] = -6.0; else if (my->x + 6.0 < player->x) my->count_d[0] = 6.0; else my->count_d[0] = player->x - my->x; (my->count[4])--; if (my->count[4] <= 0) my->count[4] = -60; } if (my->count[2] != 1) return 0; /* shoot */ if (my->count[3] <= 980) t = my->count[3] - 630; else if (my->count[3] <= 1960) t = my->count[3] - 1610; else if (my->count[3] <= 2940) t = my->count[3] - 2590; else t = my->count[3] - 3570; if ((my->count[3] >= 0) && (my->count[3] < 3920) && ((t < 0) || (t >= 350)) && (my->count[3] % 100 == 60)) { if (my->count[3] >= 630) what = 1; else what = 0; tenm_table_add(tadashi_square_new(my->x, what)); } if ((my->count[3] >= 0) && (my->count[3] < 3920) && ((t < 0) || (t >= 350)) && (my->count[3] % 10 == 0) && (my->count[3] % 70 <= 20)) { tenm_table_add(normal_shot_point_new(my->x, my->y, 5.0, player->x + 100.0, player->y - 50.0, 3)); tenm_table_add(normal_shot_point_new(my->x, my->y, 5.0, player->x - 100.0, player->y - 50.0, 3)); } if ((my->count[3] >= 0) && (my->count[3] < 3920) && ((t < 0) || (t >= 350)) && (my->count[3] % 70 == 40)) { tenm_table_add(normal_shot_point_new(my->x, my->y, 5.0, player->x, player->y, 3)); } /* main attack */ if (t == 0) { my->count[5] = rand() % 360; if (rand() % 2 == 0) my->count[6] = 1; else my->count[6] = -1; } if ((t >= 50) && (t < 300)) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; my->count[4] = -60; } if ((t >= 0) && (t <= 100)) { my->count_d[2] = player->x; my->count_d[3] = player->y; } if ((t >= 120) && (t < 300) && (t % 3 == 0)) { dx = my->count_d[2] - my->x; dy = my->count_d[3] - my->y; length = tenm_sqrt((int) (dx * dx + dy * dy)); if (length < NEAR_ZERO) length = 1.0; if (length < 100.0) theta = 75; else if (length > 400.0) theta = 15; else theta = 75 - ((int) ((length - 100.0) / 5.0)); if (theta < 0) theta = 1; if (theta >= 90) theta = 89; for (i = 0; i < 2; i++) { speed = 6.0 + ((double) i) * 1.0; phi = (my->count[5] + t * 7 + i * 7) * my->count[6]; tenm_table_add(normal_shot_new(my->x, my->y, dx * speed / length - (dy * speed / length) * (tenm_sin(theta) / tenm_cos(theta)) * tenm_sin(phi), dy * speed / length + (dx * speed / length) * (tenm_sin(theta) / tenm_cos(theta)) * tenm_sin(phi), 4, -2, 0)); } } return 0; } static int tadashi_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; double dx; double dy; double length; double v[2]; double result[2]; int theta; int i; int t; /* sanity check */ if (my == NULL) { fprintf(stderr, "tadashi_draw: my is NULL\n"); return 0; } /* decoration */ if ((priority == 0) && (my->count[2] <= 1)) { if (tadashi_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(181, 190, 92); else color = tenm_map_color(157, 182, 123); } else { if (my->count[1] >= 1) color = tenm_map_color(200, 164, 92); else color = tenm_map_color(182, 147, 123); } if (my->count_d[0] < -0.5) theta = 85; else if (my->count_d[0] > 0.5) theta = 95; else theta = 90; if (tenm_draw_line((int) (my->x + 50.0), (int) (my->y + 40.0), (int) (my->x + 50.0 + 120.0 * tenm_cos(theta - my->count[7])), (int) (my->y + 40.0 + 120.0 * tenm_sin(theta - my->count[7])), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 50.0), (int) (my->y + 40.0), (int) (my->x - 50.0 + 120.0 * tenm_cos(theta + my->count[7])), (int) (my->y + 40.0 + 120.0 * tenm_sin(theta + my->count[7])), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 5.0), (int) (my->y + 35.0), (int) (my->x + 5.0 + 30.0 * tenm_cos(85)), (int) (my->y + 35.0 + 30.0 * tenm_sin(85)), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 5.0), (int) (my->y + 35.0), (int) (my->x - 5.0 + 30.0 * tenm_cos(95)), (int) (my->y + 35.0 + 30.0 * tenm_sin(95)), 1, color) != 0) status = 1; } /* main attack */ if (my->count[3] <= 980) t = my->count[3] - 630; else if (my->count[3] <= 1960) t = my->count[3] - 1610; else if (my->count[3] <= 2940) t = my->count[3] - 2590; else t = my->count[3] - 3570; if ((priority == 0) && (my->count[2] == 1) && (t >= 0) && (t < 300)) { dx = my->count_d[2] - my->x; dy = my->count_d[3] - my->y; length = tenm_sqrt((int) (dx * dx + dy * dy)); if (length < NEAR_ZERO) length = 1.0; if (t < 100) color = tenm_map_color(158, 158, 158); else color = tenm_map_color(118, 99, 158); if (tenm_draw_line((int) (my->x), (int) (my->y), (int) (my->x + dx * 800.0 / length), (int) (my->y + dy * 800.0 / length), 1, color) != 0) status = 1; if (length < 100.0) theta = 75; else if (length > 400.0) theta = 15; else theta = 75 - ((int) ((length - 100.0) / 5.0)); if (theta < 0) theta = 1; if (theta >= 90) theta = 89; for (i = -1; i <= 1; i += 2) { v[0] = dx; v[1] = dy; result[0] = dx; result[1] = dy; vector_rotate(result, v, theta * i); if (tenm_draw_line((int) (my->x), (int) (my->y), (int) (my->x + result[0] * 800.0 / length), (int) (my->y + result[1] * 800.0 / length), 1, color) != 0) status = 1; } } /* body */ /* dead enemy has low priority */ if (((my->count[2] <= 1) && (priority == 0)) || ((my->count[2] > 1) && (priority == -1))) { if (tadashi_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 1) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (tenm_draw_circle((int) (my->x), (int) (my->y), 30, 3, color) != 0) status = 1; } /* hit point stat */ if ((priority == 0) && (my->count[2] == 1)) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 10, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "tadashi_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int tadashi_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if ((my->count[2] == 1) && (my->count[3] > 980) && (my->count[3] < 4020)) return 1; if ((my->count[2] == 2) && (my->count[8] != 0)) return 1; return 0; } static tenm_object *tadashi_square_new(double x, int what) { tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double y = (double) (WINDOW_HEIGHT * 3 / 4); count = (int *) malloc(sizeof(int) * 7); if (count == NULL) { fprintf(stderr, "tadashi_square_new: malloc(count) failed\n"); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "tadashi_square_new: malloc(count_d) failed\n"); free(count); return NULL; } /* list of count * [0] color (for delete_enemy_shot) * [1] move mode * [2] move timer * [3] rotate theta * [4] rotate direction * [5] shoot direction * [6] what */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = 6; count[1] = 0; count[2] = 0; count[3] = rand() % 360; if (rand() % 2 == 0) count[4] = 1; else count[4] = -1; count[5] = 60 + rand() % 61; count[6] = what; count_d[0] = 0.0; count_d[1] = 0.0; /* ATTR_ENEMY_SHOT is only to clear it when the player is killed */ new = tenm_object_new("Tadashi square", ATTR_ENEMY_SHOT, 0, 1, x, y, 6, count, 2, count_d, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&tadashi_square_act), (int (*)(tenm_object *, int)) (&tadashi_square_draw)); if (new == NULL) { fprintf(stderr, "tadashi_square_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); return NULL; } return new; } static int tadashi_square_act(tenm_object *my, const tenm_object *player) { double x; double y; double dx_a; double dy_a; double dx_b; double dy_b; int i; int j; int theta; int phi; double length; double c; double s; double speed; int n; /* sanity check */ if (my == NULL) { fprintf(stderr, "tadashi_square_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* no need to interpolate */ my->x += my->count_d[0]; my->y += my->count_d[1]; (my->count[2])++; if (my->count[1] == 0) { if (my->count[2] >= 60) { my->count[1] = 1; my->count[2] = 0; my->count_d[0] = 0.0; my->count_d[1] = -3.0; } } else if (my->count[1] == 1) { if (my->count[2] == 80) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[2] >= 140) { length = 175.0; phi = 60; theta = 180 + 720 * my->count[4]; theta += my->count[3]; x = length * tenm_cos(theta); y = length * tenm_sin(theta) * tenm_cos(phi); dx_a = length * tenm_cos(theta + 90) - x; dy_a = length * tenm_sin(theta + 90) * tenm_cos(phi) - y; dx_b = length * tenm_cos(theta - 90) - x; dy_b = length * tenm_sin(theta - 90) * tenm_cos(phi) - y; for (i = 0; i <= 3; i++) for (j = 0; j <= 3; j++) { if (((i == 0) || (i == 3)) && ((j == 0) || (j == 3))) continue; c = ((double) i) / 3.0; s = ((double) j) / 3.0; if ((i + j) % 2 == 0) { speed = 4.0; n = 0; } else { speed = 6.0; n = 1; } if (my->y < player->y) tenm_table_add(laser_angle_new(my->x + x + dx_a * s + dx_b * c - 15.0 * tenm_cos(my->count[5]), my->y + y + dy_a * s + dy_b * c - 15.0 * tenm_sin(my->count[5]), speed, my->count[5], 30.0, n)); else tenm_table_add(laser_angle_new(my->x + x + dx_a * s + dx_b * c + 15.0 * tenm_cos(my->count[5]), my->y + y + dy_a * s + dy_b * c + 15.0 * tenm_sin(my->count[5]), speed, 180 + my->count[5], 30.0, n)); } if (my->count[6] == 0) return 1; my->count[1] = 2; my->count[2] = 0; my->count_d[0] = 0.0; my->count_d[1] = ((double) (WINDOW_HEIGHT / 2) - my->y) / 90.0; } } else { if (my->count[2] == 90) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[2] >= 120) { length = 400.0; phi = 0; theta = 180 - 90 * my->count[4]; theta += my->count[3]; x = length * tenm_cos(theta); y = length * tenm_sin(theta) * tenm_cos(phi); dx_a = length * tenm_cos(theta + 90) - x; dy_a = length * tenm_sin(theta + 90) * tenm_cos(phi) - y; dx_b = length * tenm_cos(theta - 90) - x; dy_b = length * tenm_sin(theta - 90) * tenm_cos(phi) - y; for (i = 0; i < 5; i++) for (j = 0; j < 5; j++) { if ((i + j) % 2 == 0) continue; c = ((double) i) / 5.0; s = ((double) j) / 5.0; tenm_table_add(laser_point_new(my->x + x + dx_a * s + dx_b * c, my->y + y + dy_a * s + dy_b * c, 2.0, my->x + x + dx_a * s + dx_b * c + dx_a * 50.0 / 400.0, my->y + y + dy_a * s + dy_b * c + dy_a * 50.0 / 400.0, 50.0, 0)); tenm_table_add(laser_point_new(my->x + x + dx_a * s + dx_b * c, my->y + y + dy_a * s + dy_b * c, 3.0, my->x + x + dx_a * s + dx_b * c + dx_b * 50.0 / 400.0, my->y + y + dy_a * s + dy_b * c + dy_b * 50.0 / 400.0, 50.0, 1)); } } if (my->count[2] >= 120) { return 1; } } return 0; } static int tadashi_square_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; double x; double y; double dx_a; double dy_a; double dx_b; double dy_b; int i; int j; int theta; int phi; double length; double c; double s; /* sanity check */ if (my == NULL) { fprintf(stderr, "tadashi_square_draw: my is NULL\n"); return 0; } /* return if it is not my turn */ if (priority != 0) return 0; if (my->count[1] == 0) { length = 50.0; phi = 60; theta = my->count[2] * 3 * my->count[4]; } else if (my->count[1] == 1) { if (my->count[2] < 80) { length = 55.0 + ((double) (my->count[2])) * 1.5; phi = 60; theta = 180 + my->count[2] * 9 * my->count[4]; } else { length = 175.0; phi = 60; theta = 180 + 720 * my->count[4]; } } else { if (my->count[2] < 90) { length = 175.0 + ((double) (my->count[2])) * 2.5; if (my->count[2] < 60) phi = 60 - my->count[2]; else phi = 0; theta = 180 + 720 * my->count[4] - my->count[2] * 9 * my->count[4]; } else { length = 400.0; phi = 0; theta = 180 - 90 * my->count[4]; } } theta += my->count[3]; x = length * tenm_cos(theta); y = length * tenm_sin(theta) * tenm_cos(phi); dx_a = length * tenm_cos(theta + 90) - x; dy_a = length * tenm_sin(theta + 90) * tenm_cos(phi) - y; dx_b = length * tenm_cos(theta - 90) - x; dy_b = length * tenm_sin(theta - 90) * tenm_cos(phi) - y; if ((my->count[1] == 2) && (my->count[2] >= 100)) color = tenm_map_color(206, 201, 175); else color = tenm_map_color(158, 158, 158); if (tenm_draw_line((int) (my->x + x), (int) (my->y + y), (int) (my->x + x + dx_a), (int) (my->y + y + dy_a), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + x + dx_b), (int) (my->y + y + dy_b), (int) (my->x + x + dx_a + dx_b), (int) (my->y + y + dy_a + dy_b), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + x), (int) (my->y + y), (int) (my->x + x + dx_b), (int) (my->y + y + dy_b), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + x + dx_a), (int) (my->y + y + dy_a), (int) (my->x + x + dx_a + dx_b), (int) (my->y + y + dy_a + dy_b), 1, color) != 0) status = 1; if ((my->count[1] == 1) && (my->count[2] > 80)) { color = tenm_map_color(158, 158, 158); if (my->count[2] > 110) s = 1.0; else s = ((double) (my->count[2] - 80)) / 30.0; c = 1.0 / 3.0; if (tenm_draw_line((int) (my->x + x + dx_b * c), (int) (my->y + y + dy_b * c), (int) (my->x + x + dx_a * s + dx_b * c), (int) (my->y + y + dy_a * s + dy_b * c), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + x + dx_a + dx_b * (1.0 - c)), (int) (my->y + y + dy_a + dy_b * (1.0 - c)), (int) (my->x + x + dx_a * (1.0 - s) + dx_b * (1.0 - c)), (int) (my->y + y + dy_a * (1.0 - s) + dy_b * (1.0 - c)), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + x + dx_a * c), (int) (my->y + y + dy_a * c), (int) (my->x + x + dx_b * s + dx_a * c), (int) (my->y + y + dy_b * s + dy_a * c), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + x + dx_b + dx_a * (1.0 - c)), (int) (my->y + y + dy_b + dy_a * (1.0 - c)), (int) (my->x + x + dx_b * (1.0 - s) + dx_a * (1.0 - c)), (int) (my->y + y + dy_b * (1.0 - s) + dy_a * (1.0 - c)), 1, color) != 0) status = 1; } if ((my->count[1] == 1) && (my->count[2] > 110)) { for (i = 0; i <= 3; i++) for (j = 0; j <= 3; j++) { if (((i == 0) || (i == 3)) && ((j == 0) || (j == 3))) continue; c = ((double) i) / 3.0; s = ((double) j) / 3.0; if ((i + j) % 2 == 0) color = tenm_map_color(99, 158, 114); else color = tenm_map_color(99, 158, 138); if (tenm_draw_line((int) (my->x + x + dx_a * s + dx_b * c - 15.0 * tenm_cos(my->count[5])), (int) (my->y + y + dy_a * s + dy_b * c - 15.0 * tenm_sin(my->count[5])), (int) (my->x + x + dx_a * s + dx_b * c + 15.0 * tenm_cos(my->count[5])), (int) (my->y + y + dy_a * s + dy_b * c + 15.0 * tenm_sin(my->count[5])), 1, color) != 0) status = 1; } } if ((my->count[1] == 2) && (my->count[2] < 100)) { color = tenm_map_color(206, 201, 175); for (i = 0; i < 4; i++) { if (my->count[2] >= 90) { c = ((double) (i + 1)) / 5.0; } else { c = ((double) (i + 1)) / 5.0; if (i < 2) s = 1.0 / 3.0; else s = 2.0 / 3.0; c = c * (double) (my->count[2]) + s * (double) (90 - my->count[2]); c /= 90.0; } if (tenm_draw_line((int) (my->x + x + dx_b * c), (int) (my->y + y + dy_b * c), (int) (my->x + x + dx_a + dx_b * c), (int) (my->y + y + dy_a + dy_b * c), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + x + dx_a * c), (int) (my->y + y + dy_a * c), (int) (my->x + x + dx_b + dx_a * c), (int) (my->y + y + dy_b + dy_a * c), 1, color) != 0) status = 1; } } if ((my->count[1] == 2) && (my->count[2] > 90)) { for (i = 0; i < 5; i++) for (j = 0; j < 5; j++) { if ((i + j) % 2 == 0) continue; c = ((double) i) / 5.0; s = ((double) j) / 5.0; color = tenm_map_color(99, 158, 114); if (tenm_draw_line((int) (my->x + x + dx_a * s + dx_b * c), (int) (my->y + y + dy_a * s + dy_b * c), (int) (my->x + x + dx_a * s + dx_b * c + dx_a * 50.0 / (400.0 * tenm_sqrt(2))), (int) (my->y + y + dy_a * s + dy_b * c + dy_a * 50.0 / (400.0 * tenm_sqrt(2))), 1, color) != 0) status = 1; color = tenm_map_color(99, 158, 138); if (tenm_draw_line((int) (my->x + x + dx_a * s + dx_b * c), (int) (my->y + y + dy_a * s + dy_b * c), (int) (my->x + x + dx_a * s + dx_b * c + dx_b * 50.0 / (400.0 * tenm_sqrt(2))), (int) (my->y + y + dy_a * s + dy_b * c + dy_b * 50.0 / (400.0 * tenm_sqrt(2))), 1, color) != 0) status = 1; } } return status; } dangen-0.5/spqr/tadashi.h0000644000175000017500000000033110276702741016174 0ustar00ooharaoohara00000000000000/* $Id: tadashi.h,v 1.1 2004/05/06 13:02:13 oohara Exp $ */ #ifndef __DANGEN_TADASHI_H__ #define __DANGEN_TADASHI_H__ #include "tenm_object.h" tenm_object *tadashi_new(void); #endif /* not __DANGEN_TADASHI_H__ */ dangen-0.5/spqr/tenmado.c0000644000175000017500000003733611625011214016203 0ustar00ooharaoohara00000000000000/* $Id: tenmado.c,v 1.61 2011/08/23 20:50:20 oohara Exp $ */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "score.h" #include "tenmado.h" static int tenmado_move(tenm_object *my, double turn_per_frame); static int tenmado_hit(tenm_object *my, tenm_object *your); static int tenmado_signal(tenm_object *my, int n); static int tenmado_act(tenm_object *my, const tenm_object *player); static int tenmado_draw(tenm_object *my, int priority); static int tenmado_green(const tenm_object *my); static tenm_object *tenmado_shot_new(double x, double y, int color); static int tenmado_shot_move(tenm_object *my, double turn_per_frame); static int tenmado_shot_hit(tenm_object *my, tenm_object *your); static int tenmado_shot_act(tenm_object *my, const tenm_object *player); static int tenmado_shot_draw(tenm_object *my, int priority); tenm_object * tenmado_new(double x, double y, int n, double dx, int t, int table_index, int t_shoot) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; int i; /* sanity check */ if ((n < 0) || (n > 1)) { fprintf(stderr, "tenmado_new: strange n (%d)\n", n); return NULL; } if (t <= 0) { fprintf(stderr, "tenmado_new: t is non-positive (%d)\n", t); return NULL; } if (t_shoot <= 0) { fprintf(stderr, "tenmado_new: t_shoot is non-positive (%d)\n", t_shoot); return NULL; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 2); if (p == NULL) { fprintf(stderr, "tenmado_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(3, x + 15.0, y - 30.0, x, y + 30.0, x - 15.0, y - 30.0); if (p[0] == NULL) { fprintf(stderr, "tenmado_new: cannot set p[0]\n"); free(p); return NULL; } p[1] = (tenm_primitive *) tenm_polygon_new(4, x + 30.0, y - 30.0, x + 7.5, y, x - 7.5, y, x - 30.0, y - 30.0); if (p[1] == NULL) { fprintf(stderr, "tenmado_new: cannot set p[0]\n"); (p[0])->delete(p[0]); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 9); if (count == NULL) { fprintf(stderr, "tenmado_new: malloc(count) failed\n"); for (i = 0; i < 2; i++) (p[i])->delete(p[i]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 3); if (count_d == NULL) { fprintf(stderr, "tenmado_new: malloc(count_d) failed\n"); free(count); for (i = 0; i < 2; i++) (p[i])->delete(p[i]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] life mode * [3] life timer * [4] shoot timer * [5] n * [6] t * [7] table index * [8] time shoot */ /* list of count_d * [0] speed x * [1] speed y * [2] y origin */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 0; count[4] = 0; count[5] = n; count[6] = t; count[7] = table_index; count[8] = t_shoot; count_d[0] = dx; count_d[1] = 6.0; count_d[2] = y; new = tenm_object_new("tenmado", ATTR_ENEMY, ATTR_PLAYER_SHOT, 55, x, y, 9, count, 3, count_d, 2, p, (int (*)(tenm_object *, double)) (&tenmado_move), (int (*)(tenm_object *, tenm_object *)) (&tenmado_hit), (int (*)(tenm_object *, const tenm_object *)) (&tenmado_act), (int (*)(tenm_object *, int)) (&tenmado_draw)); if (new == NULL) { fprintf(stderr, "tenmado_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); for (i = 0; i < 2; i++) (p[i])->delete(p[i]); free(p); return NULL; } return new; } static int tenmado_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "tenmado_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "tenmado_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); if (!in_window_object(my)) return 1; return 0; } static int tenmado_hit(tenm_object *my, tenm_object *your) { int n; /* sanity check */ if (my == NULL) { fprintf(stderr, "tenmado_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "tenmado_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; deal_damage(my, your, 0); if (tenmado_green(my)) add_chain(my, your); my->count[1] = 41; if (my->hit_point <= 0) { if (tenmado_green(my)) n = 8; else n = 7; tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] / 2.0, my->count_d[1]/ 2.0, 1, 20, n, 3.0, 8)); tenm_table_add(fragment_new(my->x, my->y, my->count_d[0] / 2.0, my->count_d[1] / 2.0, 20.0, 10, n, 3.0, 0.0, 8)); add_score(11); if (my->count[2] <= 1) tenm_table_apply(my->count[7], (int (*)(tenm_object *, int)) (&tenmado_signal), 0); return 1; } return 0; } static int tenmado_signal(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "plan 9 more 1") != 0) return 0; (my->count[2])++; return 0; } static int tenmado_act(tenm_object *my, const tenm_object *player) { double c; /* sanity check */ if (my == NULL) { fprintf(stderr, "tenmado_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; (my->count[3])++; /* speed change */ if (my->count[2] == 0) { if (my->count[3] >= 18) { my->count[2] = 1; my->count[3] = 0; my->count_d[2] = my->y; } } else if (my->count[2] == 1) { if (my->count[5] == 0) c = 90.0 + ((double) ((my->count[3] % 11) * 3)); else c = 60.0; if (player->x - my->x > c) my->count_d[0] += 0.5; if (player->x - my->x > my->x) my->count_d[0] = 6.0; if (my->count[5] == 1) c = 90.0 + ((double) ((my->count[3] % 11) * 3)); else c = 60.0; if (player->x - my->x < -c) my->count_d[0] -= 0.5; if (my->x - player->x > ((double) WINDOW_WIDTH) - my->x) my->count_d[0] = -6.0; if (my->count_d[0] > 6.0) my->count_d[0] = 6.0; if (my->count_d[0] < -6.0) my->count_d[0] = -6.0; my->count_d[1] = my->count_d[2] + 50.0 * tenm_sin(my->count[3] * 7) - my->y; if (my->count[3] >= my->count[6]) { my->count[2] = 2; my->count[3] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; } } else { if (my->count[3] >= 10) my->count_d[1] = 6.0; } /* shoot */ if (my->count[2] <= 1) { if (my->count[4] < my->count[8]) (my->count[4])++; if (my->count[4] >= my->count[8]) { if ((my->x < player->x - 42.0) || (my->x > player->x + 42.0)) { tenm_table_add(tenmado_shot_new(my->x, my->y, 2)); my->count[4] = 0; } else if ((my->x > player->x - 10.0) && (my->x < player->x + 10.0)) { tenm_table_add(tenmado_shot_new(my->x, my->y, 4)); my->count[4] = 0; } } } return 0; } static int tenmado_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; /* sanity check */ if (my == NULL) { fprintf(stderr, "tenmado_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; /* decoration */ if (tenmado_green(my)) { if (my->count[1] >= 40) color = tenm_map_color(181, 190, 92); else color = tenm_map_color(157, 182, 123); } else { if (my->count[1] >= 40) color = tenm_map_color(200, 164, 92); else color = tenm_map_color(182, 147, 123); } if (tenm_draw_line((int) (my->x + 15.0), (int) (my->y - 30.0), (int) (my->x + 7.5), (int) (my->y), 1, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 15.0), (int) (my->y - 30.0), (int) (my->x - 7.5), (int) (my->y), 1, color) != 0) status = 1; if (tenm_draw_circle((int) (my->x), (int) (my->y), 5, 1, color) != 0) status = 1; /* body */ if (tenmado_green(my)) { if (my->count[1] >= 40) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 40) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (tenm_draw_line((int) (my->x + 30.0), (int) (my->y - 30.0), (int) (my->x + 7.5), (int) (my->y), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 7.5), (int) (my->y), (int) (my->x), (int) (my->y + 30.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x), (int) (my->y + 30.0), (int) (my->x - 7.5), (int) (my->y), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 7.5), (int) (my->y), (int) (my->x - 30.0), (int) (my->y - 30.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 30.0), (int) (my->y - 30.0), (int) (my->x + 30.0), (int) (my->y - 30.0), 3, color) != 0) status = 1; /* hit point stat */ if (my->count[1] > 0) { sprintf(temp, "%d", my->hit_point); if (draw_string((int) (my->x - 10.0), (int) (my->y - 18.0), temp, (int) strlen(temp)) != 0) { fprintf(stderr, "tenmado_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int tenmado_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if (my->count[2] <= 1) return 1; return 0; } static tenm_object * tenmado_shot_new(double x, double y, int color) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; /* sanity check */ if ((color < 0) || (color > 5)) { fprintf(stderr, "tenmado_shot_new: strange color (%d)\n", color); return NULL; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "tenmado_shot_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(3, x, y - 46.0, x - 6.0, y + 7.0, x + 6.0, y + 7.0); if (p[0] == NULL) { fprintf(stderr, "tenmado_shot_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 6); if (count == NULL) { fprintf(stderr, "tenmado_shot_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 3); if (count_d == NULL) { fprintf(stderr, "tenmado_shot_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] color */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = color; count_d[0] = 0.0; count_d[1] = 12.0; new = tenm_object_new("tenmado shot", ATTR_ENEMY_SHOT, ATTR_OPAQUE, 1, x, y, 6, count, 3, count_d, 1, p, (int (*)(tenm_object *, double)) (&tenmado_shot_move), (int (*)(tenm_object *, tenm_object *)) (&tenmado_shot_hit), (int (*)(tenm_object *, const tenm_object *)) (&tenmado_shot_act), (int (*)(tenm_object *, int)) (&tenmado_shot_draw)); if (new == NULL) { fprintf(stderr, "tenmado_shot_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int tenmado_shot_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "tenmado_shot_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "tenmado_shot_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); if (!in_window_object(my)) return 1; return 0; } static int tenmado_shot_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "tenmado_shot_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "tenmado_shot_hit: your is NULL\n"); return 0; } if (your->attr & ATTR_OPAQUE) return 1; return 0; } static int tenmado_shot_act(tenm_object *my, const tenm_object *player) { /* sanity check */ if (my == NULL) { fprintf(stderr, "tenmado_shot_act: my is NULL\n"); return 0; } if (player == NULL) return 0; return 0; } static int tenmado_shot_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; /* sanity check */ if (my == NULL) { fprintf(stderr, "tenmado_shot_draw: my is NULL\n"); return 0; } /* return if it is not my turn */ if (priority != 1) return 0; switch (my->count[0]) { case 0: color = tenm_map_color(0, 191, 47); break; case 1: color = tenm_map_color(0, 191, 127); break; case 2: color = tenm_map_color(0, 167, 223); break; case 3: color = tenm_map_color(0, 111, 223); break; case 4: color = tenm_map_color(75, 0, 239); break; case 5: color = tenm_map_color(175, 0, 239); break; default: fprintf(stderr, "tenmado_shot_draw: strange my->count[0] (%d)\n", my->count[0]); color = tenm_map_color(0, 0, 0); break; } if (tenm_draw_line((int) (my->x + 6.0), (int) (my->y - 7.0), (int) (my->x), (int) (my->y + 46.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x), (int) (my->y + 46.0), (int) (my->x - 6.0), (int) (my->y - 7.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 6.0), (int) (my->y - 7.0), (int) (my->x + 6.0), (int) (my->y - 7.0), 3, color) != 0) status = 1; return status; } dangen-0.5/spqr/tenmado.h0000644000175000017500000000046710276702741016220 0ustar00ooharaoohara00000000000000/* $Id: tenmado.h,v 1.9 2004/10/07 14:09:32 oohara Exp $ */ #ifndef __DANGEN_TENMADO_H__ #define __DANGEN_TENMADO_H__ #include "tenm_object.h" tenm_object *tenmado_new(double x, double y, int n, double dx, int t, int table_index, int t_shoot); #endif /* not __DANGEN_TENMADO_H__ */ dangen-0.5/spqr/theorem-weapon.c0000644000175000017500000012364011625011267017510 0ustar00ooharaoohara00000000000000/* $Id: theorem-weapon.c,v 1.224 2011/08/23 20:51:03 oohara Exp $ */ /* [normal] Theorem Weapon */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "stage-clear.h" #include "score.h" /* tenm_same_side, tenm_line_nearer */ #include "tenm_collision.h" #include "theorem-weapon.h" #define NEAR_ZERO 0.0001 static int theorem_weapon_move(tenm_object *my, double turn_per_frame); static int theorem_weapon_hit(tenm_object *my, tenm_object *your); static void theorem_weapon_explode(tenm_object *my); static int theorem_weapon_act(tenm_object *my, const tenm_object *player); static void theorem_weapon_theorem(tenm_object *my, const tenm_object *player, int what, int t); static int theorem_weapon_draw(tenm_object *my, int priority); static int theorem_weapon_green(const tenm_object *my); static tenm_object * theorem_weapon_shot_absolute_new(double x, double y, double player_x, double player_y, double speed, int theta, int what, int color); static tenm_object * theorem_weapon_shot_aim_new(double x, double y, double player_x, double player_y, double speed, int theta, int what, int color); static tenm_object * theorem_weapon_shot_new(double x, double y, double player_x, double player_y, double speed_x, double speed_y, int what, int color); static int theorem_weapon_shot_move(tenm_object *my, double turn_per_frame); static int theorem_weapon_shot_hit(tenm_object *my, tenm_object *your); static int theorem_weapon_shot_act(tenm_object *my, const tenm_object *player); static int theorem_weapon_shot_seek(double x, double y, double player_x, double player_y, double speed_x, double speed_y, int what); static int theorem_weapon_shot_draw(tenm_object *my, int priority); tenm_object * theorem_weapon_new(void) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = (double) (WINDOW_WIDTH / 2); double y = -39.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "theorem_weapon_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_circle_new(x, y, 40.0); if (p[0] == NULL) { fprintf(stderr, "theorem_weapon_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 7); if (count == NULL) { fprintf(stderr, "theorem_weapon_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "theorem_weapon_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] move mode * [3] move timer * [4] decoration timer * [5] shoot direction * [6] "was green when killed" flag */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 0; count[4] = 90; count[5] = 0; count[6] = 0; count_d[0] = 0.0; count_d[1] = (((double) (WINDOW_HEIGHT / 6)) - y) / 120.0; new = tenm_object_new("Theorem Weapon", ATTR_BOSS, ATTR_PLAYER_SHOT, 1000, x, y, 7, count, 2, count_d, 1, p, (int (*)(tenm_object *, double)) (&theorem_weapon_move), (int (*)(tenm_object *, tenm_object *)) (&theorem_weapon_hit), (int (*)(tenm_object *, const tenm_object *)) (&theorem_weapon_act), (int (*)(tenm_object *, int)) (&theorem_weapon_draw)); if (new == NULL) { fprintf(stderr, "theorem_weapon_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int theorem_weapon_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "theorem_weapon_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "theorem_weapon_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int theorem_weapon_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "theorem_weapon_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "theorem_weapon_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if (my->count[2] != 1) return 0; deal_damage(my, your, 0); if (theorem_weapon_green(my)) add_chain(my, your); my->count[1] = 2; if (my->hit_point <= 0) { add_score(30000); set_background(1); theorem_weapon_explode(my); return 0; } return 0; } static void theorem_weapon_explode(tenm_object *my) { int n; double speed_theta; /* sanity check */ if (my == NULL) return; tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy), 0); /* set "was green" flag before we change the life mode */ if (theorem_weapon_green(my)) { n = 8; my->count[6] = 1; speed_theta = -30.0; } else { n = 7; my->count[6] = 0; speed_theta = 15.0; } tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 5000, n, 10.0, 6)); tenm_table_add(fragment_new(my->x - 80.0, my->y, -2.0, 0.0, 50.0, 12, n, 4.0, speed_theta, 20)); tenm_table_add(fragment_new(my->x + 80.0, my->y, 2.0, 0.0, 50.0, 12, n, 4.0, speed_theta, 20)); tenm_table_add(fragment_new(my->x - 160.0, my->y, -2.0, 0.0, 50.0, 12, n, 4.0, speed_theta, 20)); tenm_table_add(fragment_new(my->x + 160.0, my->y, 2.0, 0.0, 50.0, 12, n, 4.0, speed_theta, 20)); my->count[2] = 2; my->count[3] = 0; my->count[1] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.5; /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ tenm_mass_delete(my->mass); my->mass = NULL; } static int theorem_weapon_act(tenm_object *my, const tenm_object *player) { int theta; int n; /* sanity check */ if (my == NULL) { fprintf(stderr, "theorem_weapon_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; (my->count[3])++; /* encounter */ if (my->count[2] == 0) { if (my->count[3] >= 120) { my->count[2] = 1; my->count[3] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; } return 0; } /* self-destruction */ if ((my->count[2] == 1) && (my->count[3] >= 4330)) { set_background(2); clear_chain(); theorem_weapon_explode(my); return 0; } /* dead */ if (my->count[2] == 2) { if (theorem_weapon_green(my)) n = 8; else n = 7; if ((my->count[3] >= 30) && (my->count[3] <= 75) && (my->count[3] % 15 == 0)) { theta = rand() % 360; tenm_table_add(explosion_new(my->x + 30.0 * tenm_cos(theta), my->y + 30.0 * tenm_sin(theta), 0.0, 0.0, 2, 300, n, 5.0, 8)); } if (my->count[3] > 120) { tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 3000, n, 10.0, 8)); tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 2, 800, n, 6.0, 8)); tenm_table_add(stage_clear_new(100)); return 1; } return 0; } /* decoration */ if (theorem_weapon_green(my)) my->count[4] -= 2; else my->count[4] += 1; if (my->count[2] != 1) return 0; /* shoot */ if ((my->count[3] >= 60) && (my->count[3] <= 150)) theorem_weapon_theorem(my, player, 0, my->count[3] - 60); if ((my->count[3] >= 300) && (my->count[3] <= 780)) theorem_weapon_theorem(my, player, 2, my->count[3] - 300); if ((my->count[3] >= 930) && (my->count[3] <= 930)) theorem_weapon_theorem(my, player, 3, my->count[3] - 930); if ((my->count[3] >= 1080) && (my->count[3] <= 1170)) theorem_weapon_theorem(my, player, 6, my->count[3] - 1080); if ((my->count[3] >= 1320) && (my->count[3] <= 1370)) theorem_weapon_theorem(my, player, 1, my->count[3] - 1320); if ((my->count[3] >= 1570) && (my->count[3] <= 1786)) theorem_weapon_theorem(my, player, 4, my->count[3] - 1570); if ((my->count[3] >= 2000) && (my->count[3] <= 2160)) theorem_weapon_theorem(my, player, 5, my->count[3] - 2000); if ((my->count[3] >= 2310) && (my->count[3] <= 2910)) theorem_weapon_theorem(my, player, 9, my->count[3] - 2310); if ((my->count[3] >= 3060) && (my->count[3] <= 3636)) theorem_weapon_theorem(my, player, 7, my->count[3] - 3060); if ((my->count[3] >= 3790) && (my->count[3] <= 4150)) theorem_weapon_theorem(my, player, 8, my->count[3] - 3790); return 0; } static void theorem_weapon_theorem(tenm_object *my, const tenm_object *player, int what, int t) { int i; int j; int theta; double speed; double x; double y; /* sanity check */ if (my == NULL) { fprintf(stderr, "theorem_weapon_theorem: my is NULL\n"); return; } if (player == NULL) return; if (t < 0) { fprintf(stderr, "theorem_weapon_theorem: t is negative (%d)\n", t); return; } switch (what) { case 0: if (t == 0) my->count[5] = rand() % 2; if ((t >= 0) && (t <= 150) && (t % 15 == 0)) { for (i = (60 - t / 3) * (-1); i <= (60 - t / 3); i += 60 - t / 3) { for (j = 0; j < 2; j++) { if (t % 30 == ((j + my->count[5]) % 2) * 15) speed = 5.5; else speed = 4.0; x = my->x - 200.0 + 400.0 * ((double) j); tenm_table_add(theorem_weapon_shot_aim_new(x, my->y, player->x, player->y, speed, i, 0, 3)); } } } break; case 1: if (t == 0) { for (j = 0; j < 2; j++) { for (i = 0; i < 3; i++) { x = my->x - 200.0 + 400.0 * ((double) j); speed = 4.0 + ((double) i) * 2.0; tenm_table_add(theorem_weapon_shot_absolute_new(x, my->y, player->x, player->y, speed, 45 + j * 90, 1, 1)); tenm_table_add(theorem_weapon_shot_absolute_new(x, my->y, player->x, player->y, speed, 15 + j * 150, 1, 1)); } } } if (t == 10) { for (j = 0; j < 2; j++) { for (i = 0; i < 3; i++) { x = my->x - 200.0 + 400.0 * ((double) j); speed = 3.0 + ((double) i) * 2.0; tenm_table_add(theorem_weapon_shot_aim_new(x, my->y, player->x, player->y, speed, 0, 1, 3)); } } } if (t == 30) { for (j = 0; j < 2; j++) { for (i = 0; i < 3; i++) { x = my->x - 200.0 + 400.0 * ((double) j); speed = 4.0 + ((double) i) * 2.0; tenm_table_add(theorem_weapon_shot_absolute_new(x, my->y, player->x, player->y, speed, 60 + j * 60, 1, 1)); tenm_table_add(theorem_weapon_shot_absolute_new(x, my->y, player->x, player->y, speed, 20 + j * 140, 1, 1)); } } } if (t == 40) { for (j = 0; j < 2; j++) { for (i = 0; i < 3; i++) { x = my->x - 200.0 + 400.0 * ((double) j); speed = 4.0 + ((double) i) * 2.0; tenm_table_add(theorem_weapon_shot_absolute_new(x, my->y, player->x, player->y, speed, 30 + j * 120, 1, 1)); tenm_table_add(theorem_weapon_shot_absolute_new(x, my->y, player->x, player->y, speed, 80 + j * 20, 1, 1)); } } } if (t == 50) { for (j = 0; j < 2; j++) { for (i = 0; i < 3; i++) { x = my->x - 200.0 + 400.0 * ((double) j); speed = 3.0 + ((double) i) * 2.0; tenm_table_add(theorem_weapon_shot_aim_new(x, my->y, player->x, player->y, speed, 0, 1, 3)); } } } break; case 2: if (t == 0) my->count[5] = rand() % 2; if ((t >= 0) && (t <= 480) && (t % 8 == 0)) { for (i = -15; i <= 15; i += 30) { for (j = 0; j < 2; j++) { x = my->x - 200.0 + 400.0 * ((double) j); tenm_table_add(theorem_weapon_shot_aim_new(x, my->y, player->x, player->y, 6.0, i, 0, 2)); } } } if ((t >= 0) && (t < 480) && (t % 8 == 0)) { j = (t / 120 + my->count[5]) % 2; x = my->x - 40.0 + 80.0 * ((double) j); theta = 160 - 140 * j + (t % 120) * (j * 2 - 1); tenm_table_add(theorem_weapon_shot_absolute_new(x, my->y, player->x, player->y, 4.5, theta, 1, 1)); x = my->x + 80.0 - 160.0 * ((double) j); theta = 20 + 140 * j - (t % 120) * (j * 2 - 1); tenm_table_add(theorem_weapon_shot_absolute_new(x, my->y, player->x, player->y, 5.0, theta, 1, 1)); } break; case 3: if (t == 0) { my->count[5] = -1 + 2 * (rand() % 2); for (i = 0; i < 6; i++) { speed = 4.0 + 0.5 * ((double) i); x = my->x + (-200.0 + 80.0 * ((double) i)) * ((double) (my->count[5])); for (j = 0; j < 360; j += 24) { tenm_table_add(theorem_weapon_shot_aim_new(x, my->y, player->x, player->y, speed, j, 1, 3)); } } } break; case 4: if ((t >= 0) && (t < 216) && (t % 3 == 0)) { if (t % 6 == 0) { tenm_table_add(theorem_weapon_shot_aim_new(my->x, my->y, player->x, player->y, 6.0, 0, 0, 3)); } else { theta = 6 + (t % 36); for (i = -1; i <= 1; i += 2) { for (j = 0; j < 2; j++) { x = my->x - 200.0 + 400.0 * ((double) j); tenm_table_add(theorem_weapon_shot_aim_new(x, my->y, player->x, player->y, 6.0, theta * i, 0, 2)); tenm_table_add(theorem_weapon_shot_aim_new(x, my->y, player->x, player->y, 6.0, (75 - theta) * i, 0, 2)); } } } } break; case 5: if (t == 0) my->count[5] = -1 + 2 * (rand() % 2); if (t == 0) { x = my->x + 200.0 * ((double) (my->count[5])); theta = 90 + 10 * my->count[5]; for (i = 0; i < 320; i += 10) tenm_table_add(theorem_weapon_shot_absolute_new(x, my->y, player->x, player->y, 4.0, theta + i * my->count[5], 0, 1)); } if (t == 30) { x = my->x - 200.0 * ((double) (my->count[5])); theta = 90 - 10 * my->count[5]; for (i = 0; i < 320; i += 10) tenm_table_add(theorem_weapon_shot_absolute_new(x, my->y, player->x, player->y, 3.5, theta - i * my->count[5], 0, 1)); } if (t == 70) { for (j = 0; j < 2; j++) { for (i = 0; i < 320; i += 10) { theta = 65 + 50 * j; x = my->x - 200.0 + 400.0 * ((double) j); tenm_table_add(theorem_weapon_shot_absolute_new(x, my->y, player->x, player->y, 3.0, theta + i * (1 - 2 * j), 0, 1)); } } } if (t == 75) { for (j = 0; j < 2; j++) { for (i = 0; i < 320; i += 10) { theta = 70 + 40 * j; x = my->x - 150.0 + 300.0 * ((double) j); tenm_table_add(theorem_weapon_shot_absolute_new(x, my->y, player->x, player->y, 2.75, theta + i * (1 - 2 * j), 0, 1)); } } } if ((t > 110) && (t < 160) && (t % 4 == 0)) { for (j = 0; j < 2; j++) { x = my->x + (8.0 * ((double) (135 - t))) * ((double) (-1 + 2 * j)); speed = 3.0 + 0.12 * ((double) (t - 110)); for (i = -1; i <= 1; i++) tenm_table_add(theorem_weapon_shot_aim_new(x, my->y, player->x, player->y, speed, (t - 100) * i, 1, 3)); } } break; case 6: if (t == 0) my->count[5] = rand() % 2; if (t == 0) { x = my->x - 200.0 + 400.0 * ((double) (my->count[5])); for (i = -7; i <= 7; i += 2) tenm_table_add(theorem_weapon_shot_aim_new(x, my->y, player->x, player->y, 6.0, 10 * i, 0, 2)); } if (t == 10) { x = my->x + 200.0 - 400.0 * ((double) (my->count[5])); for (i = -7; i <= 7; i += 2) tenm_table_add(theorem_weapon_shot_aim_new(x, my->y, player->x, player->y, 6.0, 10 * i, 0, 2)); } if (t == 20) { x = my->x - 200.0 + 400.0 * ((double) (my->count[5])); for (i = -3; i <= 3; i += 2) tenm_table_add(theorem_weapon_shot_aim_new(x, my->y, player->x, player->y, 9.0, 4 * i, 0, 2)); } if (t == 30) { x = my->x + 200.0 - 400.0 * ((double) (my->count[5])); for (i = -3; i <= 3; i += 2) tenm_table_add(theorem_weapon_shot_aim_new(x, my->y, player->x, player->y, 9.0, 4 * i, 0, 2)); } if ((t >= 40) && (t <= 60) && (t % 5 == 0)) { for (i = 0; i < 2; i++) { theta = -175 + 40 * ((t - 40) / 5) - 60 * i; for (j = -1; j <= 1; j += 2) { tenm_table_add(theorem_weapon_shot_aim_new(my->x - 40.0, my->y, player->x, player->y, 7.0, theta * j, 1, 2)); tenm_table_add(theorem_weapon_shot_aim_new(my->x + 40.0, my->y, player->x, player->y, 7.0, theta * j, 1, 2)); } } } if (t == 65) { for (i = -2; i <= 2; i++) { tenm_table_add(theorem_weapon_shot_aim_new(my->x, my->y, player->x, player->y, 7.0, 8 * i, 1, 3)); } } if ((t >= 70) && (t <= 90) && (t % 5 == 0)) { for (i = 0; i < 2; i++) { theta = 25 + 40 * ((t - 70) / 5) - 60 * i; for (j = -1; j <= 1; j += 2) { tenm_table_add(theorem_weapon_shot_aim_new(my->x - 40.0, my->y, player->x, player->y, 7.0, theta * j, 1, 2)); tenm_table_add(theorem_weapon_shot_aim_new(my->x + 40.0, my->y, player->x, player->y, 7.0, theta * j, 1, 2)); } } } break; case 7: if ((t >= 0) && (t < 576) && (t % 8 == 0)) { if (t % 48 < 24) { tenm_table_add(theorem_weapon_shot_aim_new(my->x, my->y, player->x, player->y, 6.0, 0, 0, 3)); } else { for (j = -1; j <= 1; j += 2) tenm_table_add(theorem_weapon_shot_aim_new(my->x, my->y, player->x, player->y, 6.0, 10 * j, 0, 2)); } for (i = 0; i < 2; i++) { x = my->x - 200.0 + 400.0 * ((double) i); if (t % 64 < 32) { tenm_table_add(theorem_weapon_shot_aim_new(x, my->y, player->x, player->y, 6.0, 0, 0, 3)); } else { for (j = -1; j <= 1; j += 2) tenm_table_add(theorem_weapon_shot_aim_new(x, my->y, player->x, player->y, 6.0, 10 * j, 0, 2)); } } } break; case 8: if (t > 360) break; if (t == 0) my->count[5] = -1 + 2 * (rand() % 2); if ((t >= 0) && (t % 7 == 0)) { for (i = 0; i < 2; i++) { x = my->x + 200.0 * tenm_sin((2 * t + 90 * i) * my->count[5]); speed = 6.0 + 1.0 * ((double) ((t % 28) / 7)); for (j = 0; j < 4; j++) { tenm_table_add(theorem_weapon_shot_absolute_new(x, my->y, player->x, player->y, speed, 35 + 90 * j, 1, 1)); tenm_table_add(theorem_weapon_shot_absolute_new(x, my->y, player->x, player->y, speed, 55 + 90 * j, 1, 1)); } } } if ((t >= 0) && (t % 5 == 0) && (t % 25 < 20)) { theta = t * 4 * my->count[5]; x = my->x + 40.0 * tenm_cos(theta); y = my->y + 40.0 * tenm_sin(theta); tenm_table_add(theorem_weapon_shot_aim_new(x, y, player->x, player->y, 6.0, 0, 0, 3)); } break; case 9: if (t > 600) break; if ((t >= 0) && (t % 2 == 0)) { x = my->x - 200.0 + 40.0 * ((double) (t % 12)); theta = (t % 12) * 5 + (t / 12) * 37 - 90; tenm_table_add(theorem_weapon_shot_absolute_new(x, my->y, player->x, player->y, 6.0, theta, 0, 1)); x = my->x + 200.0 - 40.0 * ((double) (t % 12)); tenm_table_add(theorem_weapon_shot_absolute_new(x, my->y, player->x, player->y, 6.0, -(theta + 180), 0, 1)); } if ((t >= 0) && (t % 26 == 0)) { for (i = -1; i <= 1; i++) tenm_table_add(theorem_weapon_shot_aim_new(my->x, my->y, player->x, player->y, 5.0, 30 * i, 1, 3)); } if ((t >= 0) && (t % 26 == 13)) { for (i = -1; i <= 1; i++) { x = my->x + 120.0 * ((double) i); tenm_table_add(theorem_weapon_shot_aim_new(x, my->y, player->x, player->y, 5.0, 0, 1, 3)); } } break; default: fprintf(stderr, "theorem_weapon_theorem: undefined what (%d)\n", what); break; } } static int theorem_weapon_draw(tenm_object *my, int priority) { int i; int status = 0; tenm_color color; char temp[32]; int theta; int red_orig; int green_orig; int blue_orig; int red; int green; int blue; int c; /* sanity check */ if (my == NULL) { fprintf(stderr, "theorem_weapon_draw: my is NULL\n"); return 0; } /* decoration */ if ((priority == 0) && (my->count[2] <= 1)) { if (theorem_weapon_green(my)) { if (my->count[1] >= 1) { red_orig = 109; green_orig = 125; blue_orig = 9; } else { red_orig = 61; green_orig = 95; blue_orig = 13; } } else { if (my->count[1] >= 1) { red_orig = 135; green_orig = 89; blue_orig = 9; } else { red_orig = 95; green_orig = 47; blue_orig = 13; } } for (i = 0; i < 360; i += 180) { theta = my->count[4] * 3 + i; while (theta >= 360) theta -= 360; while (theta < 0) theta += 360; if (theta < 180) c = 180 - theta; else c = theta - 180; if (c < 0) c = 0; if (c > 256) c = 256; red = (red_orig * (256 - c) + DEFAULT_BACKGROUND_RED * c) / 256; green = (green_orig * (256 - c) + DEFAULT_BACKGROUND_GREEN * c) / 256; blue = (blue_orig * (256 - c) + DEFAULT_BACKGROUND_BLUE * c) / 256; color = tenm_map_color(red, green, blue); if (tenm_draw_line(((int) (my->x)) + 80, (int) (my->y + 40.0 * tenm_sin(theta)), ((int) (my->x)) + 200, (int) (my->y + 40.0 * tenm_sin(theta)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x)) - 80, (int) (my->y + 40.0 * tenm_sin(theta)), ((int) (my->x)) - 200, (int) (my->y + 40.0 * tenm_sin(theta)), 1, color) != 0) status = 1; } c = 90; red = (red_orig * (256 - c) + DEFAULT_BACKGROUND_RED * c) / 256; green = (green_orig * (256 - c) + DEFAULT_BACKGROUND_GREEN * c) / 256; blue = (blue_orig * (256 - c) + DEFAULT_BACKGROUND_BLUE * c) / 256; color = tenm_map_color(red, green, blue); if (tenm_draw_line(((int) (my->x)) + 40, (int) (my->y), ((int) (my->x)) + 200, (int) (my->y), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x)) - 40, (int) (my->y), ((int) (my->x)) - 200, (int) (my->y), 1, color) != 0) status = 1; } /* body */ /* dead enemy has low priority */ if (((my->count[2] <= 1) && (priority == 0)) || ((my->count[2] > 1) && (priority == -1))) { if (theorem_weapon_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 1) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (tenm_draw_circle((int) (my->x), (int) (my->y), 40, 3, color) != 0) status = 1; } /* hit point stat */ if ((priority == 0) && (my->count[2] == 1)) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 10, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "theorem_weapon_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int theorem_weapon_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if ((my->count[2] == 1) && (my->count[3] >= 1940) && (my->count[3] < 4300)) return 1; if ((my->count[2] == 2) && (my->count[6] != 0)) return 1; return 0; } static tenm_object * theorem_weapon_shot_absolute_new(double x, double y, double player_x, double player_y, double speed, int theta, int what, int color) { /* sanity check */ if (speed < NEAR_ZERO) { fprintf(stderr, "theorem_weapon_shot_absolute_new: speed is non-positive " "(%f)\n", speed); return NULL; } if ((color != 0) && (color != 1)) { fprintf(stderr, "theorem_weapon_shot_absolute_new: wrong color " "(%d)\n", color); return NULL; } return theorem_weapon_shot_new(x, y, player_x, player_y, speed * tenm_cos(theta), speed * tenm_sin(theta), what, color); } static tenm_object * theorem_weapon_shot_aim_new(double x, double y, double player_x, double player_y, double speed, int theta, int what, int color) { double dx; double dy; double length; double result[2]; double v[2]; /* sanity check */ if (speed < NEAR_ZERO) { fprintf(stderr, "theorem_weapon_shot_aim_new: speed is non-positive " "(%f)\n", speed); return NULL; } if ((color != 2) && (color != 3)) { fprintf(stderr, "theorem_weapon_shot_aim_new: wrong color " "(%d)\n", color); return NULL; } dx = player_x - x; dy = player_y - y; length = tenm_sqrt((int) (dx * dx + dy * dy)); if (length < NEAR_ZERO) length = 1.0; v[0] = speed * dx / length; v[1] = speed * dy / length; result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, theta); return theorem_weapon_shot_new(x, y, player_x, player_y, result[0], result[1], what, color); } /* list of what * 0: normal shot * 1: laser */ static tenm_object * theorem_weapon_shot_new(double x, double y, double player_x, double player_y, double speed_x, double speed_y, int what, int color) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; int hit_mask; double length_x; double length_y; double speed; /* sanity check */ if ((what < 0) || (what > 1)) { fprintf(stderr, "theorem_weapon_shot_new: strange what (%d)\n", what); return NULL; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "theorem_weapon_shot_new: malloc(p) failed\n"); return NULL; } if (what == 0) { p[0] = (tenm_primitive *) tenm_circle_new(x, y, 5.0); } else { speed = tenm_sqrt((int) (speed_x * speed_x + speed_y * speed_y)); if (speed < NEAR_ZERO) speed = 1.0; length_x = 25.0 * speed_x / speed; length_y = 25.0 * speed_y / speed; p[0] = (tenm_primitive *) tenm_segment_new(x, y, x + length_x, y + length_y); } if (p[0] == NULL) { fprintf(stderr, "theorem_weapon_shot_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 3); if (count == NULL) { fprintf(stderr, "theorem_weapon_shot_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "theorem_weapon_shot_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] base color * [1] what * [2] warning flag */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = color; count[1] = what; count[2] = theorem_weapon_shot_seek(x, y, player_x, player_y, speed_x, speed_y, what); count_d[0] = speed_x; count_d[1] = speed_y; if (what == 0) hit_mask = ATTR_OPAQUE; else hit_mask = 0; new = tenm_object_new("Theorem Weapon shot", ATTR_ENEMY_SHOT, hit_mask, 1, x, y, 3, count, 2, count_d, 1, p, (int (*)(tenm_object *, double)) (&theorem_weapon_shot_move), (int (*)(tenm_object *, tenm_object *)) (&theorem_weapon_shot_hit), (int (*)(tenm_object *, const tenm_object *)) (&theorem_weapon_shot_act), (int (*)(tenm_object *, int)) (&theorem_weapon_shot_draw)); if (new == NULL) { fprintf(stderr, "normal_shot_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int theorem_weapon_shot_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "theorem_weapon_shot_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "theorem_weapon_shot_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; /* slow down if the player is in the way */ /* if (my->count[2] != 0) { dx_temp *= 0.5; dy_temp *= 0.5; } */ my->x += dx_temp; my->y += dy_temp; tenm_move_mass(my->mass, dx_temp, dy_temp); if (!in_window_object(my)) return 1; return 0; } static int theorem_weapon_shot_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "theorem_weapon_shot_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "theorem_weapon_shot_hit: your is NULL\n"); return 0; } if (your->attr & ATTR_OPAQUE) return 1; return 0; } static int theorem_weapon_shot_act(tenm_object *my, const tenm_object *player) { /* sanity check */ if (my == NULL) { fprintf(stderr, "normal_shot_act: my is NULL\n"); return 0; } if (player == NULL) return 0; my->count[2] = theorem_weapon_shot_seek(my->x, my->y, player->x, player->y, my->count_d[0], my->count_d[1], my->count[1]); return 0; } /* checks if the shot hit the player * return 1 (true) or 0 (false) */ static int theorem_weapon_shot_seek(double x, double y, double player_x, double player_y, double speed_x, double speed_y, int what) { /* sanity check */ if ((what < 0) || (what > 1)) return 0; if (what == 0) { if (!tenm_line_nearer(player_x, player_y, x, y, x + speed_x, y + speed_y, 10.6)) return 0; if (tenm_same_side(player_x, player_y, x + speed_x, y + speed_y, x, y, x - speed_y, y + speed_x)) return 1; if (tenm_line_nearer(player_x, player_y, x, y, x - speed_y, y + speed_x, 10.6)) return 1; return 0; } else { if (!tenm_line_nearer(player_x, player_y, x, y, x + speed_x, y + speed_y, 5.1)) return 0; if (tenm_same_side(player_x, player_y, x + speed_x, y + speed_y, x, y, x - speed_y, y + speed_x)) return 1; if (tenm_line_nearer(player_x, player_y, x, y, x - speed_y, y + speed_x, 5.1)) return 1; return 0; } /* should not reach here */ fprintf(stderr, "theorem_weapon_shot_seek: fall off\n"); return 0; } static int theorem_weapon_shot_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; /* sanity check */ if (my == NULL) { fprintf(stderr, "theorem_weapon_shot_draw: my is NULL\n"); return 0; } if (my->mass == NULL) { fprintf(stderr, "theorem_weapon_shot_draw: my->mass is NULL\n"); return 0; } /* return if it is not my turn */ if (priority != 1) return 0; if (my->count[2] != 0) color = tenm_map_color(175, 0, 239); else { switch (my->count[0]) { case 0: color = tenm_map_color(0, 191, 47); break; case 1: color = tenm_map_color(0, 191, 127); break; case 2: color = tenm_map_color(0, 167, 223); break; case 3: color = tenm_map_color(0, 111, 223); break; default: fprintf(stderr, "normal_shot_draw: strange my->count[0] (%d)\n", my->count[0]); color = tenm_map_color(0, 0, 0); break; } } if (my->count[1] == 0) { if (tenm_draw_circle((int) (my->x), (int) (my->y), 5, 2, color) != 0) status = 1; } else { if (tenm_draw_line((int) (((tenm_segment *) my->mass->p[0])->a->x), (int) (((tenm_segment *) my->mass->p[0])->a->y), (int) (((tenm_segment *) my->mass->p[0])->b->x), (int) (((tenm_segment *) my->mass->p[0])->b->y), 3, color) != 0) status = 1; } return status; } dangen-0.5/spqr/theorem-weapon.h0000644000175000017500000000037410276702741017520 0ustar00ooharaoohara00000000000000/* $Id: theorem-weapon.h,v 1.1 2004/04/25 09:34:22 oohara Exp $ */ #ifndef __DANGEN_THEOREM_WEAPON_H__ #define __DANGEN_THEOREM_WEAPON_H__ #include "tenm_object.h" tenm_object *theorem_weapon_new(void); #endif /* not __DANGEN_THEOREM_WEAPON_H__ */ dangen-0.5/spqr/title.c0000644000175000017500000000544510276702741015706 0ustar00ooharaoohara00000000000000/* $Id: title.c,v 1.12 2005/07/05 17:52:52 oohara Exp $ */ /* VERSION */ #include #include /* strlen */ #include #include "tenm_input.h" #include "tenm_graphic.h" #include "util.h" #include "esc-ok.h" #include "tenm_timer.h" #include "background.h" /* COPYRIGHT_STRING */ #include "const.h" #include "title.h" /* return * 0 if a real game is requested * 1 if a tutorial demo is requested * 2 if a play record is requested * 3 if the program should quit */ int title(void) { int choice = 0; char temp[32]; int delay = 6; /* we don't need to pause in the title */ tenm_set_focus_handler((void (*)(int)) NULL); set_background(0); while (1 == 1) { if (tenm_event_handle() != 0) { choice = 3; break; } /* quit if ESC is pressed */ if (tenm_get_key_status() & 32) { if (get_esc_ok()) { /* this is completely useless, but let's be pedantic */ set_esc_ok(0); choice = 3; break; } } else { set_esc_ok(1); } /* proceed if space if pressed */ if (tenm_get_key_status() & 16) break; switch (tenm_get_key_status() & 15) { case 1: /* up */ if (delay <= 0) { if (choice <= 0) choice = 3; else choice--; delay = 6; } else { delay--; } break; case 2: /* down */ if (delay <= 0) { if (choice >= 3) choice = 0; else choice++; delay = 6; } else { delay--; } break; default: delay = 0; break; } clear_window_with_background(); if (draw_string(80, 90, "dangen", 7) != 0) fprintf(stderr, "title: draw_string (title) failed\n"); sprintf(temp, "version %.20s", VERSION); if (draw_string(80, 120, temp, (int) strlen(temp)) != 0) fprintf(stderr, "title: draw_string (version) failed\n"); if (draw_string(100, 200, "start a game", 12) != 0) fprintf(stderr, "title: draw_string (start) failed\n"); if (draw_string(100, 220, "tutorial", 8) != 0) fprintf(stderr, "title: draw_string (tutorial) failed\n"); if (draw_string(100, 240, "play record", 11) != 0) fprintf(stderr, "title: draw_string (record) failed\n"); if (draw_string(100, 260, "quit", 4) != 0) fprintf(stderr, "title: draw_string (quit) failed\n"); if (draw_string(80, 200 + choice * 20, ">", 1) != 0) fprintf(stderr, "title: draw_string (cursor) failed\n"); if (draw_string(120, 460, COPYRIGHT_STRING, (int) strlen(COPYRIGHT_STRING)) != 0) fprintf(stderr, "title: draw_string (copyright) failed\n"); tenm_redraw_window(); tenm_wait_next_frame(); } return choice; } dangen-0.5/spqr/title.h0000644000175000017500000000025010276702741015700 0ustar00ooharaoohara00000000000000/* $Id: title.h,v 1.1 2005/06/27 18:02:40 oohara Exp $ */ #ifndef __DANGEN_TITLE_H__ #define __DANGEN_TITLE_H__ int title(void); #endif /* not __DANGEN_TITLE_H__ */ dangen-0.5/spqr/tutor.c0000644000175000017500000006575310276702741015752 0ustar00ooharaoohara00000000000000/* $Id: tutor.c,v 1.141 2005/07/10 16:46:56 oohara Exp $ */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "score.h" #include "tutor.h" #define NEAR_ZERO 0.0001 static int tutor_move(tenm_object *my, double turn_per_frame); static int tutor_hit(tenm_object *my, tenm_object *your); static void tutor_increase_level(tenm_object *my); static int tutor_signal(tenm_object *my, int n); static int tutor_act(tenm_object *my, const tenm_object *player); static int tutor_draw(tenm_object *my, int priority); static int tutor_green(const tenm_object *my); tenm_object * tutor_new(int what, double x, double y, int parent_index, int rank) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; const char *name = NULL; int hit_point = 1; int t_shoot = 9999; /* sanity check */ if ((what < 0) || (what > 3)) { fprintf(stderr, "tutor_new: strange what (%d)\n", what); return NULL; } if (parent_index < 0) { fprintf(stderr, "tutor_new: strange parent_index (%d)\n", parent_index); return NULL; } if (rank < 0) { fprintf(stderr, "tutor_new: rank is non-positive (%d)\n", rank); return NULL; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "tutor_new: malloc(p) failed\n"); return NULL; } switch(what) { case 0: p[0] = (tenm_primitive *) tenm_circle_new(x, y, 20.0); if (p[0] == NULL) { fprintf(stderr, "tutor_new: cannot set p[0] (0)\n"); free(p); return NULL; } break; case 1: p[0] = (tenm_primitive *) tenm_circle_new(x, y, 25.0); if (p[0] == NULL) { fprintf(stderr, "tutor_new: cannot set p[0] (1)\n"); free(p); return NULL; } break; case 2: p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 48.0, y - 36.0, x + 48.0, y + 36.0, x - 48.0, y + 36.0, x - 48.0, y - 36.0); if (p[0] == NULL) { fprintf(stderr, "tutor_new: cannot set p[0] (1)\n"); free(p); return NULL; } break; case 3: p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 36.0, y - 48.0, x + 36.0, y + 48.0, x - 36.0, y + 48.0, x - 36.0, y - 48.0); if (p[0] == NULL) { fprintf(stderr, "tutor_new: cannot set p[0] (1)\n"); free(p); return NULL; } break; default: fprintf(stderr, "tutor_new: undefined what when setting p[0] (%d)\n", what); free(p); return NULL; break; } count = (int *) malloc(sizeof(int) * 8); if (count == NULL) { fprintf(stderr, "tutor_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "tutor_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } switch(what) { case 0: name = "tutor soldier"; hit_point = 1; if (rank < 300) t_shoot = 31; else if (rank < 400) t_shoot = 19; else t_shoot = 11; break; case 1: name = "tutor sniper"; hit_point = 20; t_shoot = 30; break; case 2: name = "tutor divider"; hit_point = 85; if (rank < 300) t_shoot = 37; else if (rank < 400) t_shoot = 27; else t_shoot = 17; break; case 3: name = "tutor conqueror"; hit_point = 85; if (rank < 300) t_shoot = 31; else t_shoot = 17; break; default: fprintf(stderr, "tutor_new: undefined what when setting name (%d)\n", what); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; break; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] what * [3] parent index * [4] rank * [5] t_shoot * [6] life timer * [7] shoot timer */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = 0; count[1] = 0; count[2] = what; count[3] = parent_index; count[4] = rank; count[5] = t_shoot; count[6] = 0; if ((t_shoot > 5) && (t_shoot < 1000)) count[7] = rand() % ((t_shoot + 1) / 2); else count[7] = 0; count_d[0] = 0.0; if (what == 0) count_d[1] = 4.0; else if (what == 1) count_d[1] = 5.0; else count_d[1] = 5.0; new = tenm_object_new(name, ATTR_ENEMY, ATTR_PLAYER_SHOT, hit_point, x, y, 8, count, 2, count_d, 1, p, (int (*)(tenm_object *, double)) (&tutor_move), (int (*)(tenm_object *, tenm_object *)) (&tutor_hit), (int (*)(tenm_object *, const tenm_object *)) (&tutor_act), (int (*)(tenm_object *, int)) (&tutor_draw)); if (new == NULL) { fprintf(stderr, "tutor_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int tutor_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "tutor_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "tutor_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); if (!in_window_object(my)) { /* escaped */ tutor_increase_level(my); return 1; } return 0; } static void tutor_increase_level(tenm_object *my) { int level; /* sanity check */ if (my == NULL) { fprintf(stderr, "tutor_increase_level: my is NULL\n"); return; } switch (my->count[2]) { case 0: level = 1; break; case 1: level = 1; break; case 2: level = 3; break; case 3: level = 3; break; default: fprintf(stderr, "tutor_increase_level: undefined what (%d)\n", my->count[2]); level = 0; break; } tenm_table_apply(my->count[3], (int (*)(tenm_object *, int)) (&tutor_signal), level); } static int tutor_hit(tenm_object *my, tenm_object *your) { int n; int score; /* sanity check */ if (my == NULL) { fprintf(stderr, "tutor_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "tutor_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; deal_damage(my, your, 0); if (tutor_green(my)) add_chain(my, your); my->count[1] = 41; if (my->hit_point <= 0) { tutor_increase_level(my); switch (my->count[2]) { case 0: score = 2; break; case 1: score = 3; break; case 2: score = 5; break; case 3: score = 7; break; default: fprintf(stderr, "tutor_hit: undefined what when setting score (%d)\n", my->count[2]); score = 0; break; } add_score(score); if (tutor_green(my)) n = 8; else n = 7; switch (my->count[2]) { case 0: tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] / 2.0, my->count_d[1]/ 2.0, 2, 20, n, 3.0, 8)); break; case 1: tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] / 2.0, my->count_d[1]/ 2.0, 2, 30, n, 4.0, 8)); break; case 2: case 3: tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] / 2.0, my->count_d[1]/ 2.0, 1, 200, n, 5.0, 8)); tenm_table_add(fragment_new(my->x, my->y, my->count_d[0] / 2.0, my->count_d[1] / 2.0, 20.0, 20, n, 4.0, 0.0, 8)); break; default: fprintf(stderr, "tutor_hit: undefined what when exploding (%d)\n", my->count[2]); break; } return 1; } return 0; } static int tutor_signal(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "plan 0 more 1") != 0) return 0; if (n <= 0) return 0; if (my->count[5] % 100 >= (my->count[5] + n ) % 100) my->count[4] += 80; my->count[5] += n; return 0; } static int tutor_act(tenm_object *my, const tenm_object *player) { int i; int theta; double dx; double dy; double length; double length2; double speed; double result[2]; double v[2]; /* sanity check */ if (my == NULL) { fprintf(stderr, "tutor_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; (my->count[6])++; (my->count[7])++; /* speed change */ switch (my->count[2]) { case 0: if (my->x < 50.0) { my->count_d[0] = 50.0 - my->x; } else if (my->x > ((double) WINDOW_WIDTH) - 50.0) { my->count_d[0] = (((double) WINDOW_WIDTH) - 50.0) - my->x; } else if (my->count[6] < 50) { if ((my->x > player->x - 2.0) && (my->x < player->x + 2.0)) { my->count_d[0] = player->x - my->x; } else if (my->x < player->x) { my->count_d[0] += 0.1; } else { my->count_d[0] += -0.1; } } if (my->count_d[0] < -2.0) my->count_d[0] = -2.0; if (my->count_d[0] > 2.0) my->count_d[0] = 2.0; if (my->count[6] >= 50) { if ((my->count_d[0] > -0.1) && (my->count_d[0] < 0.1)) my->count_d[0] = 0.0; else if (my->count_d[0] > 0.0) my->count_d[0] += -0.1; else my->count_d[0] += 0.1; } break; case 1: break; case 2: case 3: if (my->count[6] == 20) { my->count_d[1] = 2.0; } break; default: fprintf(stderr, "tutor_act: undefined what when changing speed (%d)\n", my->count[2]); break; } /* shoot */ switch (my->count[2]) { case 0: if (my->count[7] < my->count[5]) break; if (my->y > 300.0) break; if (my->count[4] < 100) speed = 4.0 + ((double) (my->count[4])) * 0.04; else if (my->count[4] < 200) speed = 6.0 + ((double) (my->count[4] - 100)) * 0.06; else speed = 16.0; if (my->y > 150.0) speed *= 0.75; dx = player->x - my->x; dy = player->y - my->y; length2 = dx * dx + dy * dy; if ((length2 < 300.0 * 300.0) || (my->count[4] < 100)) { tenm_table_add(normal_shot_point_new(my->x, my->y, speed, player->x, player->y, 3)); } else { if (length2 < 400.0 * 400.0) theta = 6; else theta = 15; for (i = -1; i <= 1; i += 2) { v[0] = dx; v[1] = dy; result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, theta * i); tenm_table_add(normal_shot_point_new(my->x, my->y, speed, my->x + result[0], my->y + result[1], 3)); } } my->count[7] = 0; break; case 1: if (my->count[7] < my->count[5]) break; if (my->count[4] < 100) speed = 6.0 + ((double) (my->count[4])) * 0.06; else if (my->count[4] < 200) speed = 8.0 + ((double) (my->count[4] - 100)) * 0.08; else speed = 24.0; if ((my->count[7] == my->count[5] + 0) || ((my->count[7] == my->count[5] + 10) && (my->count[4] >= 100))) { tenm_table_add(laser_point_new(my->x, my->y, speed, player->x, player->y, 30.0, 4)); } else if ((my->count[7] == my->count[5] + 5) && (my->count[4] >= 400)) { tenm_table_add(laser_point_new(my->x, my->y, speed * 0.75, player->x + player->count_d[0] * 15.0, player->y + player->count_d[1] * 15.0, 30.0, 5)); } else if ((my->count[7] == my->count[5] + 15) && (my->count[4] >= 400)) { tenm_table_add(laser_point_new(my->x, my->y, speed * 0.75, player->x + player->count_d[0] * 10.0, player->y + player->count_d[1] * 10.0, 30.0, 5)); } /* don't reset my->count[7] --- shoot only once */ break; case 2: if (my->count[6] < 20) { (my->count[7])--; break; } if (my->count[7] < my->count[5]) break; if (my->count[4] < 100) speed = 5.0 + ((double) (my->count[4])) * 0.05; else if (my->count[4] < 200) speed = 7.5 + ((double) (my->count[4] - 100)) * 0.075; else speed = 20.0; if (((my->count[7] == my->count[5] + 0) || (my->count[7] == my->count[5] + 10)) && (my->y < 400.0)) { if ((player->y > my->y) && (my->y < 300.0)) { if (player->x < my->x) { if (my->count[4] >= 100) tenm_table_add(laser_angle_new(my->x - 40.0, my->y - 28.0, speed * 0.75, 80, 25.0, 1)); tenm_table_add(laser_angle_new(my->x - 40.0, my->y - 28.0, speed, 70, 25.0, 1)); if (my->count[4] >= 100) tenm_table_add(laser_angle_new(my->x + 40.0, my->y - 28.0, speed * 0.75, 140, 25.0, 1)); tenm_table_add(laser_angle_new(my->x + 40.0, my->y - 28.0, speed, 150, 25.0, 1)); } else { if (my->count[4] >= 100) tenm_table_add(laser_angle_new(my->x - 40.0, my->y - 28.0, speed * 0.75, 40, 25.0, 1)); tenm_table_add(laser_angle_new(my->x - 40.0, my->y - 28.0, speed, 30, 25.0, 1)); if (my->count[4] >= 100) tenm_table_add(laser_angle_new(my->x + 40.0, my->y - 28.0, speed * 0.75, 100, 25.0, 1)); tenm_table_add(laser_angle_new(my->x + 40.0, my->y - 28.0, speed, 110, 25.0, 1)); } } else { if (player->x < my->x) { if (my->count[4] >= 100) tenm_table_add(laser_angle_new(my->x - 40.0, my->y - 28.0, speed * 0.75, -80, 25.0, 1)); tenm_table_add(laser_angle_new(my->x - 40.0, my->y - 28.0, speed, -70, 25.0, 1)); if (my->count[4] >= 100) tenm_table_add(laser_angle_new(my->x + 40.0, my->y - 28.0, speed * 0.75, 230, 25.0, 1)); tenm_table_add(laser_angle_new(my->x + 40.0, my->y - 28.0, speed, 220, 25.0, 1)); } else { if (my->count[4] >= 100) tenm_table_add(laser_angle_new(my->x - 40.0, my->y - 28.0, speed * 0.75, -50, 25.0, 1)); tenm_table_add(laser_angle_new(my->x - 40.0, my->y - 28.0, speed, -40, 25.0, 1)); if (my->count[4] >= 100) tenm_table_add(laser_angle_new(my->x + 40.0, my->y - 28.0, speed * 0.75, -100, 25.0, 1)); tenm_table_add(laser_angle_new(my->x + 40.0, my->y - 28.0, speed, -110, 25.0, 1)); } } } else if (my->count[7] == my->count[5] + 25) { if (my->y > 200.0) speed *= 0.75; if (my->y < 300.0) tenm_table_add(normal_shot_point_new(my->x, my->y, speed, player->x, player->y, 4)); } if (my->count[7] >= my->count[5] + 25) my->count[7] = 0; break; case 3: if (my->count[6] < 20) { (my->count[7])--; break; } if (my->count[7] < my->count[5]) break; if (my->count[4] < 100) speed = 4.0 + ((double) (my->count[4])) * 0.04; else if (my->count[4] < 200) speed = 6.0 + ((double) (my->count[4] - 100)) * 0.06; else speed = 16.0; if ((my->count[7] == my->count[5] + 0) || (my->count[7] == my->count[5] + 10)) { if (my->y < 300.0) { dx = player->x - my->x; dy = player->y - my->y; length2 = dx * dx + dy * dy; length = tenm_sqrt((int) (length2)); if (length < NEAR_ZERO) length = 1.0; v[0] = 30.0 * dx / length; v[1] = 30.0 * dy / length; if (length2 < 350.0 * 350.0) { tenm_table_add(laser_point_new(my->x - v[1], my->y + v[0], speed, player->x, player->y, 25.0, 0)); tenm_table_add(laser_point_new(my->x + v[1], my->y - v[0], speed, player->x, player->y, 25.0, 0)); } else { tenm_table_add(laser_point_new(my->x - v[1], my->y + v[0], speed, my->x - v[1] + v[0] - v[1] * 0.1, my->y + v[0] + v[1] + v[0] * 0.1, 25.0, 0)); tenm_table_add(laser_point_new(my->x + v[1], my->y - v[0], speed, my->x + v[1] + v[0] + v[1] * 0.1, my->y - v[0] + v[1] - v[0] * 0.1, 25.0, 0)); } if (my->count[4] >= 100) { tenm_table_add(laser_point_new(my->x - v[1], my->y + v[0], speed * 0.75, my->x - v[1] + v[0] - v[1] * 0.3, my->y + v[0] + v[1] + v[0] * 0.3, 25.0, 0)); tenm_table_add(laser_point_new(my->x + v[1], my->y - v[0], speed * 0.75, my->x + v[1] + v[0] + v[1] * 0.3, my->y - v[0] + v[1] - v[0] * 0.3, 25.0, 0)); } } } else if (((my->count[7] == my->count[5] + 15) || (my->count[7] == my->count[5] + 20) || (my->count[7] == my->count[5] + 25)) && (my->count[4] >= 400)) { if (my->y > 200.0) speed *= 0.75; if (my->count[7] == my->count[5] + 15) speed *= 0.6; else if (my->count[7] == my->count[5] + 20) speed *= 0.8; if (my->y < 300.0) tenm_table_add(normal_shot_point_new(my->x, my->y, speed, player->x, player->y, 5)); } if (my->count[7] >= my->count[5] + 25) my->count[7] = 0; break; default: fprintf(stderr, "tutor_act: undefined what when shooting (%d)\n", my->count[2]); break; } return 0; } static int tutor_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; /* sanity check */ if (my == NULL) { fprintf(stderr, "tutor_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; /* decoration */ if (tutor_green(my)) { if (my->count[1] >= 40) color = tenm_map_color(181, 190, 92); else color = tenm_map_color(157, 182, 123); } else { if (my->count[1] >= 40) color = tenm_map_color(200, 164, 92); else color = tenm_map_color(182, 147, 123); } switch (my->count[2]) { case 0: if (tenm_draw_line(((int) (my->x + 20.0)), ((int) (my->y)), ((int) (my->x - 20.0)), ((int) (my->y)), 1, color) != 0) status = 1; break; case 1: if (tenm_draw_line(((int) (my->x + 25.0)), ((int) (my->y)), ((int) (my->x - 25.0)), ((int) (my->y)), 1, color) != 0) status = 1; break; case 2: break; case 3: if (tenm_draw_line(((int) (my->x - 24.0)), ((int) (my->y - 48.0)), ((int) (my->x - 12.0)), ((int) (my->y + 48.0)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + 24.0)), ((int) (my->y - 48.0)), ((int) (my->x + 12.0)), ((int) (my->y + 48.0)), 1, color) != 0) status = 1; break; default: fprintf(stderr, "tutor_draw: undefined what when drawing decoration " "(%d)\n", my->count[2]); break; } /* body */ if (tutor_green(my)) { if (my->count[1] >= 40) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 40) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } switch (my->count[2]) { case 0: if (tenm_draw_circle((int) (my->x), (int) (my->y), 20, 3, color) != 0) status = 1; break; case 1: if (tenm_draw_circle((int) (my->x), (int) (my->y), 25, 3, color) != 0) status = 1; break; case 2: if (tenm_draw_line(((int) (my->x - 40.0)), ((int) (my->y - 28.0)), ((int) (my->x + 40.0)), ((int) (my->y - 28.0)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - 40.0)), ((int) (my->y - 28.0)), ((int) (my->x - 40.0)), ((int) (my->y + 36.0)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + 40.0)), ((int) (my->y - 28.0)), ((int) (my->x + 40.0)), ((int) (my->y + 36.0)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + 48.0)), ((int) (my->y - 36.0)), ((int) (my->x + 48.0)), ((int) (my->y + 36.0)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + 48.0)), ((int) (my->y + 36.0)), ((int) (my->x - 48.0)), ((int) (my->y + 36.0)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - 48.0)), ((int) (my->y + 36.0)), ((int) (my->x - 48.0)), ((int) (my->y - 36.0)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - 48.0)), ((int) (my->y - 36.0)), ((int) (my->x + 48.0)), ((int) (my->y - 36.0)), 3, color) != 0) status = 1; break; case 3: if (tenm_draw_line(((int) (my->x + 36.0)), ((int) (my->y - 48.0)), ((int) (my->x + 36.0)), ((int) (my->y + 48.0)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + 36.0)), ((int) (my->y + 48.0)), ((int) (my->x - 36.0)), ((int) (my->y + 48.0)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - 36.0)), ((int) (my->y + 48.0)), ((int) (my->x - 36.0)), ((int) (my->y - 48.0)), 3, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - 36.0)), ((int) (my->y - 48.0)), ((int) (my->x + 36.0)), ((int) (my->y - 48.0)), 3, color) != 0) status = 1; break; default: fprintf(stderr, "tutor_draw: undefined what when drawing body (%d)\n", my->count[2]); break; } /* hit point stat */ if (my->count[1] > 0) { sprintf(temp, "%d", my->hit_point); if (draw_string((int) (my->x - 5.0), (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "tutor_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int tutor_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; switch (my->count[2]) { case 0: if (my->count[6] <= 75) return 1; break; case 1: if (my->count[6] <= 60) return 1; break; case 2: if (my->count[6] <= 145) return 1; break; case 3: if (my->count[6] <= 145) return 1; break; default: fprintf(stderr, "tutor_green: undefined what (%d)\n", my->count[2]); break; } return 0; } dangen-0.5/spqr/tutor.h0000644000175000017500000000043210276702741015736 0ustar00ooharaoohara00000000000000/* $Id: tutor.h,v 1.6 2005/07/09 06:34:45 oohara Exp $ */ #ifndef __DANGEN_TUTOR_H__ #define __DANGEN_TUTOR_H__ #include "tenm_object.h" tenm_object *tutor_new(int what, double x, double y, int parent_index, int rank); #endif /* not __DANGEN_TUTOR_H__ */ dangen-0.5/spqr/w-ko.c0000644000175000017500000013323211625011346015427 0ustar00ooharaoohara00000000000000/* $Id: w-ko.c,v 1.226 2011/08/23 20:51:50 oohara Exp $ */ /* [normal] W-KO */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "normal-enemy.h" #include "stage-clear.h" #include "score.h" #include "ship.h" #include "w-ko.h" #define NEAR_ZERO 0.0001 static int w_ko_move(tenm_object *my, double turn_per_frame); static int w_ko_hit(tenm_object *my, tenm_object *your); static void w_ko_explode(tenm_object *my); static int w_ko_act(tenm_object *my, const tenm_object *player); static int w_ko_draw(tenm_object *my, int priority); static int w_ko_green(const tenm_object *my); static tenm_object *w_ko_cut_new(double dx, double dy, double target_x, double target_y); static int w_ko_cut_act(tenm_object *my, const tenm_object *player); static int w_ko_cut_draw(tenm_object *my, int priority); static tenm_object *w_ko_spear_new(double x, double y, double dx, double dy); static int w_ko_spear_move(tenm_object *my, double turn_per_frame); static int w_ko_spear_act(tenm_object *my, const tenm_object *player); static int w_ko_spear_draw(tenm_object *my, int priority); static tenm_object *w_ko_lock_on_new(double x, double y, double target_x, double target_y, int what); static int w_ko_lock_on_act(tenm_object *my, const tenm_object *player); static int w_ko_lock_on_draw(tenm_object *my, int priority); static tenm_object *w_ko_more_1_new(void); static int w_ko_more_1_act(tenm_object *my, const tenm_object *player); tenm_object * w_ko_new(void) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = (double) (WINDOW_WIDTH / 2); double y = -100.0; int i; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "w_ko_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_circle_new(x, y, 30.0); if (p[0] == NULL) { fprintf(stderr, "w_ko_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 38); if (count == NULL) { fprintf(stderr, "w_ko_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 30); if (count_d == NULL) { fprintf(stderr, "w_ko_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] life mode * [3] life timer * [4] dash mode * [5] dash timer * [6] blade mode * [7] blade timer * [8] normal shot mode * [9] normal shot timer * [10] spear mode * [11] spear timer * [12 -- 35] lock on * [suffix + 0] mode * [suffix + 1] timer * [36] last resort randomness * [37] "was green when killed" flag */ /* list of count_d * [0] speed x * [1] speed y * [2] aim x * [3] aim y * [4] dash x * [5] dash y * [6 -- 29] lock on (x, y) */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 0; count[4] = 1; count[5] = 0; count[6] = 0; count[7] = -30; count[8] = 0; count[9] = 0; count[10] = 0; count[11] = -460; for (i = 0; i < 12; i++) { count[12 + i * 2 + 0] = 0; count[12 + i * 2 + 1] = -20 - 20 * i; } count[36] = 0; count[37] = 0; count_d[0] = 0.0; count_d[1] = 0.0; count_d[2] = 0.0; count_d[3] = 60.0; count_d[4] = (double) (WINDOW_WIDTH / 2); count_d[5] = (double) (WINDOW_HEIGHT / 2); for (i = 0; i < 12; i++) { count_d[6 + i * 2 + 0] = 0.0; count_d[6 + i * 2 + 1] = 0.0; } new = tenm_object_new("W-KO", ATTR_BOSS, ATTR_PLAYER_SHOT, 400, x, y, 38, count, 30, count_d, 1, p, (int (*)(tenm_object *, double)) (&w_ko_move), (int (*)(tenm_object *, tenm_object *)) (&w_ko_hit), (int (*)(tenm_object *, const tenm_object *)) (&w_ko_act), (int (*)(tenm_object *, int)) (&w_ko_draw)); if (new == NULL) { fprintf(stderr, "w_ko_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int w_ko_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "w_ko_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "w_ko_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int w_ko_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "w_ko_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "w_ko_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; deal_damage(my, your, 0); if (w_ko_green(my)) add_chain(my, your); my->count[1] = 2; if (my->hit_point <= 0) { add_score(30000); set_background(1); w_ko_explode(my); return 0; } return 0; } static void w_ko_explode(tenm_object *my) { int n; /* sanity check */ if (my == NULL) return; tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy), 0); /* don't modify my->attr or my->hit_mask here, or the player shot * may fly through the enemy */ tenm_mass_delete(my->mass); my->mass = NULL; /* set "was green" flag before we change the life mode */ if (w_ko_green(my)) { n = 8; my->count[37] = 1; } else { n = 7; my->count[37] = 0; } tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 3000, n, 6.0, 8)); tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 2, 800, n, 3.5, 8)); my->count[1] = 0; my->count[2] = 1; my->count[3] = 1; my->count_d[0] = 0.0; my->count_d[1] = 0.0; } static int w_ko_act(tenm_object *my, const tenm_object *player) { double result[2]; double v[2]; double a[2]; int i; int j; double x; double y; double c; /* sanity check */ if (my == NULL) { fprintf(stderr, "w_ko_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; (my->count[3])++; /* dead */ if (my->count[2] == 1) { if ((my->count[3] <= 9) && (my->count[3] % 3 == 0)) { if (w_ko_green(my)) i = 8; else i = 7; tenm_table_add(explosion_new(my->x + ((double) (my->count[3]/3)) * 60.0, my->y, 0.0, 0.0, 1, 200, i, 2.0, 8)); tenm_table_add(explosion_new(my->x - ((double) (my->count[3]/3)) * 60.0, my->y, 0.0, 0.0, 1, 200, i, 2.0, 8)); } if (my->count[3] >= 9) { tenm_table_add(stage_clear_new(100)); return 1; } return 0; } /* self-destruction */ if (my->count[3] >= 4630) { set_background(2); clear_chain(); w_ko_explode(my); return 0; } /* normal enemy */ if (my->count[3] == 1500) tenm_table_add(w_ko_more_1_new()); /* speed change */ if (my->count[4] == 0) { for (i = 0; i <= 1; i++) { if ((player->count_d[i] < -0.11) || (player->count_d[i] > 0.11)) my->count_d[i] = player->count_d[i] * (-0.75); else if ((my->count_d[i] > -0.11) && (my->count_d[i] < 0.11)) my->count_d[i] = 0.0; else if (my->count_d[i] < -0.11) my->count_d[i] += 0.1; else my->count_d[i] -= 0.1; } if (((my->x < 15.0) && (my->count_d[0] < NEAR_ZERO)) || ((my->x > ((double) WINDOW_WIDTH) - 15.0) && (my->count_d[0] > -NEAR_ZERO))) { my->count_d[0] = 0.0; if (my->count[4] == 0) (my->count[5])++; } if (((my->y < 15.0) && (my->count_d[1] < NEAR_ZERO)) || ((my->y > ((double) WINDOW_HEIGHT) - 15.0) && (my->count_d[1] > -NEAR_ZERO))) { my->count_d[1] = 0.0; if (my->count[4] == 0) (my->count[5])++; } } /* aim the player */ a[0] = player->x - my->x; a[1] = player->y - my->y; v[0] = my->count_d[2]; v[1] = my->count_d[3]; result[0] = v[0]; result[1] = v[1]; vector_rotate_bounded(result, v, a, 1); my->count_d[2] = result[0]; my->count_d[3] = result[1]; /* last resort */ if (my->count[3] == 4200) { /* dash to the center */ my->count[4] = 1; my->count[5] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; my->count_d[4] = (double) (WINDOW_WIDTH / 2); my->count_d[5] = (double) (WINDOW_HEIGHT / 2); } if (my->count[3] >= 4260) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; } if (my->count[3] == 4260) { my->count[36] = 1 + rand() % 12; if (rand() % 2 == 0) my->count[36] *= -1; } if ((my->count[3] >= 4260) && (my->count[3] <= 4370) && (my->count[3] % 10 == 0)) { /* super lock on */ i = (my->count[3] - 4260) / 10; i = (i + my->count[36] + 12) % 12; if ((i >= 0) && (i < 12)) { x = (double) (WINDOW_WIDTH / 5) * ((double) ((i % 4) + 1)); y = (double) (WINDOW_HEIGHT / 4) * ((double) ((i % 3) + 1)); if (my->count[36] < 0) y = (double) (WINDOW_HEIGHT) - y; x += (double) (-5 + rand() % 11); y += (double) (-5 + rand() % 11); my->count[12 + i * 2 + 0] = 1; my->count[12 + i * 2 + 1] = 1; my->count_d[6 + i * 2 + 0] = x; my->count_d[6 + i * 2 + 1] = y; } } if (my->count[3] == 4440) my->count[36] = rand() % 360; if ((my->count[3] >= 4445) && (my->count[3] <= 4535) && (my->count[3] % 10 == 0)) { i = (my->count[3] - 4445) / 10; i = i * 36 * 7 + my->count[36]; /* super blade */ tenm_table_add(w_ko_cut_new(60.0 * tenm_cos(i), 60.0 * tenm_sin(i), player->x, player->y)); } /* normal lock on */ for (i = 0; i < 12; i++) { if (my->count[12 + i * 2 + 0] == 0) { if (i >= 4) continue; if ((my->count[3] < 1000) || (my->count[3] >= 4000)) continue; (my->count[12 + i * 2 + 1])++; if (my->count[12 + i * 2 + 1] <= 0) continue; if (i % 2 == 0) { x = player->x; y = player->y; } else { x = ((double) WINDOW_WIDTH) - player->x; y = ((double) WINDOW_HEIGHT) - player->y; } if ((x - my->x) * (x - my->x) + (y - my->y) * (y - my->y) <= (double) (my->count[12 + i * 2 + 1] * my->count[12 + i * 2 + 1]) * 64.0) { my->count[12 + i * 2 + 0] = 1; my->count[12 + i * 2 + 1] = 1; my->count_d[6 + i * 2 + 0] = x; my->count_d[6 + i * 2 + 1] = y; for (j = 0; j < 4; j++) { if ((j == i) || (my->count[12 + j * 2 + 0] != 0)) continue; my->count[12 + j * 2 + 1] -= 5; if ((j - i) % 2 == 0) my->count[12 + j * 2 + 1] -= 25; } } } else if (my->count[12 + i * 2 + 0] == 1) { (my->count[12 + i * 2 + 1])++; if (my->count[12 + i * 2 + 1] > 20) { x = player->x - my->count_d[6 + i * 2 + 0]; y = player->y - my->count_d[6 + i * 2 + 1]; if ((x * x + y * y <= (double) (my->count[12 + i * 2 + 1] * my->count[12 + i * 2 + 1]) * 25.0) && ((my->x - my->count_d[6 + i * 2 + 0] < -NEAR_ZERO) || (my->x - my->count_d[6 + i * 2 + 0] > NEAR_ZERO))) { tenm_table_add(w_ko_lock_on_new(my->x, my->y, my->count_d[6 + i * 2 + 0], my->count_d[6 + i * 2 + 1], i % 2)); my->count[12 + i * 2 + 0] = 0; my->count[12 + i * 2 + 1] = -30; } } } } /* spear */ if (my->count[10] == 0) { (my->count[11])++; if ((my->count[11] >= 200) && (my->count[4] == 0) && (my->count[6] == 0) && (my->count[3] < 4000)) { a[0] = player->x - my->x; a[1] = player->y - my->y; v[0] = my->count_d[2]; v[1] = my->count_d[3]; result[0] = v[0]; result[1] = v[1]; vector_rotate_bounded(result, v, a, 360); my->count_d[2] = result[0]; my->count_d[3] = result[1]; my->count[10] = 1; my->count[11] = 0; return 0; } } else if (my->count[10] == 1) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; (my->count[11])++; if (my->count[11] >= 30) { tenm_table_add(w_ko_spear_new(my->x, my->y, my->count_d[2], my->count_d[3])); my->count[10] = 0; my->count[11] = 0; } return 0; } /* dash */ if (my->count[4] == 0) { (my->count[5])++; /* we want to dash if the player is behind us */ if ((player->x - my->x) * my->count_d[2] + (player->y - my->y) * my->count_d[3] < 0.0) (my->count[5])++; my->count_d[4] = my->x; my->count_d[5] = my->y; if ((my->count[5] >= 0) && (my->count[6] == 0) && (my->count[10] == 0) && (my->count[3] < 4000)) { my->count[4] = 1; my->count[5] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.0; my->count_d[4] = player->x; my->count_d[5] = player->y; my->count_d[4] += (double) (-30 + (rand() % 61)); my->count_d[5] += (double) (-30 + (rand() % 61)); if (my->count_d[4] < 15.0) my->count_d[4] = 15.0; if (my->count_d[4] > ((double) WINDOW_WIDTH) - 15.0) my->count_d[4] = ((double) WINDOW_WIDTH) - 15.0; if (my->count_d[5] < 15.0) my->count_d[5] = 15.0; if (my->count_d[5] > ((double) WINDOW_HEIGHT) - 15.0) my->count_d[5] = ((double) WINDOW_HEIGHT) - 15.0; } } else if (my->count[4] == 1) { my->count_d[0] = 0.0; my->count_d[1] = 0.0; (my->count[5])++; if (my->count[5] == 60) { if (my->mass != NULL) tenm_move_mass(my->mass, my->count_d[4] - my->x, my->count_d[5] - my->y); my->x = my->count_d[4]; my->y = my->count_d[5]; } if (my->count[5] == 30) { if (my->count[6] == 0) my->count[7] = 0; } if (my->count[5] >= 30) { c = ((double) (60 - my->count[5])) / 30.0; c *= 3.0 / 4.0; x = my->count_d[4] * (1.0 - c) + my->x * c; y = my->count_d[5] * (1.0 - c) + my->y * c; a[0] = player->x - x; a[1] = player->y - y; v[0] = my->count_d[2]; v[1] = my->count_d[3]; result[0] = v[0]; result[1] = v[1]; vector_rotate_bounded(result, v, a, 360); my->count_d[2] = result[0]; my->count_d[3] = result[1]; } if (my->count[5] >= 60) { my->count[4] = 0; my->count[5] = -100; if (my->count[6] == 0) my->count[7] = 0; } } /* blade */ if (my->count[6] == 0) { if (my->count[7] < 0) (my->count[7])++; if ((my->count[7] >= 0) && (!((my->count[4] == 1) && (my->count[5] < 30))) && (my->count[3] > 60) && (my->count[3] < 4000)) { x = player->x - my->count_d[4]; y = player->y - my->count_d[5]; if ((x * x + y * y < 180.0 * 180.0) && (x * my->count_d[2] + y * my->count_d[3] > 0.0)) { my->count[6] = 1; my->count[7] = 0; } } } else if (my->count[6] == 1) { (my->count[7])++; /* we can't cut the player if the player is immutable */ if ((get_ship() < 0) || (player->count[1] > 0)) { my->count[6] = 0; my->count[7] = -30; } if (my->count[7] == 5) { v[0] = my->count_d[2]; v[1] = my->count_d[3]; result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, -30); tenm_table_add(w_ko_cut_new(result[0], result[1], player->x, player->y)); } if (my->count[7] >= 10) { if ((my->count[4] == 1) && (my->count[5] < 30)) { my->count[6] = 0; my->count[7] = -30; } else { x = player->x - my->count_d[4]; y = player->y - my->count_d[5]; if ((x * x + y * y < 180.0 * 180.0) && (x * my->count_d[2] + y * my->count_d[3] > 0.0)) { my->count[6] = 2; my->count[7] = 0; } else { my->count[6] = 0; my->count[7] = -30; } } } } else if (my->count[6] == 2) { (my->count[7])++; /* we can't cut the player if the player is immutable */ if ((get_ship() < 0) || (player->count[1] > 0)) { my->count[6] = 0; my->count[7] = -30; } if (my->count[7] == 5) { v[0] = my->count_d[2]; v[1] = my->count_d[3]; result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, 30); tenm_table_add(w_ko_cut_new(result[0], result[1], player->x, player->y)); } if (my->count[7] >= 10) { my->count[6] = 0; my->count[7] = -30; } } /* normal shot */ if ((my->count[4] == 1) && (my->count[5] >= 30)) return 0; if ((my->count[3] <= 60) || (my->count[3] >= 4260)) return 0; (my->count[9])++; if (my->count[8] == 0) { if (my->count[9] % 11 == 0) { for (i = -2; i <= 2; i++) { if (i == 0) { if (my->count[9] % 33 >= 22) continue; } else if ((i == -1) || (i == 1)) { if (my->count[9] % 22 != 0) continue; } else if ((i == -2) || (i == 2)) { if (my->count[9] % 22 != 11) continue; } v[0] = my->count_d[2]; v[1] = my->count_d[3]; result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, 15 * i); tenm_table_add(laser_point_new(my->x, my->y, 4.5, my->x + result[0], my->y + result[1], 25.0, 3)); } } if (my->count[9] >= 132) { my->count[8] = 1; my->count[9] = 0; } } else if (my->count[8] == 1) { if (my->count[9] % 10 == 0) { for (i = -1; i <= 1; i += 2) { v[0] = my->count_d[2] * 20.0 / 60.0; v[1] = my->count_d[3] * 20.0 / 60.0; result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, 90 * i); tenm_table_add(laser_point_new(my->x + result[0], my->y + result[1], 7.5, my->x + result[0] + my->count_d[2], my->y + result[1] + my->count_d[3], 25.0, 2)); } } if (my->count[9] >= 40) { my->count[8] = 0; my->count[9] = 0; } } return 0; } static int w_ko_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; int i; int j; double result[2]; double v[2]; double x; double y; double c; int theta; /* sanity check */ if (my == NULL) { fprintf(stderr, "w_ko_draw: my is NULL\n"); return 0; } if (my->count[2] != 0) return 0; /* decoration */ if (priority == 0) { if (w_ko_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(181, 190, 92); else color = tenm_map_color(157, 182, 123); } else { if (my->count[1] >= 1) color = tenm_map_color(200, 164, 92); else color = tenm_map_color(182, 147, 123); } if (tenm_draw_line((int) (my->x), (int) (my->y), (int) (my->x + my->count_d[2]), (int) (my->y + my->count_d[3]), 1, color) != 0) status = 1; for (i = -1; i <= 1; i += 2) { v[0] = my->count_d[2] * 30.0 / 60.0; v[1] = my->count_d[3] * 30.0 / 60.0; result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, 75 * i); x = my->x + result[0]; y = my->y + result[1]; v[0] = result[0] * 60.0 / 30.0; v[1] = result[1] * 60.0 / 30.0; vector_rotate(result, v, 90 * i); if (tenm_draw_line((int) (x), (int) (y), (int) (x + result[0]), (int) (y + result[1]), 1, color) != 0) status = 1; if (tenm_draw_circle((int) (x + result[0]), (int) (y + result[1]), 5, 1, color) != 0) status = 1; } } /* lock on */ if (priority == 0) { for (i = 0; i < 12; i++) { if (my->count[12 + i * 2 + 0] == 0) continue; if (my->count[12 + i * 2 + 1] <= 20) { c = 425.0 - ((double) (my->count[12 + i * 2 + 1])) * 20.0; theta = 45 + my->count[12 + i * 2 + 1] * 18; x = my->count_d[6 + i * 2 + 0]; y = my->count_d[6 + i * 2 + 1]; for (j = 0; j < 360; j += 90) if (tenm_draw_line((int) (x + c * tenm_cos(theta + j)), (int) (y + c * tenm_sin(theta + j)), (int) (x + c * tenm_cos(theta + 90 + j)), (int) (y + c * tenm_sin(theta + 90 + j)), 1, tenm_map_color(206, 201, 175)) != 0) status = 1; } else { c = 25.0; theta = 30; x = my->count_d[6 + i * 2 + 0]; y = my->count_d[6 + i * 2 + 1]; for (j = 0; j < 360; j += 120) if (tenm_draw_line((int) (x + c * tenm_cos(theta + j)), (int) (y + c * tenm_sin(theta + j)), (int) (x + c * tenm_cos(theta + 120 + j)), (int) (y + c * tenm_sin(theta + 120 + j)), 1, tenm_map_color(158, 158, 158)) != 0) status = 1; } } } /* spear */ if ((priority == 0) && (my->count[10] == 1)) { if (tenm_draw_line((int) (my->x + 90.0 * my->count_d[3] / 60.0), (int) (my->y - 90.0 * my->count_d[2] / 60.0), (int) (my->x + 180.0 * my->count_d[2] / 60.0), (int) (my->y + 180.0 * my->count_d[3] / 60.0), 1, tenm_map_color(182, 123, 162)) != 0) status = 1; if (tenm_draw_line((int) (my->x + 180.0 * my->count_d[2] / 60.0), (int) (my->y + 180.0 * my->count_d[3] / 60.0), (int) (my->x - 90.0 * my->count_d[3] / 60.0), (int) (my->y + 90.0 * my->count_d[2] / 60.0), 1, tenm_map_color(182, 123, 162)) != 0) status = 1; if (tenm_draw_line((int) (my->x - 90.0 * my->count_d[3] / 60.0), (int) (my->y + 90.0 * my->count_d[2] / 60.0), (int) (my->x - 90.0 * my->count_d[2] / 60.0), (int) (my->y - 90.0 * my->count_d[3] / 60.0), 1, tenm_map_color(182, 123, 162)) != 0) status = 1; if (tenm_draw_line((int) (my->x - 90.0 * my->count_d[2] / 60.0), (int) (my->y - 90.0 * my->count_d[3] / 60.0), (int) (my->x + 90.0 * my->count_d[3] / 60.0), (int) (my->y - 90.0 * my->count_d[2] / 60.0), 1, tenm_map_color(182, 123, 162)) != 0) status = 1; } /* dash */ if ((priority == 0) && (my->count[4] == 1)) { if (my->count[5] < 30) c = ((double) (my->count[5])) / 30.0; else c = 1.0; x = my->count_d[4] * c + my->x * (1.0 - c); y = my->count_d[5] * c + my->y * (1.0 - c); if (tenm_draw_circle((int) (x), (int) (y), 30, 1, color) != 0) status = 1; if (tenm_draw_line((int) (x), (int) (y), (int) (x + my->count_d[2]), (int) (y + my->count_d[3]), 1, color) != 0) status = 1; if ((my->count[5] >= 30) && (my->count[5] < 60)) { for (i = 1; i < 4; i++) { c = ((double) (60 - my->count[5])) / 30.0; c *= ((double) i) / 4.0; x = my->count_d[4] * (1.0 - c) + my->x * c; y = my->count_d[5] * (1.0 - c) + my->y * c; if (tenm_draw_circle((int) (x), (int) (y), 30, 1, color) != 0) status = 1; } } } /* super blade */ if ((priority == 0) && (my->count[3] >= 4440) && (my->count[3] < 4540)) { i = (my->count[3] - 4440) / 10; theta = i * 36 * 7 + my->count[36]; if (i % 2 == 0) theta += -60 + ((my->count[3] - 4440) % 10) * 12; else theta -= -60 + ((my->count[3] - 4440) % 10) * 12; if (tenm_draw_line((int) (my->x), (int) (my->y), (int) (my->x + 180.0 * tenm_cos(theta)), (int) (my->y + 180.0 * tenm_sin(theta)), 1, tenm_map_color(75, 0, 239)) != 0) status = 1; } /* blade */ if ((priority == 0) && (my->count[6] != 0)) { if (my->count[6] == 1) theta = -90 + my->count[7] * 12; else theta = 90 - my->count[7] * 12; v[0] = my->count_d[2] * 180.0 / 60.0; v[1] = my->count_d[3] * 180.0 / 60.0; result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, theta); if (tenm_draw_line((int) (my->count_d[4]), (int) (my->count_d[5]), (int) (my->count_d[4] + result[0]), (int) (my->count_d[5] + result[1]), 1, tenm_map_color(75, 0, 239)) != 0) status = 1; } /* body */ if (priority == 0) { if (w_ko_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 1) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (tenm_draw_circle((int) (my->x), (int) (my->y), 30, 3, color) != 0) status = 1; } /* hit point stat */ if (priority == 0) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 10, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "w_ko_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int w_ko_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if ((my->count[2] == 0) && (my->count[3] >= 1000) && (my->count[3] < 4600)) return 1; if ((my->count[2] == 1) && (my->count[37] != 0)) return 1; return 0; } static tenm_object * w_ko_cut_new(double dx, double dy, double target_x, double target_y) { tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double length; /* sanity check */ length = tenm_sqrt((int) (dx * dx + dy * dy)); if (length < NEAR_ZERO) { fprintf(stderr, "w_ko_cut_new: (dx, dy) too short\n"); return NULL; } count = (int *) malloc(sizeof(int) * 2); if (count == NULL) { fprintf(stderr, "w_ko_cut_new: malloc(count) failed\n"); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "w_ko_cut_new: malloc(count_d) failed\n"); free(count); return NULL; } /* list of count * [0] color (for delete_enemy_shot) * [1] timer */ /* list of count_d * [0] vector x * [1] vector y */ count[0] = 4; count[1] = 1; count_d[0] = (-dy) / length; count_d[1] = dx / length; /* ATTR_ENEMY_SHOT is only to clear it when the player is killed */ new = tenm_object_new("W-KO cut", ATTR_ENEMY_SHOT, 0, 1, target_x, target_y, 2, count, 2, count_d, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&w_ko_cut_act), (int (*)(tenm_object *, int)) (&w_ko_cut_draw)); if (new == NULL) { fprintf(stderr, "w_ko_cut_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); return NULL; } return new; } static int w_ko_cut_act(tenm_object *my, const tenm_object *player) { /* sanity check */ if (my == NULL) { fprintf(stderr, "w_ko_cut_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[1])++; if (my->count[1] > 27) { tenm_table_add(laser_new(my->x - 810.0 * my->count_d[0], my->y - 810.0 * my->count_d[1], 0.0, 0.0, 1620.0 * my->count_d[0], 1620.0 * my->count_d[1], 4, 1, 0)); return 1; } return 0; } static int w_ko_cut_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; double length; /* sanity check */ if (my == NULL) { fprintf(stderr, "w_ko_cut_draw: my is NULL\n"); return 0; } if (priority == 1) { color = tenm_map_color(118, 99, 158); length = ((double) (my->count[1])) * 30.0; if (length < NEAR_ZERO) length = 1.0; if (tenm_draw_line((int) (my->x - my->count_d[0] * length), (int) (my->y - my->count_d[1] * length), (int) (my->x + my->count_d[0] * length), (int) (my->y + my->count_d[1] * length), 1, color) != 0) status = 1; } return status; } static tenm_object * w_ko_spear_new(double x, double y, double dx, double dy) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double length; /* sanity check */ length = tenm_sqrt((int) (dx * dx + dy * dy)); if (length < NEAR_ZERO) { fprintf(stderr, "w_ko_spear_new: (dx, dy) too short\n"); return NULL; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "w_ko_spear_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 90.0 * dy / length, y - 90.0 * dx / length, x + 180.0 * dx / length, y + 180.0 * dy / length, x - 90.0 * dy / length, y + 90.0 * dx / length, x - 90.0 * dx / length, y - 90.0 * dy / length); if (p[0] == NULL) { fprintf(stderr, "w_ko_spear_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 1); if (count == NULL) { fprintf(stderr, "w_ko_spear_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "w_ko_spear_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] timer */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = 0; count_d[0] = 10.0 * dx / length; count_d[1] = 10.0 * dy / length; new = tenm_object_new("W-KO spear", ATTR_ENEMY | ATTR_OBSTACLE | ATTR_OPAQUE, 0, 1, x, y, 1, count, 2, count_d, 1, p, (int (*)(tenm_object *, double)) (&w_ko_spear_move), (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&w_ko_spear_act), (int (*)(tenm_object *, int)) (&w_ko_spear_draw)); if (new == NULL) { fprintf(stderr, "w_ko_spear_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int w_ko_spear_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "w_ko_spear_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "w_ko_spear_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int w_ko_spear_act(tenm_object *my, const tenm_object *player) { /* sanity check */ if (my == NULL) { fprintf(stderr, "w_ko_spear_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[0])++; if (my->count[0] > 130) return 1; return 0; } static int w_ko_spear_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; /* sanity check */ if (my == NULL) { fprintf(stderr, "w_ko_spear_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; /* decoration */ color = tenm_map_color(218, 184, 177); if (tenm_draw_line((int) (my->x - 90.0 * my->count_d[0] / 10.0), (int) (my->y - 90.0 * my->count_d[1] / 10.0), (int) (my->x - 450.0 * my->count_d[0] / 10.0), (int) (my->y - 450.0 * my->count_d[1] / 10.0), 1, color) != 0) status = 1; /* body */ color = tenm_map_color(95, 13, 68); if (tenm_draw_line((int) (my->x + 90.0 * my->count_d[1] / 10.0), (int) (my->y - 90.0 * my->count_d[0] / 10.0), (int) (my->x + 180.0 * my->count_d[0] / 10.0), (int) (my->y + 180.0 * my->count_d[1] / 10.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x + 180.0 * my->count_d[0] / 10.0), (int) (my->y + 180.0 * my->count_d[1] / 10.0), (int) (my->x - 90.0 * my->count_d[1] / 10.0), (int) (my->y + 90.0 * my->count_d[0] / 10.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 90.0 * my->count_d[1] / 10.0), (int) (my->y + 90.0 * my->count_d[0] / 10.0), (int) (my->x - 90.0 * my->count_d[0] / 10.0), (int) (my->y - 90.0 * my->count_d[1] / 10.0), 3, color) != 0) status = 1; if (tenm_draw_line((int) (my->x - 90.0 * my->count_d[0] / 10.0), (int) (my->y - 90.0 * my->count_d[1] / 10.0), (int) (my->x + 90.0 * my->count_d[1] / 10.0), (int) (my->y - 90.0 * my->count_d[0] / 10.0), 3, color) != 0) status = 1; return status; } static tenm_object * w_ko_lock_on_new(double x, double y, double target_x, double target_y, int what) { tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; /* just to avoid gcc -Wall warning * --- actually, -1.0 is the only _wrong_ value */ double t = -1.0; double c; double temp; /* sanity check */ if ((what < 0) || (what > 1)) { fprintf(stderr, "w_ko_lock_on_new: strange what (%d)\n", what); return NULL; } if ((x - target_x >= -NEAR_ZERO) && (x - target_x <= NEAR_ZERO)) { fprintf(stderr, "w_ko_lock_on_new: too close\n"); return NULL; } count = (int *) malloc(sizeof(int) * 3); if (count == NULL) { fprintf(stderr, "w_ko_lock_on_new: malloc(count) failed\n"); return NULL; } count_d = (double *) malloc(sizeof(double) * 4); if (count_d == NULL) { fprintf(stderr, "w_ko_lock_on_new: malloc(count_d) failed\n"); free(count); return NULL; } if (y > (double) (WINDOW_HEIGHT / 2)) { if ((y > 5.0) && (target_y > 5.0)) { c = 0.0; } else { if (y > target_y) c = target_y - 5.0; else c = y - 5.0; } t = tenm_sqrt((int) (y - c)) + tenm_sqrt((int) (target_y - c)); t *= t; t /= (x - target_x) * (x - target_x); t -= 1.0; temp = 0.5 * (x + target_x - (target_y - y) / ((target_x - x) * (t + 1))); if (((x < temp) && (target_x < temp)) || ((x > temp) && (target_x > temp))) { t = tenm_sqrt((int) (y - c)) - tenm_sqrt((int) (target_y - c)); t *= t; t /= (x - target_x) * (x - target_x); t -= 1.0; } } else { if ((y < ((double) WINDOW_HEIGHT) - 5.0) && (target_y < ((double) WINDOW_HEIGHT) - 5.0)) { c = ((double) WINDOW_HEIGHT) - 5.0; } else { if (y > target_y) c = y + 5.0; else c = target_y + 5.0; } t = tenm_sqrt((int) (c - t)) + tenm_sqrt((int) (c - target_y)); t *= t * (-1.0); t /= (x - target_x) * (x - target_x); t -= 1; temp = 0.5 * (x + target_x - (target_y - y) / ((target_x - x) * (t + 1))); if (((x < temp) && (target_x < temp)) || ((x > temp) && (target_x > temp))) { t = tenm_sqrt((int) (c - y)) - tenm_sqrt((int) (c - target_y)); t *= t * (-1.0); t /= (x - target_x) * (x - target_x); t -= 1.0; } } if ((t - (-1.0) < -NEAR_ZERO) && (t - (-1.0) > NEAR_ZERO)) { fprintf(stderr, "w_ko_lock_on_new: strange t\n"); /* little effect on the gameplay, continue */ } /* list of count * [0] color (for delete_enemy_shot) * [1] timer * [2] what */ /* list of count_d * [0] coefficient of x^2 * [1] coefficient of x^1 * [2] coefficient of x^0 * [3] start point x */ count[0] = 0; count[1] = 0; count[2] = what; count_d[0] = t + 1; count_d[1] = -(t + 1) * (x + target_x) + (target_y - y) / (target_x - x); count_d[2] = (t + 1) * x * target_x + (target_x * y - x * target_y) / (target_x - x); count_d[3] = x; /* ATTR_ENEMY_SHOT is only to clear it when the player is killed */ new = tenm_object_new("W-KO lock on", ATTR_ENEMY_SHOT, 0, 1, target_x, target_y, 3, count, 4, count_d, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&w_ko_lock_on_act), (int (*)(tenm_object *, int)) (&w_ko_lock_on_draw)); if (new == NULL) { fprintf(stderr, "w_ko_lock_on_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); return NULL; } return new; } static int w_ko_lock_on_act(tenm_object *my, const tenm_object *player) { int i; /* sanity check */ if (my == NULL) { fprintf(stderr, "w_ko_lock_on_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[1])++; if (my->count[1] > 30) { for (i = 0; i < 360; i += 60) { tenm_table_add(normal_shot_angle_new(my->x, my->y, 5.5, my->count[2] * 30 + i, 0)); tenm_table_add(normal_shot_angle_new(my->x, my->y, 3.5, my->count[2] * 30 + i, 0)); } return 1; } return 0; } static int w_ko_lock_on_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; int i; double c; double x; double y; /* sanity check */ if (my == NULL) { fprintf(stderr, "w_ko_lock_on_draw: my is NULL\n"); return 0; } if (priority == 1) { color = tenm_map_color(99, 158, 114); for (i = 0; i < 360; i += 120) if (tenm_draw_line((int) (my->x + 25.0 * tenm_cos(-90 + i)), (int) (my->y + 25.0 * tenm_sin(-90 + i)), (int) (my->x + 25.0 * tenm_cos(30 + i)), (int) (my->y + 25.0 * tenm_sin(30 + i)), 1, color) != 0) status = 1; if ((my->count[1] >= 0) && (my->count[1] <= 30)) { c = ((double) (my->count[1])) / 30.0; x = my->count_d[3] * (1.0 - c) + my->x * c; y = my->count_d[0] * x * x + my->count_d[1] * x + my->count_d[2]; if (tenm_draw_circle((int) (x), (int) (y), 5, 1, tenm_map_color(99, 158, 114)) != 0) status = 1; } } return status; } static tenm_object * w_ko_more_1_new(void) { tenm_object *new = NULL; int *count = NULL; count = (int *) malloc(sizeof(int) * 4); if (count == NULL) { fprintf(stderr, "w_ko_more_1_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] life timer * [1] mode * [2] add enemy timer * [3] number of enemies killed/escaped */ count[0] = 0; count[1] = rand() % 4; count[2] = 0; count[3] = 0; /* ATTR_ENEMY is only to clear it when the boss is dead */ new = tenm_object_new("W-KO more 1", ATTR_ENEMY, 0, 1, 0.0, 0.0, 4, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&w_ko_more_1_act), (int (*)(tenm_object *, int)) NULL); if (new == NULL) { fprintf(stderr, "w_ko_more_1_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int w_ko_more_1_act(tenm_object *my, const tenm_object *player) { (my->count[0])++; if ((my->count[0] > 2200) && (my->count[2] > 30)) return 1; if ((my->count[3] >= 4) && (my->count[0] < 2000)) { my->count[1] = rand() % 4; my->count[2] = 0; my->count[3] = 0; } if ((my->count[2] <= 30) && (my->count[2] % 10 == 0)) { switch (my->count[1]) { case 0: tenm_table_add(normal_enemy_new(24.0, -19.0, BALL_SOLDIER, ENEMY_TYPE_WEAK, 0, my->table_index, 3, my->table_index, 3, 1, 1, /* move 0 */ 9999, 0.0, 0.0, 0.0, 0.0, 505.0, -19.0, 0.0, -0.05, 0, /* shoot 0 */ 9999, 99999, 0, 0, 1, 0)); break; case 1: tenm_table_add(normal_enemy_new(616.0, -19.0, BALL_SOLDIER, ENEMY_TYPE_WEAK, 0, my->table_index, 3, my->table_index, 3, 1, 1, /* move 0 */ 9999, 0.0, 0.0, 0.0, 0.0, 135.0, -19.0, 0.0, 0.05, 0, /* shoot 0 */ 9999, 99999, 0, 0, 1, 0)); break; case 2: tenm_table_add(normal_enemy_new(24.0, -19.0, BALL_SOLDIER, ENEMY_TYPE_WEAK, 0, my->table_index, 3, my->table_index, 3, 1, 1, /* move 0 */ 9999, 0.0, 0.0, 0.0, 0.0, 148.0, 74.0, 0.0, -0.15, 0, /* shoot 0 */ 9999, 99999, 0, 0, 1, 0)); break; case 3: tenm_table_add(normal_enemy_new(616.0, -19.0, BALL_SOLDIER, ENEMY_TYPE_WEAK, 0, my->table_index, 3, my->table_index, 3, 1, 1, /* move 0 */ 9999, 0.0, 0.0, 0.0, 0.0, 492.0, 74.0, 0.0, 0.15, 0, /* shoot 0 */ 9999, 99999, 0, 0, 1, 0)); break; default: fprintf(stderr, "w_ko_more_1: undefined mode (%d)\n", my->count[1]); break; } } (my->count[2])++; return 0; } dangen-0.5/spqr/w-ko.h0000644000175000017500000000031210276702741015433 0ustar00ooharaoohara00000000000000/* $Id: w-ko.h,v 1.1 2004/05/12 22:50:43 oohara Exp $ */ #ifndef __DANGEN_W_KO_H__ #define __DANGEN_W_KO_H__ #include "tenm_object.h" tenm_object *w_ko_new(void); #endif /* not __DANGEN_W_KO_H__ */ dangen-0.5/spqr/wall-0.c0000644000175000017500000001070611625011407015644 0ustar00ooharaoohara00000000000000/* $Id: wall-0.c,v 1.5 2011/08/23 20:52:23 oohara Exp $ */ #include /* malloc, rand */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "tenm_table.h" #include "tenm_math.h" #include "wall-0.h" static int wall_0_move(tenm_object *my, double turn_per_frame); static int wall_0_draw(tenm_object *my, int priority); tenm_object * wall_0_new(double x) { double y = -29.0; tenm_primitive **p = NULL; tenm_object *new = NULL; double *count_d = NULL; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "wall_0_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 30.0, y - 30.0, x + 30.0, y + 30.0, x - 30.0, y + 30.0, x - 30.0, y - 30.0); if (p[0] == NULL) { fprintf(stderr, "wall_0_new: cannot set p[0]\n"); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "wall_0_new: malloc(count_d) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count_d * [0] speed x * [1] speed y */ count_d[0] = 0.0; count_d[1] = 4.0; new = tenm_object_new("wall 0", ATTR_OBSTACLE | ATTR_OPAQUE, 0, 1, x, y, 0, NULL, 2, count_d, 1, p, (int (*)(tenm_object *, double)) (&wall_0_move), (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) NULL, (int (*)(tenm_object *, int)) (&wall_0_draw)); if (new == NULL) { fprintf(stderr, "wall_0_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int wall_0_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "wall_0_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "wall_0_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); if (my->y > ((double) WINDOW_HEIGHT) + 31.0) return 1; return 0; } static int wall_0_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; /* sanity check */ if (my == NULL) { fprintf(stderr, "wall_0_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; /* body */ color = tenm_map_color(95, 13, 68); if (tenm_draw_line(((int) (my->x - 30.0)), ((int) (my->y - 30.0)), ((int) (my->x + 30.0)), ((int) (my->y + 30.0)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + 30.0)), ((int) (my->y - 30.0)), ((int) (my->x - 30.0)), ((int) (my->y + 30.0)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + 30.0)), ((int) (my->y - 30.0)), ((int) (my->x + 30.0)), ((int) (my->y + 30.0)), 2, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + 30.0)), ((int) (my->y + 30.0)), ((int) (my->x - 30.0)), ((int) (my->y + 30.0)), 2, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - 30.0)), ((int) (my->y + 30.0)), ((int) (my->x - 30.0)), ((int) (my->y - 30.0)), 2, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - 30.0)), ((int) (my->y - 30.0)), ((int) (my->x + 30.0)), ((int) (my->y - 30.0)), 2, color) != 0) status = 1; return status; } dangen-0.5/spqr/wall-0.h0000644000175000017500000000027610276702741015663 0ustar00ooharaoohara00000000000000/* $Id: wall-0.h,v 1.1 2005/07/10 17:03:09 oohara Exp $ */ #ifndef __DANGEN_WALL_0_H__ #define __DANGEN_WALL_0_H__ tenm_object *wall_0_new(double x); #endif /* not __DANGEN_WALL_0_H__ */ dangen-0.5/spqr/wall-4.c0000644000175000017500000001703711625011443015654 0ustar00ooharaoohara00000000000000/* $Id: wall-4.c,v 1.11 2011/08/23 20:52:51 oohara Exp $ */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "tenm_table.h" #include "tenm_math.h" #include "wall-4.h" static int wall_4_move(tenm_object *my, double turn_per_frame); static int wall_4_act(tenm_object *my, const tenm_object *player); static int wall_4_draw(tenm_object *my, int priority); tenm_object * wall_4_new(double x, double y, double speed_slide, int t_slide, int t_slide_initial) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "wall_4_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 30.0, y - 30.0, x + 30.0, y + 30.0, x - 30.0, y + 30.0, x - 30.0, y - 30.0); if (p[0] == NULL) { fprintf(stderr, "wall_4_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 2); if (count == NULL) { fprintf(stderr, "wall_4_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "wall_4_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] slide timer * [1] t_slide */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = t_slide_initial; count[1] = t_slide; count_d[0] = speed_slide; count_d[1] = 1.0; new = tenm_object_new("wall 4", ATTR_OBSTACLE | ATTR_OPAQUE, 0, 1, x, y, 2, count, 2, count_d, 1, p, (int (*)(tenm_object *, double)) (&wall_4_move), (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&wall_4_act), (int (*)(tenm_object *, int)) (&wall_4_draw)); if (new == NULL) { fprintf(stderr, "wall_4_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int wall_4_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "wall_4_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "wall_4_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; if ((my->count[1] > 0) && (my->count[0] < 0)) dx_temp = 0.0; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); if (my->y > ((double) WINDOW_HEIGHT) + 31.0) return 1; return 0; } static int wall_4_act(tenm_object *my, const tenm_object *player) { /* sanity check */ if (my == NULL) { fprintf(stderr, "wall_13_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[0])++; if ((my->count[1] > 0) && (my->count[0] >= my->count[1])) { my->count[0] = -20; my->count_d[0] *= -1.0; } return 0; } static int wall_4_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; double c; /* sanity check */ if (my == NULL) { fprintf(stderr, "wall_4_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; /* decoration */ color = tenm_map_color(182, 123, 162); if ((my->count[1] > 0) && (my->count[0] < 0)) { c = 30.0 + ((double) (my->count[0])); if (tenm_draw_line(((int) (my->x + c)), ((int) (my->y - c)), ((int) (my->x + c)), ((int) (my->y + c)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + c)), ((int) (my->y + c)), ((int) (my->x - c)), ((int) (my->y + c)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - c)), ((int) (my->y + c)), ((int) (my->x - c)), ((int) (my->y - c)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - c)), ((int) (my->y - c)), ((int) (my->x + c)), ((int) (my->y - c)), 1, color) != 0) status = 1; } /* body */ color = tenm_map_color(95, 13, 68); if (my->count[1] > 0) { if (tenm_draw_line(((int) (my->x + 10.0)), ((int) (my->y - 10.0)), ((int) (my->x + 10.0)), ((int) (my->y + 10.0)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + 10.0)), ((int) (my->y + 10.0)), ((int) (my->x - 10.0)), ((int) (my->y + 10.0)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - 10.0)), ((int) (my->y + 10.0)), ((int) (my->x - 10.0)), ((int) (my->y - 10.0)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - 10.0)), ((int) (my->y - 10.0)), ((int) (my->x + 10.0)), ((int) (my->y - 10.0)), 1, color) != 0) status = 1; } else { if (tenm_draw_line(((int) (my->x - 30.0)), ((int) (my->y - 30.0)), ((int) (my->x + 30.0)), ((int) (my->y + 30.0)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + 30.0)), ((int) (my->y - 30.0)), ((int) (my->x - 30.0)), ((int) (my->y + 30.0)), 1, color) != 0) status = 1; } if (tenm_draw_line(((int) (my->x + 30.0)), ((int) (my->y - 30.0)), ((int) (my->x + 30.0)), ((int) (my->y + 30.0)), 2, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + 30.0)), ((int) (my->y + 30.0)), ((int) (my->x - 30.0)), ((int) (my->y + 30.0)), 2, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - 30.0)), ((int) (my->y + 30.0)), ((int) (my->x - 30.0)), ((int) (my->y - 30.0)), 2, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - 30.0)), ((int) (my->y - 30.0)), ((int) (my->x + 30.0)), ((int) (my->y - 30.0)), 2, color) != 0) status = 1; return status; } dangen-0.5/spqr/wall-4.h0000644000175000017500000000046110276702741015663 0ustar00ooharaoohara00000000000000/* $Id: wall-4.h,v 1.1 2005/06/19 00:53:23 oohara Exp $ */ #ifndef __DANGEN_WALL_4_H__ #define __DANGEN_WALL_4_H__ #include "tenm_object.h" tenm_object *wall_4_new(double x, double y, double speed_slide, int t_slide, int t_slide_initial); #endif /* not __DANGEN_WALL_4_H__ */ dangen-0.5/spqr/wall-8.c0000644000175000017500000001470410276702741015667 0ustar00ooharaoohara00000000000000/* $Id: wall-8.c,v 1.20 2005/01/02 18:26:45 oohara Exp $ */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "tenm_table.h" #include "tenm_math.h" #include "wall-8.h" static int wall_8_move(tenm_object *my, double turn_per_frame); static int wall_8_act(tenm_object *my, const tenm_object *player); static double wall_8_speed(int what, int axis, int t); static int wall_8_draw(tenm_object *my, int priority); tenm_object * wall_8_new(double x, double y, int what, int t) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; int i; /* sanity check */ if ((what < 0) || (what > 3)) { fprintf(stderr, "wall_8_new: strange what (%d)\n", what); return NULL; } if (t < 0) { fprintf(stderr, "wall_8_new: t is negative (%d)\n", t); return NULL; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "wall_8_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 30.0, y - 30.0, x + 30.0, y + 30.0, x - 30.0, y + 30.0, x - 30.0, y - 30.0); if (p[0] == NULL) { fprintf(stderr, "wall_8_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 2); if (count == NULL) { fprintf(stderr, "wall_8_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "wall_8_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] move timer * [1] what */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = t; count[1] = what; for (i = 0; i <= 1; i++) count_d[i] = wall_8_speed(what, i, t); new = tenm_object_new("wall 8", ATTR_OBSTACLE | ATTR_OPAQUE, 0, 1, x, y, 2, count, 2, count_d, 1, p, (int (*)(tenm_object *, double)) (&wall_8_move), (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&wall_8_act), (int (*)(tenm_object *, int)) (&wall_8_draw)); if (new == NULL) { fprintf(stderr, "wall_8_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int wall_8_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "wall_8_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "wall_8_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); if (my->y > ((double) WINDOW_HEIGHT) + 30.0) return 1; return 0; } static int wall_8_act(tenm_object *my, const tenm_object *player) { int i; /* sanity check */ if (my == NULL) { fprintf(stderr, "wall_8_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[0])++; /* speed change */ for (i = 0; i <= 1; i++) my->count_d[i] = wall_8_speed(my->count[1], i, my->count[0]); return 0; } static double wall_8_speed(int what, int axis, int t) { /* sanity check */ if ((axis < 0) || (axis > 1)) { fprintf(stderr, "wall_8_speed: strange axis (%d)\n", axis); return 0.0; } if (axis == 0) { switch (what) { case 0: return 0.0; break; case 1: return 4.0; break; case 2: return -4.0; break; case 3: return 0.0; break; default: fprintf(stderr, "wall_8_speed: undefined what (%d)\n", what); return 0.0; break; } } else { if (what == 3) return 10.0; if ((t >= 2458) && (t < 2533)) return 7.5 - ((double) (t - 2458)) * 0.1; else if ((t >= 2533) && (t < 3490)) return 0.0; else if ((t >= 3490) && (t < 3565)) return ((double) (t - 3490)) * 0.1; return 7.5; } return 0.0; } static int wall_8_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; /* sanity check */ if (my == NULL) { fprintf(stderr, "wall_8_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; /* body */ color = tenm_map_color(95, 13, 68); if (tenm_draw_line(((int) (my->x - 30.0)), ((int) (my->y - 30.0)), ((int) (my->x + 30.0)), ((int) (my->y + 30.0)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + 30.0)), ((int) (my->y - 30.0)), ((int) (my->x - 30.0)), ((int) (my->y + 30.0)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + 30.0)), ((int) (my->y - 30.0)), ((int) (my->x + 30.0)), ((int) (my->y + 30.0)), 2, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + 30.0)), ((int) (my->y + 30.0)), ((int) (my->x - 30.0)), ((int) (my->y + 30.0)), 2, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - 30.0)), ((int) (my->y + 30.0)), ((int) (my->x - 30.0)), ((int) (my->y - 30.0)), 2, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - 30.0)), ((int) (my->y - 30.0)), ((int) (my->x + 30.0)), ((int) (my->y - 30.0)), 2, color) != 0) status = 1; return status; } dangen-0.5/spqr/wall-8.h0000644000175000017500000000036310276702741015670 0ustar00ooharaoohara00000000000000/* $Id: wall-8.h,v 1.3 2004/10/25 12:09:44 oohara Exp $ */ #ifndef __DANGEN_WALL_8_H__ #define __DANGEN_WALL_8_H__ #include "tenm_object.h" tenm_object *wall_8_new(double x, double y, int what, int t); #endif /* not __DANGEN_WALL_8_H__ */ dangen-0.5/spqr/wall-11.c0000644000175000017500000001305110276702741015733 0ustar00ooharaoohara00000000000000/* $Id: wall-11.c,v 1.8 2004/12/12 16:13:15 oohara Exp $ */ #include /* malloc, rand */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "tenm_table.h" #include "tenm_math.h" #include "normal-shot.h" #include "wall-11.h" #define NEAR_ZERO 0.0001 static int wall_11_move(tenm_object *my, double turn_per_frame); static int wall_11_act(tenm_object *my, const tenm_object *player); static int wall_11_draw(tenm_object *my, int priority); tenm_object * wall_11_new(double x, double y, double speed, int theta, int t_shoot) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; int i; double result[2]; double v[2]; double c[10]; double d[10]; /* sanity check */ if (speed < NEAR_ZERO) { fprintf(stderr, "wall_11_new: speed is too small (%f)\n", speed); return NULL; } if (t_shoot <= 0) { fprintf(stderr, "wall_11_new: t_shoot is non-positive (%d)\n", t_shoot); return NULL; } c[0] = 30.0; c[1] = 0.0; c[2] = 20.0; c[3] = 10.0; c[4] = -10.0; c[5] = 10.0; c[6] = -10.0; c[7] = -10.0; c[8] = 20.0; c[9] = -10.0; for (i = 0; i < 5; i++) { v[0] = c[i * 2 + 0]; v[1] = c[i * 2 + 1]; result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, theta); d[i * 2 + 0] = result[0]; d[i * 2 + 1] = result[1]; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "wall_11_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(5, x + d[0], y + d[1], x + d[2], y + d[3], x + d[4], y + d[5], x + d[6], y + d[7], x + d[8], y + d[9]); if (p[0] == NULL) { fprintf(stderr, "wall_11_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 4); if (count == NULL) { fprintf(stderr, "wall_11_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 12); if (count_d == NULL) { fprintf(stderr, "wall_11_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] timer * [1] escape time * [2] shoot time * [3] theta */ /* list of count_d * [0] speed x * [1] speed y * [2 -- 11] mass vertexes */ count[0] = 0; count[1] = ((int) (900.0 / speed)) + 1; if (count[1] < 1) count[1] = 1; count[2] = t_shoot; count[3] = theta; count_d[0] = speed * tenm_cos(theta); count_d[1] = speed * tenm_sin(theta); for (i = 0; i < 10; i++) count_d[2 + i] = d[i]; new = tenm_object_new("wall 11", ATTR_OBSTACLE, 0, 1, x, y, 4, count, 12, count_d, 1, p, (int (*)(tenm_object *, double)) (&wall_11_move), (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&wall_11_act), (int (*)(tenm_object *, int)) (&wall_11_draw)); if (new == NULL) { fprintf(stderr, "wall_11_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int wall_11_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "wall_11_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "wall_11_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int wall_11_act(tenm_object *my, const tenm_object *player) { /* sanity check */ if (my == NULL) { fprintf(stderr, "wall_8_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[0])++; if (my->count[0] >= my->count[1]) return 1; if (my->count[0] % my->count[2] == 0) { tenm_table_add(normal_shot_angle_new(my->x, my->y, 4.5, my->count[3] + 150, 4)); tenm_table_add(normal_shot_angle_new(my->x, my->y, 4.5, my->count[3] - 150, 4)); } return 0; } static int wall_11_draw(tenm_object *my, int priority) { int i; int status = 0; tenm_color color; /* sanity check */ if (my == NULL) { fprintf(stderr, "wall_11_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; /* body */ color = tenm_map_color(95, 13, 68); for (i = 0; i < 5; i++) { if (tenm_draw_line(((int) (my->x + my->count_d[2 + (i * 2 + 0) % 10])), ((int) (my->y + my->count_d[2 + (i * 2 + 1) % 10])), ((int) (my->x + my->count_d[2 + (i * 2 + 2) % 10])), ((int) (my->y + my->count_d[2 + (i * 2 + 3) % 10])), 3, color) != 0) status = 1; } return status; } dangen-0.5/spqr/wall-11.h0000644000175000017500000000044610276702741015744 0ustar00ooharaoohara00000000000000/* $Id: wall-11.h,v 1.2 2004/12/12 16:09:06 oohara Exp $ */ #ifndef __DANGEN_WALL_11_H__ #define __DANGEN_WALL_11_H__ #include "tenm_object.h" tenm_object *wall_11_new(double x, double y, double speed, int theta, int t_shoot); #endif /* not __DANGEN_WALL_11_H__ */ dangen-0.5/spqr/wall-13.c0000644000175000017500000001342111625011502015721 0ustar00ooharaoohara00000000000000/* $Id: wall-13.c,v 1.8 2011/08/23 20:53:22 oohara Exp $ */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "tenm_table.h" #include "tenm_math.h" #include "wall-13.h" static int wall_13_move(tenm_object *my, double turn_per_frame); static int wall_13_act(tenm_object *my, const tenm_object *player); static double wall_13_speed(int axis, int t); static int wall_13_draw(tenm_object *my, int priority); tenm_object * wall_13_new(double x, double y, int t) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; int i; /* sanity check */ if (t < 0) { fprintf(stderr, "wall_13_new: t is negative (%d)\n", t); return NULL; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "wall_13_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_polygon_new(4, x + 30.0, y - 30.0, x + 30.0, y + 30.0, x - 30.0, y + 30.0, x - 30.0, y - 30.0); if (p[0] == NULL) { fprintf(stderr, "wall_13_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 1); if (count == NULL) { fprintf(stderr, "wall_13_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "wall_13_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] move timer */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = t; for (i = 0; i <= 1; i++) count_d[i] = wall_13_speed(i, t); new = tenm_object_new("wall 13", ATTR_OBSTACLE | ATTR_OPAQUE, 0, 1, x, y, 1, count, 2, count_d, 1, p, (int (*)(tenm_object *, double)) (&wall_13_move), (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&wall_13_act), (int (*)(tenm_object *, int)) (&wall_13_draw)); if (new == NULL) { fprintf(stderr, "wall_13_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int wall_13_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "wall_13_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "wall_13_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); if (my->y < -31.0) return 1; return 0; } static int wall_13_act(tenm_object *my, const tenm_object *player) { int i; /* sanity check */ if (my == NULL) { fprintf(stderr, "wall_13_act: my is NULL\n"); return 0; } if (player == NULL) return 0; (my->count[0])++; /* speed change */ for (i = 0; i <= 1; i++) my->count_d[i] = wall_13_speed(i, my->count[0]); return 0; } static double wall_13_speed(int axis, int t) { /* sanity check */ if ((axis < 0) || (axis > 1)) { fprintf(stderr, "wall_13_speed: strange axis (%d)\n", axis); return 0.0; } if (axis == 0) { if (t < 1230) return -1.0; return 0.0; } else { if (t < 1800) return 0.0; return -1.0; } return 0.0; } static int wall_13_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; /* sanity check */ if (my == NULL) { fprintf(stderr, "wall_13_draw: my is NULL\n"); return 0; } if (priority != 0) return 0; /* body */ color = tenm_map_color(95, 13, 68); if (tenm_draw_line(((int) (my->x - 30.0)), ((int) (my->y - 30.0)), ((int) (my->x + 30.0)), ((int) (my->y + 30.0)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + 30.0)), ((int) (my->y - 30.0)), ((int) (my->x - 30.0)), ((int) (my->y + 30.0)), 1, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + 30.0)), ((int) (my->y - 30.0)), ((int) (my->x + 30.0)), ((int) (my->y + 30.0)), 2, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x + 30.0)), ((int) (my->y + 30.0)), ((int) (my->x - 30.0)), ((int) (my->y + 30.0)), 2, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - 30.0)), ((int) (my->y + 30.0)), ((int) (my->x - 30.0)), ((int) (my->y - 30.0)), 2, color) != 0) status = 1; if (tenm_draw_line(((int) (my->x - 30.0)), ((int) (my->y - 30.0)), ((int) (my->x + 30.0)), ((int) (my->y - 30.0)), 2, color) != 0) status = 1; return status; } dangen-0.5/spqr/wall-13.h0000644000175000017500000000035610276702741015746 0ustar00ooharaoohara00000000000000/* $Id: wall-13.h,v 1.1 2005/01/02 18:07:33 oohara Exp $ */ #ifndef __DANGEN_WALL_13_H__ #define __DANGEN_WALL_13_H__ #include "tenm_object.h" tenm_object *wall_13_new(double x, double y, int t); #endif /* not __DANGEN_WALL_13_H__ */ dangen-0.5/spqr/warning.c0000644000175000017500000000435610276702741016232 0ustar00ooharaoohara00000000000000/* $Id: warning.c,v 1.7 2004/08/13 15:31:00 oohara Exp $ */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "tenm_table.h" #include "background.h" #include "tenm_math.h" #include "warning.h" static int warning_act(tenm_object *my, const tenm_object *player); static int warning_draw(tenm_object *my, int priority); tenm_object * warning_new(void) { tenm_object *new = NULL; int *count = NULL; count = (int *) malloc(sizeof(int) * 5); if (count == NULL) { fprintf(stderr, "warning_new: malloc(count) failed\n"); return NULL; } /* list of count * [0] timer */ count[0] = 0; new = tenm_object_new("warning", 0, 0, 1, 0.0, 0.0, 1, count, 0, NULL, 0, NULL, (int (*)(tenm_object *, double)) NULL, (int (*)(tenm_object *, tenm_object *)) NULL, (int (*)(tenm_object *, const tenm_object *)) (&warning_act), (int (*)(tenm_object *, int)) (&warning_draw)); if (new == NULL) { fprintf(stderr, "warning_new: tenm_object_new failed\n"); if (count != NULL) free(count); return NULL; } return new; } static int warning_act(tenm_object *my, const tenm_object *player) { /* sanity check */ if (my == NULL) { fprintf(stderr, "warning_act: my is NULL\n"); return 0; } if (player == NULL) return 0; if ((my->count[0] == 0) || (my->count[0] == 50)) set_background(3); (my->count[0])++; if (my->count[0] >= 100) return 1; return 0; } static int warning_draw(tenm_object *my, int priority) { int status = 0; /* sanity check */ if (my == NULL) { fprintf(stderr, "warning_draw: my is NULL\n"); return 0; } if (priority != 1) return 0; if (draw_string(WINDOW_WIDTH - 1 - my->count[0] * 10, 300, "warning: boss approaching", 25) != 0) { fprintf(stderr, "warning_draw: draw_string failed\n"); status = 1; } return status; } dangen-0.5/spqr/warning.h0000644000175000017500000000033110276702741016224 0ustar00ooharaoohara00000000000000/* $Id: warning.h,v 1.1 2004/08/10 10:28:53 oohara Exp $ */ #ifndef __DANGEN_WARNING_H__ #define __DANGEN_WARNING_H__ #include "tenm_object.h" tenm_object *warning_new(void); #endif /* not __DANGEN_WARNING_H__ */ dangen-0.5/spqr/watcher-below.c0000644000175000017500000006434510276702741017334 0ustar00ooharaoohara00000000000000/* $Id: watcher-below.c,v 1.107 2005/05/03 16:21:43 oohara Exp $ */ /* [easy] Watcher Below */ #include /* malloc, rand */ #include /* strlen, strcmp */ #include #include "const.h" #include "tenm_object.h" #include "tenm_graphic.h" #include "tenm_primitive.h" #include "util.h" #include "player-shot.h" #include "tenm_table.h" #include "background.h" #include "chain.h" #include "laser.h" #include "normal-shot.h" #include "tenm_math.h" #include "fragment.h" #include "explosion.h" #include "stage-clear.h" #include "score.h" #include "watcher-below.h" #define NEAR_ZERO 0.0001 static int watcher_below_move(tenm_object *my, double turn_per_frame); static int watcher_below_hit(tenm_object *my, tenm_object *your); static void watcher_below_next(tenm_object *my); static int watcher_below_signal(tenm_object *my, int n); static int watcher_below_act(tenm_object *my, const tenm_object *player); static int watcher_below_in_territory(double x, double y, double r); static int watcher_below_draw(tenm_object *my, int priority); static int watcher_below_green(const tenm_object *my); static tenm_object *watcher_below_bit_new(double x, double y, double speed_x, double speed_y, int table_index, int what); static int watcher_below_bit_move(tenm_object *my, double turn_per_frame); static int watcher_below_bit_hit(tenm_object *my, tenm_object *your); static void watcher_below_bit_explode(tenm_object *my); static int watcher_below_bit_signal(tenm_object *my, int n); static int watcher_below_bit_act(tenm_object *my, const tenm_object *player); static int watcher_below_bit_draw(tenm_object *my, int priority); static int watcher_below_bit_green(const tenm_object *my); tenm_object * watcher_below_new(void) { int i; tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; double x = (double) (WINDOW_WIDTH / 2); double y = ((double) (WINDOW_HEIGHT / 2)) + 20.0; p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "watcher_below_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_circle_new(x, y, 45.0); if (p[0] == NULL) { fprintf(stderr, "watcher_below_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 9); if (count == NULL) { fprintf(stderr, "watcher_below_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "watcher_below_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] life mode * [3] life timer * [4] number of bits killed * [5 -- 7] bit index * [8] "was green when killed" flag */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 5; count[4] = 0; for (i = 5; i < 8; i++) count[i] = -1; count[8] = 0; count_d[0] = 0.0; count_d[1] = 0.0; new = tenm_object_new("Watcher Below", 0, 0, 600, x, y, 9, count, 2, count_d, 1, p, (int (*)(tenm_object *, double)) (&watcher_below_move), (int (*)(tenm_object *, tenm_object *)) (&watcher_below_hit), (int (*)(tenm_object *, const tenm_object *)) (&watcher_below_act), (int (*)(tenm_object *, int)) (&watcher_below_draw)); if (new == NULL) { fprintf(stderr, "watcher_below_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int watcher_below_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "watcher_below_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "watcher_below_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int watcher_below_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "watcher_below_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "watcher_below_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; if (my->count[2] != 1) return 0; deal_damage(my, your, 0); if (watcher_below_green(my)) add_chain(my, your); my->count[1] = 2; if (my->hit_point <= 0) { add_score(10000); set_background(1); watcher_below_next(my); return 0; } return 0; } static void watcher_below_next(tenm_object *my) { int i; int n; /* sanity check */ if (my == NULL) { fprintf(stderr, "watcher_below_next: my is NULL\n"); return; } /* set "was green" flag before we change the life mode */ if (watcher_below_green(my)) { n = 8; my->count[8] = 1; } else { n = 7; my->count[8] = 0; } tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 5000, n, 10.0, 6)); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy_shot), 0); tenm_table_apply_all((int (*)(tenm_object *, int)) (&delete_enemy), 0); for (i = 5; i < 8; i++) if (my->count[i] >= 0) tenm_table_apply(my->count[i], (int (*)(tenm_object *, int)) (&watcher_below_signal), 0); my->count[2] = 2; my->count[3] = 0; my->count[1] = 0; my->count_d[0] = 0.0; my->count_d[1] = 0.5; my->attr = ATTR_BOSS; my->hit_mask = ATTR_PLAYER_SHOT; tenm_mass_delete(my->mass); my->mass = NULL; } static int watcher_below_signal(tenm_object *my, int n) { /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "Watcher Below bit") != 0) return 0; /* the explosion should be brown since this is a suicide */ my->count[2] = 1; watcher_below_bit_explode(my); return 1; } static int watcher_below_act(tenm_object *my, const tenm_object *player) { int i; int j; int theta; int dtheta; int direction; double x; double y; double dx; double dy; double result[2]; double v[2]; double a[2]; double temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "watcher_below_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; (my->count[3])++; /* dead */ if (my->count[2] == 2) { if (watcher_below_green(my)) i = 8; else i = 7; if ((my->count[3] >= 30) && (my->count[3] <= 75) && (my->count[3] % 15 == 0)) { theta = rand() % 360; tenm_table_add(explosion_new(my->x + 30.0 * tenm_cos(theta), my->y + 30.0 * tenm_sin(theta), 0.0, 0.0, 2, 300, i, 5.0, 8)); } if (my->count[3] > 120) { tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 1, 3000, i, 10.0, 8)); tenm_table_add(explosion_new(my->x, my->y, 0.0, 0.0, 2, 800, i, 6.0, 8)); tenm_table_add(stage_clear_new(100)); return 1; } return 0; } /* phasing */ if (my->count[2] == 1) { if (watcher_below_in_territory(my->x, my->y, 45.0)) { my->attr = ATTR_BOSS; my->hit_mask = ATTR_PLAYER_SHOT; } else { my->attr = 0; my->hit_mask = 0; } } /* add bit */ if ((my->count[2] == 1) && (my->count[3] >= 180) && (my->count[3] <= 300) && (my->count[3] % 60== 0)) { if (my->count[3] == 180) theta = 40; else if (my->count[3] == 240) theta = 155; else theta = 55; x = my->x; y = my->y; if (x - 10.0 < 0.0) x = 10.0; if (x + 10.0 > (double) WINDOW_WIDTH) x = ((double) WINDOW_WIDTH) - 10.0; if (y - 10.0 < 0.0) y = 10.0; if (y + 10.0 > ((double) WINDOW_HEIGHT)) y = ((double) WINDOW_HEIGHT) - 10.0; i = 2 + my->count[3] / 60; my->count[i] = tenm_table_add(watcher_below_bit_new(x, y, 6.0 * tenm_cos(theta), 6.0 * tenm_sin(theta), my->table_index, my->count[3]/60 - 3)); } /* move direction change */ v[0] = my->count_d[0]; v[1] = my->count_d[1]; result[0] = v[0]; result[1] = v[1]; if ((my->count[2] == 1) && (my->x - 10.0 > 0.0) && (my->x + 10.0 < (double) WINDOW_WIDTH) && (my->y - 10.0 > 0.0) && (my->y + 10.0 < (double) WINDOW_HEIGHT)) { if (my->attr != 0) { /* chase player */ v[0] = my->count_d[0]; v[1] = my->count_d[1]; a[0] = player->x - my->x; a[1] = player->y - my->y; result[0] = v[0]; result[1] = v[1]; vector_rotate_bounded(result, v, a, 1); } else if ((my->count_d[0] > 0.0) && (my->count_d[0] < 1.0)) { /* force a good direction */ if (my->count_d[1] > 0.0) vector_rotate(result, v, -1); else vector_rotate(result, v, 1); } else if ((my->count_d[0] > -1.0) && (my->count_d[0] < NEAR_ZERO)) { if (my->count_d[1] > 0.0) vector_rotate(result, v, 1); else vector_rotate(result, v, -1); } else if ((my->count_d[1] > 0.0) && (my->count_d[1] < 1.0)) { if (my->count_d[0] > 0.0) vector_rotate(result, v, 1); else vector_rotate(result, v, -1); } else if ((my->count_d[1] > -1.0) && (my->count_d[1] < NEAR_ZERO)) { if (my->count_d[0] > 0.0) vector_rotate(result, v, -1); else vector_rotate(result, v, 1); } } my->count_d[0] = result[0]; my->count_d[1] = result[1]; /* reflect */ if ((my->x < 0.0) || (my->x > (double) WINDOW_WIDTH)) my->count_d[0] *= -1.0; if ((my->y < 0.0) || (my->y > (double) WINDOW_HEIGHT)) my->count_d[1] *= -1.0; /* encounter */ if (my->count[2] == 0) { if (my->count[3] == 45) { my->count_d[0] = 4.0; my->count_d[1] = 3.0; } if (my->count[3] >= 180) { my->count[2] = 1; my->count[3] = 0; } return 0; } /* self-destruction */ if ((my->count[2] == 1) && (my->count[3] >= 4130)) { set_background(2); clear_chain(); watcher_below_next(my); return 0; } /* shoot */ if (my->attr == 0) return 0; if (my->count[2] != 1) return 0; if (my->count[3] > 4000) return 0; if (((my->count[4] >= 2) && (my->count[3] % 38 == 0)) || ((my->count[4] >= 3) && (my->count[3] % 19 == 0))) { dx = player->x - my->x; dy = player->y - my->y; temp = tenm_sqrt((int) (dx * dx + dy * dy)); if (temp < NEAR_ZERO) temp = 1.0; v[0] = dx / temp; v[1] = dy / temp; result[0] = v[0]; result[1] = v[1]; if (my->count[3] % 38 == 0) vector_rotate(result, v, (60 + rand() % 61) * (2 * (rand() % 2) - 1)); dx = result[0]; dy = result[1]; theta = rand() % 360; if (rand() % 2) direction = 1; else direction = -1; if (rand() % 2) { for (i = 0; i < 3; i++) for (j = 0; j < 4; j++) { dtheta = (i * 120 + j * 30) * direction; x = my->x + 40.0 * tenm_cos(theta + dtheta); y = my->y + 40.0 * tenm_sin(theta + dtheta); dx = 4.0 * result[0]; dy = 4.0 * result[1]; dx -= 0.6 * ((double) (j + 1)) * tenm_cos(theta + dtheta); dy -= 0.6 * ((double) (j + 1)) * tenm_sin(theta + dtheta); tenm_table_add(normal_shot_new(x, y, dx, dy, 1, -2, 0)); } } else { for (i = 0; i < 6; i++) for (j = 0; j < 2; j++) { dtheta = i * 60 + j * 30; if (j == 0) { x = my->x + 40.0 * tenm_cos(theta + dtheta); y = my->y + 40.0 * tenm_sin(theta + dtheta); dx = 3.0 * result[0]; dy = 3.0 * result[1]; dx -= 1.0 * tenm_cos(theta + dtheta); dy -= 1.0 * tenm_sin(theta + dtheta); } else { x = my->x; y = my->y; dx = 3.0 * result[0]; dy = 3.0 * result[1]; dx += 1.0 * tenm_cos(theta + dtheta); dy += 1.0 * tenm_sin(theta + dtheta); } tenm_table_add(normal_shot_new(x, y, dx, dy, 2, -2, 0)); } } } if ((my->count[4] >= 1) && (my->count[3] % 11 == 0)) { dx = my->count_d[0]; dy = my->count_d[1]; temp = tenm_sqrt((int) (dx * dx + dy * dy)); if (temp < NEAR_ZERO) temp = 1.0; v[0] = dx / temp; v[1] = dy / temp; for (i = -1; i <= 1; i += 2) { result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, 120 * i); tenm_table_add(laser_new(my->x, my->y, 7.5 * result[0], 7.5 * result[1], 30.0 * result[0], 30.0 * result[1], 4, -2, 0)); } } return 0; } /* return 1 (true) or 0 (false) */ static int watcher_below_in_territory(double x, double y, double r) { double x1; double y1; /* sanity check */ if (r < NEAR_ZERO) { fprintf(stderr, "watcher_below_in_territory: r is non-positive (%f)\n", r); return 0; } x1 = (x - (double) (WINDOW_WIDTH / 2)) * 7.0 / tenm_sqrt(50) + (y - (double) (WINDOW_HEIGHT / 2)) * (-1.0) / tenm_sqrt(50); y1 = -(x - (double) (WINDOW_WIDTH / 2)) * (-1.0) / tenm_sqrt(50) + (y - (double) (WINDOW_HEIGHT / 2)) * 7.0 / tenm_sqrt(50); if ((x1 - r > -212.1320) && (x1 + r < 212.1320) && (y1 - r > -212.1320) && (y1 + r < 212.1320)) return 1; return 0; } static int watcher_below_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; int width; int r; int c; /* sanity check */ if (my == NULL) { fprintf(stderr, "watcher_below_draw: my is NULL\n"); return 0; } /* territory */ if ((priority == -1) && (((my->count[2] == 0) && (my->count[3] >= 90)) || (my->count[2] == 1))) { c = 0; color = tenm_map_color(182, 147, 123); if (my->count[2] == 0) { color = tenm_map_color(158, 158, 158); c = 180 - my->count[3]; if (c < 0) c = 0; if (c > 90) c = 90; } if (tenm_draw_line((500 * (90 - c) + WINDOW_WIDTH * c) / 90, (0 * (90 - c) + 0 * c) / 90, (560 * (90 - c) + WINDOW_WIDTH * c) / 90, (420 * (90 - c) + WINDOW_HEIGHT * c) / 90, 1, color) != 0) status = 1; if (tenm_draw_line((560 * (90 - c) + WINDOW_WIDTH * c) / 90, (420 * (90 - c) + WINDOW_HEIGHT * c) / 90, (140 * (90 - c) + 0 * c) / 90, (480 * (90 - c) + WINDOW_HEIGHT * c) / 90, 1, color) != 0) status = 1; if (tenm_draw_line((140 * (90 - c) + 0 * c) / 90, (480 * (90 - c) + WINDOW_HEIGHT * c) / 90, (80 * (90 - c) + 0 * c) / 90, (60 * (90 - c) + 0 * c) / 90, 1, color) != 0) status = 1; if (tenm_draw_line((80 * (90 - c) + 0 * c) / 90, (60 * (90 - c) + 0 * c) / 90, (500 * (90 - c) + WINDOW_WIDTH * c) / 90, (0 * (90 - c) + 0 * c) / 90, 1, color) != 0) status = 1; } /* body */ /* dead enemy has low priority */ if (((my->count[2] <= 1) && (priority == 0)) || ((my->count[2] > 1) && (priority == -1))) { if (watcher_below_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 1) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (my->attr != 0) width = 3; else width = 1; r = 45; if (my->count[2] == 0) { r = my->count[3]; if (r < 5) r = 5; if (r > 45) r = 45; } if (tenm_draw_circle((int) (my->x), (int) (my->y), r, width, color) != 0) status = 1; } /* hit point stat */ if ((priority == 0) && (my->count[2] == 1)) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 10, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "watcher_below_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int watcher_below_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if ((my->count[2] == 1) && (my->count[4] >= 3) && (my->count[3] <= 4100)) return 1; if ((my->count[2] == 2) && (my->count[8] != 0)) return 1; return 0; } static tenm_object * watcher_below_bit_new(double x, double y, double speed_x, double speed_y, int table_index, int what) { tenm_primitive **p = NULL; tenm_object *new = NULL; int *count = NULL; double *count_d = NULL; int attr; int hit_mask; /* sanity check */ if (speed_x * speed_x + speed_y * speed_y < NEAR_ZERO) { fprintf(stderr, "watcher_below_bit_new: speed is too small (%f, %f)\n", speed_x, speed_y); return NULL; } if (table_index < 0) { fprintf(stderr, "watcher_below_bit_new: table_index is negative (%d)\n", table_index); return NULL; } p = (tenm_primitive **) malloc(sizeof(tenm_primitive *) * 1); if (p == NULL) { fprintf(stderr, "watcher_below_bit_new: malloc(p) failed\n"); return NULL; } p[0] = (tenm_primitive *) tenm_circle_new(x, y, 25.0); if (p[0] == NULL) { fprintf(stderr, "watcher_below_bit_new: cannot set p[0]\n"); free(p); return NULL; } count = (int *) malloc(sizeof(int) * 6); if (count == NULL) { fprintf(stderr, "watcher_below_bit_new: malloc(count) failed\n"); (p[0])->delete(p[0]); free(p); return NULL; } count_d = (double *) malloc(sizeof(double) * 2); if (count_d == NULL) { fprintf(stderr, "watcher_below_bit_new: malloc(count_d) failed\n"); free(count); (p[0])->delete(p[0]); free(p); return NULL; } if (watcher_below_in_territory(x, y, 25.0)) { attr = ATTR_BOSS; hit_mask = ATTR_PLAYER_SHOT; } else { attr = 0; hit_mask = 0; } /* list of count * [0] for deal_damage * [1] "damaged" timer * [2] life mode * [3] life timer * [4] core index * [5] what */ /* list of count_d * [0] speed x * [1] speed y */ count[0] = 0; count[1] = 0; count[2] = 0; count[3] = 0; count[4] = table_index; count[5] = what; count_d[0] = speed_x; count_d[1] = speed_y; new = tenm_object_new("Watcher Below bit", attr, hit_mask, 200, x, y, 6, count, 2, count_d, 1, p, (int (*)(tenm_object *, double)) (&watcher_below_bit_move), (int (*)(tenm_object *, tenm_object *)) (&watcher_below_bit_hit), (int (*)(tenm_object *, const tenm_object *)) (&watcher_below_bit_act), (int (*)(tenm_object *, int)) (&watcher_below_bit_draw)); if (new == NULL) { fprintf(stderr, "watcher_below_bit_new: tenm_object_new failed\n"); if (count_d != NULL) free(count_d); if (count != NULL) free(count); (p[0])->delete(p[0]); free(p); return NULL; } return new; } static int watcher_below_bit_move(tenm_object *my, double turn_per_frame) { double dx_temp; double dy_temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "watcher_below_bit_move: my is NULL\n"); return 0; } if (turn_per_frame <= 0.5) { fprintf(stderr, "watcher_below_bit_move: strange turn_per_frame (%f)\n", turn_per_frame); return 0; } dx_temp = my->count_d[0] / turn_per_frame; dy_temp = my->count_d[1] / turn_per_frame; my->x += dx_temp; my->y += dy_temp; if (my->mass != NULL) tenm_move_mass(my->mass, dx_temp, dy_temp); return 0; } static int watcher_below_bit_hit(tenm_object *my, tenm_object *your) { /* sanity check */ if (my == NULL) { fprintf(stderr, "watcher_below_bit_hit: my is NULL\n"); return 0; } if (your == NULL) { fprintf(stderr, "watcher_below_bit_hit: your is NULL\n"); return 0; } if (!(your->attr & ATTR_PLAYER_SHOT)) return 0; deal_damage(my, your, 0); if (watcher_below_bit_green(my)) add_chain(my, your); my->count[1] = 41; if (my->hit_point <= 0) { add_score(7500); watcher_below_bit_explode(my); tenm_table_apply(my->count[4], (int (*)(tenm_object *, int)) (&watcher_below_bit_signal), my->table_index); return 1; } return 0; } static void watcher_below_bit_explode(tenm_object *my) { int n; /* sanity check */ if (my == NULL) { fprintf(stderr, "watcher_below_bit_explode: my is NULL\n"); return; } if (watcher_below_bit_green(my)) n = 8; else n = 7; tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 1, 1000, n, 8.0, 6)); tenm_table_add(explosion_new(my->x, my->y, my->count_d[0] * 0.5, my->count_d[1] * 0.5, 2, 300, n, 5.0, 8)); } static int watcher_below_bit_signal(tenm_object *my, int n) { int i; /* sanity check */ if (my == NULL) return 0; if (strcmp(my->name, "Watcher Below") != 0) return 0; (my->count[4])++; for (i = 5; i < 8; i++) if (my->count[i] == n) my->count[i] = -1; return 0; } static int watcher_below_bit_act(tenm_object *my, const tenm_object *player) { int i; double dx; double dy; double result[2]; double v[2]; double temp; /* sanity check */ if (my == NULL) { fprintf(stderr, "watcher_below_bit_act: my is NULL\n"); return 0; } if (player == NULL) return 0; /* for deal_damage */ my->count[0] = 0; /* "damaged" count down */ if (my->count[1] > 0) (my->count[1])--; (my->count[3])++; /* phasing */ if (watcher_below_in_territory(my->x, my->y, 25.0)) { my->attr = ATTR_BOSS; my->hit_mask = ATTR_PLAYER_SHOT; } else { my->attr = 0; my->hit_mask = 0; } /* reflect */ if ((my->x < 0.0) || (my->x > (double) WINDOW_WIDTH)) my->count_d[0] *= -1.0; if ((my->y < 0.0) || (my->y > (double) WINDOW_HEIGHT)) my->count_d[1] *= -1.0; /* shoot */ if (my->attr == 0) return 0; if (my->count[2] != 0) return 0; if ((my->count[3] < 100) || (my->count[3] > 4000 - (my->count[5]*60 + 180))) return 0; if (my->count[3] % 11 == 0) { dx = my->count_d[0]; dy = my->count_d[1]; temp = tenm_sqrt((int) (dx * dx + dy * dy)); if (temp < NEAR_ZERO) temp = 1.0; v[0] = dx / temp; v[1] = dy / temp; for (i = -1; i <= 1; i += 2) { result[0] = v[0]; result[1] = v[1]; vector_rotate(result, v, 120 * i); tenm_table_add(laser_new(my->x, my->y, 4.5 * result[0], 4.5 * result[1], 25.0 * result[0], 25.0 * result[1], 3, -2, 0)); } } if (my->count[3] % 17 == 0) { tenm_table_add(normal_shot_point_new(my->x, my->y, 3.5, player->x, player->y, 5)); } return 0; } static int watcher_below_bit_draw(tenm_object *my, int priority) { int status = 0; tenm_color color; char temp[32]; int width; /* sanity check */ if (my == NULL) { fprintf(stderr, "watcher_below_bit_draw: my is NULL\n"); return 0; } /* decoration */ if ((priority == 0) && (my->count[2] <= 1)) { if (watcher_below_bit_green(my)) { if (my->count[1] >= 40) color = tenm_map_color(181, 190, 92); else color = tenm_map_color(157, 182, 123); } else { if (my->count[1] >= 40) color = tenm_map_color(200, 164, 92); else color = tenm_map_color(182, 147, 123); } } /* body */ if (priority == 0) { if (watcher_below_bit_green(my)) { if (my->count[1] >= 1) color = tenm_map_color(109, 125, 9); else color = tenm_map_color(61, 95, 13); } else { if (my->count[1] >= 1) color = tenm_map_color(135, 89, 9); else color = tenm_map_color(95, 47, 13); } if (my->attr != 0) width = 3; else width = 1; if (tenm_draw_circle((int) (my->x), (int) (my->y), 25, width, color) != 0) status = 1; } /* hit point stat */ if ((priority == 0) && (my->count[1] >= 1)) { sprintf(temp, "%d", my->hit_point); if (draw_string(((int) my->x) - 10, (int) my->y, temp, (int) strlen(temp)) != 0) { fprintf(stderr, "watcher_below_bit_draw: draw_string failed\n"); status = 1; } } return status; } /* return 1 (true) or 0 (false) */ static int watcher_below_bit_green(const tenm_object *my) { /* sanity check */ if (my == NULL) return 0; if ((my->count[2] == 0) && (my->count[3] >= 100) && (my->count[3] <= 4100 - (my->count[5] * 60 + 180))) return 1; return 0; } dangen-0.5/spqr/watcher-below.h0000644000175000017500000000036710276702741017333 0ustar00ooharaoohara00000000000000/* $Id: watcher-below.h,v 1.1 2004/07/14 14:59:08 oohara Exp $ */ #ifndef __DANGEN_WATCHER_BELOW_H__ #define __DANGEN_WATCHER_BELOW_H__ #include "tenm_object.h" tenm_object *watcher_below_new(void); #endif /* not __DANGEN_WATCHER_BELOW_H__ */ dangen-0.5/spqr/image/0000777000175000017500000000000011625724131015473 5ustar00ooharaoohara00000000000000dangen-0.5/spqr/image/Makefile.am0000644000175000017500000000107511624751043017527 0ustar00ooharaoohara00000000000000## Makefile.am for dangen/spqr/image ## process this file with automake --foreign to generate Makefile.in # $Id: Makefile.am,v 1.15 2011/08/23 16:15:31 oohara Exp $ EXTRA_DIST = font.png \ font-medium.png \ font-terminus.png install-data-local: $(mkinstalldirs) $(DESTDIR)$(datadir)/games/dangen/image/ $(INSTALL_DATA) $(top_srcdir)/spqr/image/font.png \ $(DESTDIR)$(datadir)/games/dangen/image/ uninstall-local: -rm -f $(DESTDIR)$(datadir)/games/dangen/image/font.png -rmdir $(DESTDIR)$(datadir)/games/dangen/image/ -rmdir $(DESTDIR)$(datadir)/games/dangen/ dangen-0.5/spqr/image/Makefile.in0000644000175000017500000002212011624751772017543 0ustar00ooharaoohara00000000000000# Makefile.in generated by automake 1.11 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # $Id: Makefile.am,v 1.15 2011/08/23 16:15:31 oohara Exp $ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : subdir = spqr/image DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build_alias = @build_alias@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ EXTRA_DIST = font.png \ font-medium.png \ font-terminus.png all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign spqr/image/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign spqr/image/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): tags: TAGS TAGS: ctags: CTAGS CTAGS: distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-data-local install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-local .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic distclean \ distclean-generic distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am \ install-data-local install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ pdf-am ps ps-am uninstall uninstall-am uninstall-local install-data-local: $(mkinstalldirs) $(DESTDIR)$(datadir)/games/dangen/image/ $(INSTALL_DATA) $(top_srcdir)/spqr/image/font.png \ $(DESTDIR)$(datadir)/games/dangen/image/ uninstall-local: -rm -f $(DESTDIR)$(datadir)/games/dangen/image/font.png -rmdir $(DESTDIR)$(datadir)/games/dangen/image/ -rmdir $(DESTDIR)$(datadir)/games/dangen/ # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: dangen-0.5/spqr/image/font.png0000644000175000017500000000302110276702741017143 0ustar00ooharaoohara00000000000000PNG  IHDRW8ݳbKGDC pHYs CfStIME(iIDATxے ־OU"Ӗ|WӉ E<^})u=XqD} pu]!8L!g58qf|}gCo|o}A3$ill)x1&ے"j`ҙ>REVs DR@$+ (Y+\@!zI]6Ri78MJ |IE@ (e*8ΝZ^nH c k}S:sn E6`,8nBf7| NI7@BgX]'ǗY )R<_[SZTy'qbȱ` `C'e,#>{#Z̤@ӥx[ d9'ň2fԷCj׃mp0ْ5v/08Hop*]Jsݺ#o &*^X0r^80D8ON!5n-xU>'+Gq"M@Dgc n^ "/dZ l۪%@OB|2/ՕORW?2d bS4S:&RJ[TuKAF)G+ .ށ35gۺ^ ^uM-պ@Q*jBo{o\"헪N78Re71:"r "!2EfppF*!Z@I[DnWU⺘_,fkA."-eAlM0Lw5mp*En2l7©ȵQ|v{G !Z eS,] -/MM@]WiW1fݯy`WyqEs3m޾ykX֋8\=po PXн@0KfwVj>OK# #U)rNQdȸ—3'ޢ6g{I[ĩN< 1`QeW:]Ļ;hq(1Y'???Ur6ww @ˡ*p PWxD+.8djuȝb/u]$S·d =MAPZ%W5VCʴȌQAr<_JUYhU- W+ ;J0lGqfQGSE%6(*c]S^╍:( ztqHe8G2^jS$jU,U| fiIENDB`dangen-0.5/spqr/image/font-medium.png0000644000175000017500000000312210276702741020423 0ustar00ooharaoohara00000000000000PNG  IHDRW8ݳbKGD pHYs  d_tIME  $V IDATx۲ E_REVs DR@$+ (Y+\@!zI]6Ri78MJ |IE@ (e*8ΝZ^nH c k}S:sn E6`,8nBf7| NI7@BgX]'ǗY )R<_[SZTy'qbȱ` `C'e,#>{#Z̤@ӥx[ d9'ň2fԷCj׃mp0ْ5v/08Hop*]Jsݺ#o &*^X0r^80D8ON!5n-xU>'+Gq"M@Dgc n^ "/dZ l۪%@OB|2/ՕORW?2d bS4S:&RJ[TuKAF)G+ .ށ35gۺ^ ^uM-պ@Q*jBo{o\"헪N78Re71:"r "!2EfppF*!Z@I[DnWU⺘_,fkA."-eAlM0Lw5mp*En2l7©ȵQ|v{G !Z eS,] -/MM@]WiW1fݯy`WyqEs3m޾ykX֋8\=po PXн@0KfwVj>OK# #U)rNQdȸ—3'ޢ6g{I[ĩN< 1`QeW:]Ļ;hq(1Y'???Ur6ww @ˡ*p PWxD+.8djuȝb/u]$S·d =MAPZ%W5VCʴȌQAr<_JUYhU- W+ ;J0lGqfQGSE%6(*c]S^╍:( ztqHe8G2^jS$jU,U| fiIENDB`