'eRATication by Bplus 2018-07-15
'Ultra Mod version by Cobalt 2018-07-19 13:25 Build 0001 Ver 1.0beta
'known things to fix/complete:
' re-add rat collision with player
' À-Currently in GOD mode. :)
' add Title screen and Title Bar text
' fix bullet collision with rat so Mini rats are hit correctly
' À-add more points of detection shots tend to pass right by :(
' add highscore list
' re-add hit explosions
' À-rats simply vanish at the moment :(
RemFlag
AS _BYTE 'if the shot has hit a rat or gone offscreen flag for removal
Momentum
AS SINGLE 'players movement speed ThrstRot
AS SINGLE 'the rotation of players craft when thrust was stopped
'constants
CONST MaxShots
= 3 'only 3 shots at a time on screen CONST RatScore
= 71 'how much the base score of each rat is CONST Drag
= .015 'how much the players movement slows over time CONST Rate
= .25 'delay between shots fired CONST RatCount
= 5 'base rat count
'Make screen and set timer
'set up arrays
'set up layers, an idea for haveing everything on its own layer then
'combining them on to the display
'DIM SHARED shiplayer&, ratlayer&
'shiplayer& = _NEWIMAGE(ScrnX, ScrnY, 32)
'ratlayer& = _NEWIMAGE(ScrnX, ScrnY, 32)
'initilize starting Values
ShotsFired%% = 0 'number of shots fired
P.Life = 1 'player on life #1
P.Points = 0
P.Rot = 0
P.Xloc = ScrnX \ 2
P.Yloc = ScrnY \ 2
'make some Rats
FOR i%%
= 0 TO RatCount
- 1 newRat i%%
'OPEN "debug.txt" FOR OUTPUT AS #1
FOR i
= 1 TO P.Life
* RatCount
'the rats drawRat i
'use arrow keys to swing shooter, spacebar to fire
'left shift to speed up rotation, this frees up the UP arrow to allow for movement
'of the players craft.
P.Momentum = P.Momentum + .056
IF P.Momentum
> 2.86 THEN P.Momentum
= 2.86 P.ThrstRot = P.Rot 'get current rotation
ELSEIF P.Momentum
THEN 'player is no longer thrusting and still has momentum P.Momentum = P.Momentum - Drag
IF P.Momentum
< 0 THEN P.Momentum
= 0
' IF _KEYDOWN(20480) THEN P.Rot = P.Rot + _PI(1 / 30)
'added cooldown to shooting so you can't auto gun 'normally' maybe add specails
'or bonuses to allow that later
ShotsFired%%
= NewShot
(ShotsFired%%
): cooldown!
= TIMER
IF ShotsFired%%
THEN ShotsFired%%
= shotprocess
(ShotsFired%%
) PlayerMovement
drawshooter P.Xloc, P.Yloc, P.Rot
IF P.Life
> 3 THEN ExitFlag%%
= TRUE
'bring rock in from one side, need to set heading according to side
'RANDOMIZE TIMER + RND
CASE 1: Rats
(iRat
).Xloc
= 0: Rats
(iRat
).Yloc
= RND * ScrnY: Rats
(iRat
).Rot
= 3 * _PI / 2 + RND * _PI CASE 2: Rats
(iRat
).Xloc
= ScrnX: Rats
(iRat
).Yloc
= RND * ScrnY: Rats
(iRat
).Rot
= _PI / 2 + RND * _PI CASE 3: Rats
(iRat
).Xloc
= RND * ScrnX: Rats
(iRat
).Yloc
= 0: Rats
(iRat
).Rot
= RND * _PI CASE 4: Rats
(iRat
).Xloc
= RND * ScrnX: Rats
(iRat
).Yloc
= ScrnY: Rats
(iRat
).Rot
= _PI + RND * _PI
'speed, angle, radius, gray coloring, spin, seed
Rats
(iRat
).Spd
= RND * 5 * P.Life
+ 1 Rats
(iRat
).Siz
= RND * 60 / P.Life
+ 3 Rats(iRat).Colr = ratKolor~&
'move the rat
Rats
(i
).Xloc
= Rats
(i
).Xloc
+ Rats
(i
).Spd
* COS(Rats
(i
).Rot
) + rand
(-.1 * Rats
(i
).Siz
, .1 * Rats
(i
).Siz
) Rats
(i
).Yloc
= Rats
(i
).Yloc
+ Rats
(i
).Spd
* SIN(Rats
(i
).Rot
) + rand
(-.1 * Rats
(i
).Siz
, .1 * Rats
(i
).Siz
)
IF Rats
(i
).Xloc
> 0 AND Rats
(i
).Xloc
< ScrnX
AND Rats
(i
).Yloc
> 0 AND Rats
(i
).Yloc
< ScrnY
THEN 'inbounds noseX
= Rats
(i
).Xloc
+ 2 * Rats
(i
).Siz
* COS(Rats
(i
).Rot
) noseY
= Rats
(i
).Yloc
+ 2 * Rats
(i
).Siz
* SIN(Rats
(i
).Rot
) neckX
= Rats
(i
).Xloc
+ .75 * Rats
(i
).Siz
* COS(Rats
(i
).Rot
) neckY
= Rats
(i
).Yloc
+ .75 * Rats
(i
).Siz
* SIN(Rats
(i
).Rot
) tailX
= Rats
(i
).Xloc
+ 2 * Rats
(i
).Siz
* COS(Rats
(i
).Rot
+ _PI) tailY
= Rats
(i
).Yloc
+ 2 * Rats
(i
).Siz
* SIN(Rats
(i
).Rot
+ _PI) earLX
= Rats
(i
).Xloc
+ Rats
(i
).Siz
* COS(Rats
(i
).Rot
- _PI(1 / 12)) earLY
= Rats
(i
).Yloc
+ Rats
(i
).Siz
* SIN(Rats
(i
).Rot
- _PI(1 / 12)) earats.sizats.xloc
= Rats
(i
).Xloc
+ Rats
(i
).Siz
* COS(Rats
(i
).Rot
+ _PI(1 / 12)) earats.sizats.yloc
= Rats
(i
).Yloc
+ Rats
(i
).Siz
* SIN(Rats
(i
).Rot
+ _PI(1 / 12)) fcirc Rats(i).Xloc, Rats(i).Yloc, .65 * Rats(i).Siz, Rats(i).Colr
fcirc neckX, neckY, Rats(i).Siz * .3, Rats(i).Colr
fTri noseX, noseY, earLX, earLY, earats.sizats.xloc, earats.sizats.yloc, Rats(i).Colr
fcirc earLX, earLY, Rats(i).Siz * .3, Rats(i).Colr
fcirc earats.sizats.xloc, earats.sizats.yloc, Rats(i).Siz * .3, Rats(i).Colr
wX
= .5 * Rats
(i
).Siz
* COS(Rats
(i
).Rot
- _PI(11 / 18)) wY
= .5 * Rats
(i
).Siz
* SIN(Rats
(i
).Rot
- _PI(11 / 18)) LINE (noseX
+ wX
, noseY
+ wY
)-(noseX
- wX
, noseY
- wY
), Rats
(i
).Colr
wX
= .5 * Rats
(i
).Siz
* COS(Rats
(i
).Rot
- _PI(7 / 18)) wY
= .5 * Rats
(i
).Siz
* SIN(Rats
(i
).Rot
- _PI(7 / 18)) LINE (noseX
+ wX
, noseY
+ wY
)-(noseX
- wX
, noseY
- wY
), Rats
(i
).Colr
LINE (Rats
(i
).Xloc
, Rats
(i
).Yloc
)-(tailX
, tailY
), Rats
(i
).Colr
newRat i
'vince version
x0 = R
y0 = 0
e = 0
y0 = y0 + 1
LINE (x
- x0
, y
+ y0
)-(x
+ x0
, y
+ y0
), C
, BF
LINE (x
- x0
, y
- y0
)-(x
+ x0
, y
- y0
), C
, BF
e = e + 2 * y0
LINE (x
- y0
, y
- x0
)-(x
+ y0
, y
- x0
), C
, BF
LINE (x
- y0
, y
+ x0
)-(x
+ y0
, y
+ x0
), C
, BF
x0 = x0 - 1
e = e - 2 * x0
LINE (x
- R
, y
)-(x
+ R
, y
), C
, BF
g%
= INT(RND * (.5 * r%
)) + .2 * r%
b%
= INT(RND * (.4 * g%
)) + .1 * g%
' r% = 165: g% = 95: b% = 25
ratKolor~&
= _RGB32(r%
, g%
, b%
)
rand%
= INT(RND * (hi%
- lo%
+ 1)) + lo%
SUB drawshooter
(x
, y
, radianAngle
) 'simple red iso triangle pointed towards radianAngle 'calculate 3 points of triangle shooter
x1
= x
+ 60 * COS(radianAngle
) 'main point of shooter according to heading y1
= y
+ 60 * SIN(radianAngle
) x2
= x
+ 30 * COS(radianAngle
+ _PI(2 / 3)) 'next two points are 120 degrees off main point in direction y2
= y
+ 30 * SIN(radianAngle
+ _PI(2 / 3)) x3
= x
+ 30 * COS(radianAngle
- _PI(2 / 3)) y3
= y
+ 30 * SIN(radianAngle
- _PI(2 / 3)) fTri x
, y
, x1
, y1
, x2
, y2
, _RGB(255, 0, 0) fTri x
, y
, x1
, y1
, x3
, y3
, _RGB(255, 0, 0)
IF Count%%
THEN 'are there active shots to move FOR i%%
= 0 TO Count%%
- 1 Shot(i%%).Xloc = Shot(i%%).Xloc + Shot(i%%).DXval
Shot(i%%).Yloc = Shot(i%%).Yloc + Shot(i%%).DYval
'check for shot hitting rat
IF RatCollision
(i%%
) THEN behappy
= yes
IF Shot
(i%%
).Xloc
> 0 AND Shot
(i%%
).Xloc
< ScrnX
AND Shot
(i%%
).Yloc
> 0 AND Shot
(i%%
).Yloc
< ScrnY
THEN 'in bounds draw it fcirc Shot
(i%%
).Xloc
, Shot
(i%%
).Yloc
, 2, _RGB32(170, 130, 10) Shot(i%%).RemFlag = TRUE
'check for offscreen shots
IF Shot
(j%%
).RemFlag
THEN 'shot is flaged for removal from rathit or offscreen FOR i%%
= j%%
TO Count%%
+ 1 Shot(i%%).Xloc = Shot(i%% + 1).Xloc
Shot(i%%).Yloc = Shot(i%% + 1).Yloc
Shot(i%%).DXval = Shot(i%% + 1).DXval
Shot(i%%).DYval = Shot(i%% + 1).DYval
Shot(i%%).RemFlag = Shot(i%% + 1).RemFlag
Count%% = Count%% - 1
shotprocess = Count%%
'fire a bullet
Shot
(id%%
).Xloc
= P.Xloc
+ 3 * BulletSpeed
* COS(P.Rot
) Shot
(id%%
).Yloc
= P.Yloc
+ 3 * BulletSpeed
* SIN(P.Rot
) Shot
(id%%
).DXval
= BulletSpeed
* COS(P.Rot
) Shot
(id%%
).DYval
= BulletSpeed
* SIN(P.Rot
) Shot(id%%).RemFlag = FALSE
id%% = id%% + 1
NewShot = id%%
'move player around if they have momentum
P.Xloc
= P.Xloc
+ P.Momentum
* COS(P.ThrstRot
) P.Yloc
= P.Yloc
+ P.Momentum
* SIN(P.ThrstRot
) 'stop the player if they encroach upon the screen bounds
IF P.Xloc
< 30 OR P.Yloc
< 30 OR P.Xloc
> ScrnX
- 30 OR P.Yloc
> ScrnY
- 30 THEN P.Momentum
= 0 'now that does allow player to move extreamly slow, like they are stuck in tar! but they
'can still leave screen, in that case they lose a life.
IF P.Xloc
<= 0 OR P.Xloc
>= ScrnX
OR P.Yloc
<= 0 OR P.Yloc
>= ScrnY
THEN P.Life = P.Life + 1 'player left screen by force! KILL EM'
P.Xloc = ScrnX \ 2: P.Yloc = ScrnY \ 2
FOR j%%
= 0 TO RatCount
* P.Life
check~&
= POINT(Shot
(id%%
).Xloc
, Shot
(id%%
).Yloc
) IF check~&
<> 0 THEN 'if bullet finds a nother color FOR i%%
= 0 TO RatCount
* P.Life
'which rat was hit. IF Rats
(i%%
).Colr
= check~&
THEN 'found dead rat 'give player points
P.Points = P.Points + (RatScore - Rats(i%%).Siz)
'kill that rat
newRat i%%
'kill the shot
Shot(id%%).RemFlag = TRUE
'exit the for next loop
i%% = RatCount * P.Life + 2
results%% = TRUE
results%% = FALSE
RatCollision = results%%