This commit is contained in:
Fabien Freling 2021-08-10 16:53:55 +02:00
parent 26599cf0e9
commit f4daf5a0b0

View file

@ -26,7 +26,7 @@ class Star {
TIC.circ(_x, _y, _size, _color)
}
isPassed {
expired {
_x + _size < 0
}
}
@ -45,6 +45,10 @@ class Bullet {
draw() {
TIC.rect(_x, _y, 3, 1, 4)
}
expired {
_x > W
}
}
class Ship {
@ -68,6 +72,8 @@ class Ship {
if (TIC.btn(3)) {
_x = _x + _speed
}
_x.clamp(0, W)
_y.clamp(0, H)
if (TIC.btnp(4, 5, 10)) {
shoot()
@ -76,6 +82,9 @@ class Ship {
for (b in _bullets) {
b.update()
}
while (_bullets.count > 0 && _bullets[0].expired) {
_bullets.removeAt(0)
}
}
draw() {
@ -95,6 +104,9 @@ class World {
_t = 0
_stars = []
_player = Ship.new(W / 2, H / 2)
_world_x = 0
_world_y = 0
_world_scroll_speed = 60 / 2
// init background
for (i in 0..W) {
@ -109,7 +121,7 @@ class World {
s.update()
}
// collect passed stars
while (_stars.count > 0 && _stars[0].isPassed) {
while (_stars.count > 0 && _stars[0].expired) {
_stars.removeAt(0)
}
// small stars
@ -125,9 +137,15 @@ class World {
_stars.add(Star.new(W, R.int(0,H), width, speed, 13))
}
_t = _t + 1
if (_t % _world_scroll_speed == 0) {
_world_x = _world_x + 1
}
}
draw() {
var sx = (_t % _world_scroll_speed) / (_world_scroll_speed / 8)
TIC.map(_world_x, _world_y, 30 + 1, 17 + 1, -sx, 0)
for (s in _stars) {
s.draw()
}
@ -171,10 +189,13 @@ class Game is TIC{
// 002:ccccceee8888cceeaaaa0cee888a0ceeccca0ccc0cca0c0c0cca0c0c0cca0c0c
// 003:eccccccccc888888caaaaaaaca888888cacccccccacccccccacc0ccccacc0ccc
// 004:ccccceee8888cceeaaaa0cee888a0ceeccca0cccccca0c0c0cca0c0c0cca0c0c
// 005:2222222223312331231123112111211122222222233123312311231121112111
// 017:cacccccccaaaaaaacaaacaaacaaaaccccaaaaaaac8888888cc000cccecccccec
// 018:ccca00ccaaaa0ccecaaa0ceeaaaa0ceeaaaa0cee8888ccee000cceeecccceeee
// 019:cacccccccaaaaaaacaaacaaacaaaaccccaaaaaaac8888888cc000cccecccccec
// 020:ccca00ccaaaa0ccecaaa0ceeaaaa0ceeaaaa0cee8888ccee000cceeecccceeee
// 033:0000000000000000000000000002200000022000000000000000000000000000
// 034:0000000000000000000000000003300000033000000000000000000000000000
// </TILES>
// <SPRITES>
@ -184,6 +205,12 @@ class Game is TIC{
// 017:ddccccccddddddd0eeeeee000000000000000000000000000000000000000000
// </SPRITES>
// <MAP>
// 014:000000000000000000000000000000000000000000000000000000000000000000000000005000000000000000500000000000000050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
// 015:000000000000000000000000000000000000000000000000000000000000000000000000505050000000000050505000000000005050500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
// 016:000000000000000000000000000000000000000000000000000000000000505050505050505050505050505050505050505050505050505050505050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
// </MAP>
// <WAVES>
// 000:00000000ffffffff00000000ffffffff
// 001:0123456789abcdeffedcba9876543210