skymonsters_Ksさんが投稿したコード一覧

HSP HSPプログラムコンテストの作品をリスト&カウント

#include "hspinet.as"

#define URL_BASE "http://dev.onionsoft.net/seed/info.ax?id="

	netinit
	if stat : dialog "connection error" : end

	; 年度
	year = "2017" ; 2012年より前は非対応

	; 部門
	category = "n", "s", "d"
	cate_name = "一般", "HSPTV", "Dish"

	sdim listBuf, 32000

	neturl "http://hsp.tv/contest" + year + "/"

	num_str = "("
	num_total = 0
	foreach category : cate_id = cnt
		num_cate(cate_id) = 0
		repeat , 1
			fn = "list_" + category(cate_id) + cnt + ".html"
			request fn
			if stat : break
			title "downloading " + fn
			gosub *downloadLoop
			gosub *getWork
		loop
		num_str += strf("%s:%d, ", cate_name(cate_id), num_cate(cate_id))
	loop
	poke num_str, strlen(num_str) - 2
	title strf("作品数:%d %s)", num_total, num_str)
	objsize 640, 480
	listbox listid, 0, listBuf
	notesel listBuf
	onkey gosub *inKey
	stop

*inKey
	if lparam >> 30 : return
	if wparam == 13 { ; Enter
		noteget ts, listid
		getstr id, ts, 1, ':'
		exec URL_BASE + int(id), 16
	}
	return

#deffunc request str _fn
	netfileinfo info, _fn
	if stat {
		dialog "info error"
		end
	}
	getstr ts, info
	if instr(ts, 0, "404") >= 0 {
		return 1
	}
	netrequest_get _fn
	return 0

*downloadLoop
	netexec res
	if res < 0 {
		neterror estr
		dialog "download error: " + estr
		end
	}
	if res > 0 {
		netgetv buf
		return
	}
	await 50
	goto *downloadLoop

*getWork
	pt = instr(buf, 0, "<!--段落始まり-->")
	repeat
		t = instr(buf, pt, "<a name=")
		if (t < 0) : break
		pt += t
		getstr id, buf, pt + 9, '\"'
		url = URL_BASE + id
		pt += instr(buf, pt, url)
		getstr name, buf, pt + strlen(url) + 2, '<'
		listBuf += strf("#%05d: %s\n", id, name)
		num_total++
		num_cate(cate_id)++
	loop
return

HSP HGIMG3でテクスチャのUV座標を変化させてスクロール

; HSP 3.4
#include "hgimg3.as"

	hgini

	setfont 16, 16, 12, 1
	texload dir_exe + "/sample/hgimg3/fontchr.bmp"

	texload dir_exe + "/hsptv/hsptv_img.bmp"
	addplate id, 0, 400, 300, 0, 0, 120, 90, stat
	regobj bg, id
	setpos bg, , , -300

	setcolor 250, 250, 100
	addbox id, 10, 10
	regobj box, id

	clscolor $000080

*mainLoop

	delevent ev
	newevent ev
	event_uv ev, sin(0.022 * frm) * 100, cos(0.033 * frm) * 100
	setevent bg, ev

	setang bg, sin(0.0045 * frm), cos(0.0067 * frm), sin(0.0089 * frm)
	addang box, 0.02, 0.03, 0.04

	hgdraw

	fprt "" + frm, 10, 10

	hgsync 16

	frm++

	goto *mainLoop

HSP Aeroの有無で描画見た目がどう変わるかのテスト

; HSP 3.4
#uselib "dwmapi"
#func DwmEnableComposition "DwmEnableComposition" int

	if (varptr(DwmEnableComposition) == 0) {
		dialog "Aero非対応です"
		end
	}
	c = "Aero OFF", "Aero ON"
	f = 1
	button gosub c, *btn
*mainLoop
	redraw 0
	color 255, 255, 255
	boxf
	color
	x = cos(0.04 * t) * 200 + 320
	y = sin(0.04 * t) * 200 + 240
	s = 10
	circle x - s, y - s, x + s, y + s
	if (t & 1) {
		x = 320
		y = 240
		s = 60
		circle  x - s, y - s, x + s, y + s
	}
	t++
	redraw
	await 20
	goto *mainLoop
*btn
	f ^= 1
	DwmEnableComposition f
	objprm 0, c
	return

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

	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

HSP 時間内にミスなくアローキーを押すゲーム「Arrows Attack」

	buffer 1, 800, 200
	font msgothic, 200, 16
	mes "←↑→↓"
	arrow = 1, 2, 4, 8
	celdiv 1, 200, , 100, 100
	gsel
	font "arial", 30, 16
	scene = 1
*mainLoop
	stick key
	if (scene) {
		if (key & 16) {
			scene = 0
			gosub *initGame
		}
	} else {
		if (key & 15) {
			if (key == arrow(nowNo)) {
				score++
				nowNo = rnd(4)
				arrowAni = 4
			} else {
				scene = 2
			}
		}
	}
	redraw 0
	color 255, 255, 255
	boxf
	if (scene != 1) {
		pos 320, 240
		arrowAni -= arrowAni > 0
		celput 1, nowNo, 0.2 * arrowAni + 1, 0.2 * arrowAni + 1
	}
	color
	pos 100, 230
	mes score
	pos 480, 230
	mes strf("%2.2f", double(remain) / 66)
	if (scene == 1) {
		pos 230, 80
		mes "Arrows Attack"
	}
	if (scene == 2) {
		pos 285, 80
		mes "Miss!"
	}
	if (scene == 3) {
		pos 250, 80
		mes"Time's up!"
	}
	if (scene) {
		pos 170, 380
		mes "SPACE key to START"
	}
	redraw
	await 15
	if (scene == 0) {
		remain--
		if (remain == 0) {
			scene = 3
		}
	}
	goto *mainLoop
*initGame
	randomize
	nowNo = rnd(4)
	remain = 66 * 10
	arrowAni = 4
	dim score
	return

HSP フォントをストローク描画

#include "gdi32.as"
#define ctype RGB(%1,%2,%3) (%1|(%2<<8)|(%3<<16))

a = "Good night ☆ zzz..."

gradf ,,,, 1, $000033, $000088

font msgothic, 50

CreatePen 0, 2, RGB(200, 200, 100) ; 線の種類、幅、色を設定できる
pen = stat
SelectObject hdc, pen

BeginPath hdc
TextOut hdc, 50, 50, a, strlen(a) ; 描画座標はここで
EndPath hdc
StrokePath hdc

redraw 1
DeleteObject pen

よく投稿されているコード

タグ

最近投稿されたコード