changeset 7:3ed112d64b1b

Added basic creep spawning code
author Mike Pavone <pavone@retrodev.com>
date Sun, 12 Jan 2014 15:22:22 -0800
parents d73f53857e5f
children 2fde9ab7308f
files src/creep.h src/main.c
diffstat 2 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/creep.h	Sun Jan 12 13:55:54 2014 -0800
+++ b/src/creep.h	Sun Jan 12 15:22:22 2014 -0800
@@ -12,4 +12,8 @@
 	u8   direction;
 } creep;
 
+#define MAX_CREEPS 40
+extern u16 cur_creeps;
+u16 spawn_creep(u8 species, s16 x, s16 y);
+
 #endif //CREEP_H_
--- a/src/main.c	Sun Jan 12 13:55:54 2014 -0800
+++ b/src/main.c	Sun Jan 12 15:22:22 2014 -0800
@@ -2,6 +2,7 @@
 #include "creep.h"
 
 u16 tilemap[40*28];
+u16 countdown;
 
 int main(void)
 {
@@ -26,6 +27,16 @@
 		{
 			VDP_setTileMapRectByIndex(VDP_PLAN_B, tilemap + i*40, i*64, 40, 0);
 		}
+		if (cur_creeps < 4)
+		{
+			if (countdown)
+				--countdown;
+			else
+			{
+				spawn_creep(CREEP_NORMAL, 4, 122);
+				countdown = 300;
+			}
+		}
 	}
 	return 0;
 }