☆集めゲーム「Star: The Gathering」

短時間?ゲーム制作その2。制作時間4時間…HSP 3.4β2, Win XP で動作確認しています。

短時間?ゲーム制作その2。制作時間4時間…HSP 3.4β2, Win XP で動作確認しています。

  • タグ:
  • タグはありません
	sz = 32
	buffer 1, sz, sz
	font msgothic, sz
	color
	boxf
	color 255, 255, 255
	mes "☆"
	gsel
	title "Star: The Gathering"
	celdiv 1, , , sz / 2, sz / 2
	starNum = 100
	font "arial", 24
*init
	ddim starPosX, starNum
	ddim starPosY, starNum
	ddim starPosX, starNum
	ddim starVelY, starNum
	repeat starNum
		genStar cnt
	loop
	dim gstarLife, starNum
	ddim gstarPosX, starNum
	ddim gstarPosY, starNum
	circleSize = 0.0
*mainLoop
	stick key, 256
	if (scene) {
		if (key & 256) {
			mlbDown = 1
			circleSize += 1.0
			if (circleSize > 120) {
				circleSize = 120.0
			}
		} else {
			if (mlbDown) {
				gatherNum = 0
				repeat starNum
					x = mousex - starPosX(cnt)
					y = mousey - starPosY(cnt)
					if (sqrt(x * x + y * y) <= circleSize) {
						score++
						gstarLife(gsIdx) = 10
						gstarPosX(gsIdx) = starPosX(cnt)
						gstarPosY(gsIdx) = starPosY(cnt)
						gsIdx = (gsIdx + 1) \ starNum
						genStar cnt
					}
				loop
			}
			mlbDown = 0
			circleSize = 0.0
		}
		if (key & 128) {
			scene = 0
		}
	} else {
		if (key & 16) {
			score = 0
			remain = 66 * 30
			scene = 1
			goto *init
		}
	}
	repeat starNum
		starPosX(cnt) += starVelX(cnt)
		starPosY(cnt) += starVelY(cnt)
		starVelX(cnt) *= 0.998
		starVelY(cnt) *= 0.998
		if (starPosX(cnt) < 0) {
			starPosX(cnt) = -starPosX(cnt)
			starVelX(cnt) = -starVelX(cnt)
		}
		if (starPosX(cnt) > 640) {
			starPosX(cnt) = 1280.0 - starPosX(cnt)
			starVelX(cnt) = -starVelX(cnt)
		}
		if (starPosY(cnt) < 0) {
			starPosY(cnt) = -starPosY(cnt)
			starVelY(cnt) = -starVelY(cnt)
		}
		if (starPosY(cnt) > 480) {
			starPosY(cnt) = 960.0 - starPosY(cnt)
			starVelY(cnt) = -starVelY(cnt)
		}
	loop
	repeat starNum
		if (gstarLife(cnt) > 0) {
			gstarLife(cnt)--
		}
	loop
	redraw 0
	color
	boxf
	gmode 2
	repeat starNum
		pos starPosX(cnt), starPosY(cnt)
		celput 1
	loop
	repeat starNum
		if (gstarLife(cnt) > 0) {
			pos gstarPosX(cnt), gstarPosY(cnt)
			gmode 5, , , gstarLife(cnt) * 30 + 40
			s = 0.4 * (7 - gstarLife(cnt)) + 1
			celput 1, , s, s
		}
	loop
	if (scene) {
		color 255, 255, 255
		circle mousex - circleSize, mousey - circleSize, mousex + circleSize, mousey + circleSize, 0
	}
	gmode 3, , , 200
	color
	grect 320, 15, , 200, 30
	color 255, 255, 255
	pos 270, 0
	mes strf("%3d", score)
	pos 340, 0
	mes strf("%2.1f", double(remain) / 66)
	if (scene = 0) {
		color
		grect 340, 250, , 340, 160
		color 255, 255, 255
		pos 200, 200
		mes "Star: The Gathering"
		mes ""
		mes "Space key: start"
		mes "Mouse Left button: gather"
	}
	redraw
	await 15
	if (scene) {
		remain--
		if (remain == 0) {
			scene = 0
		}
	}
	goto *mainLoop

#deffunc genStar int _id
	starPosX(_id) = double(rnd(640))
	starPosY(_id) = double(rnd(480))
	starVelX(_id) = (double(rnd(100)) / 10) * (rnd(2) * 2 - 1)
	starVelY(_id) = (double(rnd(100)) / 10) * (rnd(2) * 2 - 1)
	return