示例#1
0
文件: main.go 项目: ptrr/HeatSeeker
func update() {
	if (go2d.GetTicks() - ticker) >= 100 {
		for i := 0; i < len(humans); i++ {
			if humans[i].x >= 500 && humans[i].x <= 600 && hatchOpen {
				humans[i].y += 20
				if humans[i].y >= SCREEN_HEIGHT {
					hatchOpen = false
					currentDiseases = make([]*Disease, 0)
					removeHuman(i)
					NewHuman()
					break
				}
				continue
			}
			if humans[i].x >= 150 && humans[i].x <= 230 {
				temp_head = 34 + rand.Intn(7)
				temp_upper = 34 + rand.Intn(7)
				temp_lower = 34 + rand.Intn(7)
			}
			if humans[i].x >= 320 && humans[i].x <= 400 {
				country := countries[rand.Intn(len(countries))]
				if country != nil {
					currentCountry = country
					setDiseases()
				}
			}
			if humans[i].x >= 500 && humans[i].x <= 600 {
				if len(currentDiseases) > 0 {
					for _, dis := range currentDiseases {
						for _, epi := range epidemics {
							if dis.name == epi {
								hatchOpen = true
								//goto is bad? http://kerneltrap.org/node/553/2131
								goto thebatmobile
							}
						}
					}
				thebatmobile:
				}
			}

			humans[i].x += 10

			if humans[i].frame+1 < len(humans[i].frames) {
				humans[i].frame++
			} else {
				humans[i].frame = 0
			}

			if humans[i].x >= SCREEN_WIDTH {
				removeHuman(i)
				NewHuman()
				break
			}
		}
		ticker = go2d.GetTicks()
	}
}
示例#2
0
文件: main.go 项目: ptrr/HeatSeeker
	//www.github.com/urmel/go2d
	"go2d"
	"rand"

	"io/ioutil"
	"json"
	"time"
	//"os"
)

const (
	SCREEN_WIDTH  = 800
	SCREEN_HEIGHT = 600
)

var ticker uint32 = go2d.GetTicks()
var humans []*Human = make([]*Human, 0)
var font *go2d.Font
var borden [5]*go2d.Image
var hatchOpen bool = false

var temp_head int = 0
var temp_upper int = 0
var temp_lower int = 0

var epidemics [4]string

var currentCountry *Country
var currentDiseases []*Disease
var currentEnv *Env