-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfireball.wl
51 lines (40 loc) · 927 Bytes
/
fireball.wl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use "importc"
import(C) "/usr/include/SDL/SDL.h"
import(C) "/usr/include/stdio.h"
import(C) "/usr/include/stdlib.h"
import "sprite.wl"
import "list.wl"
import "main.wl"
import "particle.wl"
import "halo.wl"
Sprite^ fireballSprite = null
Particle^ fireball_new(float x, float y)
{
if(fireballSprite == null)
{
fireballSprite = sprite_new("res/fireball.png")
}
Particle^ fb = particle_new(x, y, 0, 10)
return fb
}
bool fireball_update(Particle^ fb)
{
fb.y = fb.y - 5.0
float r = rand()
r = r / float: RAND_MAX
if(r < 0.1)
{
frag_new(fb.x, fb.y)
}
return (fb.y > 300.0 ||
fb.y < 0.0 - 50.0 ||
fb.x < 0.0 - 50.0 ||
fb.x > 350.0)
}
void fireball_draw(Particle^ fb, SDL_Surface^ dst, SDL_Surface^ lit)
{
fireballSprite.x = fb.x
fireballSprite.y = fb.y
sprite_draw(dst, fireballSprite)
halo_draw(lit, 4, fb.x, fb.y)
}