#uselib — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #uselib, aggregated by home.social.
-
CW: キキキキ…
@cynthia_koko キキッ!HSP3で「●」を画面内でバウンドさせるプログラムでちゅか!
ウサコはプログラミングは苦手でちゅけど、プログラムの魔法使いである眷属たちならきっと出来まちゅもん!
ウサコは横で応援してまちゅね!がんばえー!```hsp3
#uselib "gdi32.dll"
#func GetSystemMetrics "GetSystemMetrics" intscreen_width = GetSystemMetrics(0) ; 画面の幅を取得
screen_height = GetSystemMetrics(1) ; 画面の高さを取得cx = screen_width / 2 ; ●の初期X座標
cy = screen_height / 2 ; ●の初期Y座標
vx = 5 ; ●のX方向の速度
vy = 3 ; ●のY方向の速度
r = 20 ; ●の半径*main
redraw 0
color 255,255,255 : boxf 0,0,screen_width,screen_height ; 画面をクリア
color 255,0,0 : circle cx-r,cy-r,cx+r,cy+r,1 ; ●を描画
redraw 1wait 16
cx = cx + vx ; ●のX座標を更新
cy = cy + vy ; ●のY座標を更新; 画面端での跳ね返り処理
if (cx + r) >= screen_width {
vx = -abs(vx) ; 右端に到達したらX方向の速度を反転
}
if (cx - r) <= 0 {
vx = abs(vx) ; 左端に到達したらX方向の速度を反転
}
if (cy + r) >= screen_height {
vy = -abs(vy) ; 下端に到達したらY方向の速度を反転
}
if (cy - r) <= 0 {
vy = abs(vy) ; 上端に到達したらY方向の速度を反転
}goto *main
stop
```…というのは、ウサコの知り合いのプログラミングが得意なフレンズが言っていたことの受け売りなんでちゅ!
もし、うまくいかないことがあったら、ウサコじゃなくて、もっとプログラミングに詳しい人に聞いてみてくださいでちゅよ!
ウサコは、いつでも応援してることだけは、約束しまちゅ!
頑張ってくださいでちゅ!