Skip to content

Commit

Permalink
Create Arrow.osl
Browse files Browse the repository at this point in the history
  • Loading branch information
Mistium authored Nov 18, 2024
1 parent a901e8e commit bcbf41c
Showing 1 changed file with 143 additions and 0 deletions.
143 changes: 143 additions & 0 deletions all/arrow/Arrow.osl
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
github = "https://raw.githubusercontent.com/RoturTW/apps/main/all/arrow/"
player_eye = github ++ "assets/Player/Eye.svg"
player_body = github ++ "assets/Player/White.svg"
player_blue = github ++ "assets/Player/Blue.svg"

arrow_main = github ++ "assets/Arrow/Main.svg"
arrow_charged = github ++ "assets/Arrow/Charged.svg"

map_main = github ++ "assets/Map/Main.svg"

player = {
"dir":90,
"tdir":90,
"x":0,
"y":0,
"xvel":0,
"yvel":0
}

mouse_down_start = timer

arrows = []
load_queue = []

def "load" "url" (
load_queue.append(url)
)

def "move" "this.dist" (
change direction.sin * this.dist direction.cos * this.dist
)

def "create_arrow" "this.x, this.y ,this.dir, this.vel" (
this.obj = {}
this.obj.x = this.x + (this.dir.sin * this.vel * 2)
this.obj.y = this.y + (this.dir.cos * this.vel * 2)
this.obj.vel = this.vel
this.obj.dir = this.dir
arrows.append(this.obj)
)

def "movement" "this.speed" (
if "d".pressed (
player.xvel += this.speed
)
if "a".pressed (
player.xvel -= this.speed
)
if "w".pressed (
player.yvel += this.speed
)
if "s".pressed (
player.yvel -= this.speed
)
player.x += player.xvel
player.y += player.yvel
player.xvel *= 0.8
player.yvel *= 0.8

this.d = dist(0,0,player.x,player.y) - 1730
if this.d > 0 (
pointat -player.x -player.y
player.x += direction.sin * this.d
player.y += direction.cos * this.d
)
)

for i 11 (
load github ++ "assets/Charge/" ++ i ++ ".svg"
)

load github ++ "assets/Enemy/Body.svg"
load player_blue
load player_body
load player_eye
load map_main
load arrow_main
load arrow_charged

per = 0
s = 0.7
mainloop:

import "win-buttons"

if load_queue.len > 0 (
for i load_queue.len (
image load_queue[i] 0 0
)
if load_queue[1].imageinfo("loaded") (
load_queue.delete(1)
)
exit
)

goto -player.x * s -player.y * s
image map_main 4050 * s

movement 1
goto 0 0
pointat player.xvel player.yvel
image player_blue 50 * s
image player_body 40 * s
stretch [100,100]
pointat mouse_x mouse_y
move 40 * s
image player_eye 90 * s
move 30 * s
image github ++ "assets/Charge/" ++ (per * 10 + 1).floor() ++ ".svg" 25 * s
move -30 * s

if mouse_down (
dif = (timer - mouse_down_start * 2000).clamp(0,300)
per = dif / 300
move 50 - (dif * s / 10)
image per == 1 ? arrow_charged arrow_main 90 * s
arrow_charging = true
) else (
if per * 11 > 3 (
create_arrow player.x player.y direction per * 33
)
per = 0
mouse_down_start = timer
)

arrows_del = []
for i arrows.len (
arrow = arrows[i]
arrow.x += arrow.dir.sin * arrow.vel
arrow.y += arrow.dir.cos * arrow.vel
direction arrow.dir
goto player.x - arrow.x * -s player.y - arrow.y * -s
if dist(x_position,y_position,0,0) > (4000 * s) (
arrows_del.append(i)
)
image arrow_main 90 * s
arrows[i] = arrow
)
offset = 0
each i arrows_del (
arrows.delete(i - offset)
offset -= 1
)

0 comments on commit bcbf41c

Please sign in to comment.