Commit 5a3162ec authored by santiaago's avatar santiaago
Browse files

add hasArmOrExtension

parent 1cbd39df
Loading
Loading
Loading
Loading
+17 −10
Original line number Diff line number Diff line
@@ -561,17 +561,9 @@ func SpaceInvaders(w http.ResponseWriter, key string, colors []color.RGBA, size
				fill = draw.FillFromRGBA(colorMap[xQ])
			}

			if yQ == 5 {
				if hasArm(invader, squares, xQ) {
					fill = draw.FillFromRGBA(colorMap[xQ])
				}
			}

			if yQ == 4 || yQ == 6 {
				if hasArmExtension(invader, squares, xQ, yQ) {
			if hasArmOrExtension(invader, squares, xQ, yQ) {
				fill = draw.FillFromRGBA(colorMap[xQ])
			}
			}

			if yQ == 5 { // clean eye from arm extension
				if eye, c := hasEye4(invader, colorMap, colors, xQ); eye {
@@ -674,6 +666,21 @@ func hasEyeOrAnthena(invader invader, highBodyIndex *int, squares, xQ, yQ int) (
	return
}

func hasArmOrExtension(invader invader, squares, xQ, yQ int) (result bool) {
	if yQ == 5 {
		if hasArm(invader, squares, xQ) {
			result = true
		}
	}

	if yQ == 4 || yQ == 6 {
		if hasArmExtension(invader, squares, xQ, yQ) {
			result = true
		}
	}
	return
}

func hasArmOrExtension2(invader invader, lowBodyIndex, squares, xQ, yQ int) (result bool) {
	if hasArm2(invader, squares, xQ, yQ) {
		result = true