12-30-2024, 04:21 AM
THE ISOMETRIC ALIEN
click the image to zoom-in
Attention, Earthlings!
The wait is OVER! The Isometric Alien has landed, and it's NOT here to probe your cows (this time)!
Prepare your thumbs for intergalactic action as you step into the wobbly, weird world of pet alien.
Available starting TODAY!
So grab your controllers, snacks, and maybe an anti-alien helmet (just in case)
Don’t miss your chance to save the pet alien... or at least look cool trying.
Play now. Conquer later.
click the image to zoom-in
Attention, Earthlings!
The wait is OVER! The Isometric Alien has landed, and it's NOT here to probe your cows (this time)!
Prepare your thumbs for intergalactic action as you step into the wobbly, weird world of pet alien.
Available starting TODAY!
So grab your controllers, snacks, and maybe an anti-alien helmet (just in case)
Don’t miss your chance to save the pet alien... or at least look cool trying.
Play now. Conquer later.
Code:
'=============================================================
' THE ISOMETRIC ALIEN PET
' Your mission is very simple
' Save the cute alien pet from red space rocks
'
' CONTROL KEYS :
' - ESC = quit
' - SPACE BAR = continue
' - LEFT,RIGHT = movement
' - 1,2,3,4 = choose your own alien pet
'
' ACKNOWLEDGEMENTS :
' - Sprites of "Attackers, Galaga Style N7" (Marcus)
' - Big object transformed into small pieces (Marcus)
' - Sound samples and sound library (Marcus)
' - The wave was inspired by "Golden Waves N7" (Johnno56)
'
' DISCLAIMER
' This tiny game is a work of fiction.
' It is not intended for commercial use and not for sale
' No person or entity associated with this game received payment
' or anything of value, or entered into any agreement,
' in connection with any game assets used in this game.
' Names, characters, places, events and incidents
' are either the products of the author’s imagination
' or used in a fictitious manner.
' Any resemblance to actual persons, animals, and aliens,
' living or dead, or actual events is purely coincidental.
'
'==============================================================
'set window size
#win32
set window "The Isometric Alien Pet", 800, 500
set redraw off
randomize clock()
' Include sound fx library.
include "sfx.n7"
' Create an sfx instance.
sfx = SFX()
sfx.SetSampleRate(16000)
sfx.SetEcho(2, 0.4, 0.1, 0)
crispSound = sfx.SquareWave(0.5, [50, 100, -500, 1000], [0.5, 1, 0])
boomSound = sfx.Noise(0.6, [5000, 100], [1, 0, 1, 0])
visible expSound = Create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, 1, 1, 1],
[1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1],
[1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1],
[0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0],
[0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0],
[0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0],
[0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0],
[1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1],
[1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1],
[0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0]
]
rock = []
rock[1] =
[
[1, 1],
[1, 1]
]
'color definition
visible white = [255,255,255]
visible black = [0,0,0]
visible topcolor = [130,130,130]
visible leftcolor = [60,60,60]
visible rightcolor = [150,150,150]
'initial value
visible platformSize = 30 'isometric platform size
gameSpeed = 1 ; prevTime = clock() 'to be used with delta time
offX = 2 ; offY = 4 ; h = 20 'offY -2,15, h=height of sprite
offRockX = 29 ; offRockY = rnd(-2,27) 'offRockX -5,29 , offRockY -2,27
offRockX2 = 29 ; offRockY2 = 20
score = 0 ; life = 3 ; endgame = false
pet = rnd(1,4) ; rp = 0 ; gp = 0 ; bp = 60 'number of pet and rgb color
'introduction scene
visible objects = []
visible bigObject = []
visible count = 0
visible start = false
Intro(sprite[rnd(1,4)])
ShakeIt(sprite[1],rp,gp,bp)
play sound crispSound
'-----------
' MAIN LOOP
'-----------
do
'delta time
t = clock()
dt = (min(t - prevTime, 66))/1000
prevTime = t
dt = dt*gameSpeed
gameSpeed = gameSpeed + dt*0.05
'clear screen
set color black; cls
'infobox
set color white
set caret 10,10
wln "LEFT / RIGHT to move the pet alien"
wln
wln "Score = "+score
wln "Life = "+life
wln "Game Speed = "+int(gameSpeed)
'isometric platform
for x1 = 0 to platformSize
for y1 = 0 to platformSize
Ommatidia(OmmaX(x1,y1),OmmaY(x1,y1),30,topcolor,leftcolor,rightcolor)
next
next
'controls
if keydown(KEY_RIGHT,true) then
offY = min(offY+5,platformSize-15)
elseif keydown(KEY_LEFT,true) then
offY = max(offY-5,-2)
endif
if keydown(KEY_1,true) then
pet = 1
rp = 0
gp = 0
bp = 60
elseif keydown(KEY_2,true) then
pet = 2
rp = 0
gp = 40
bp = 20
elseif keydown(KEY_3,true) then
pet = 3
rp = 60
gp = 30
bp = 0
elseif keydown(KEY_4,true) then
pet = 4
rp = 0
gp = 30
bp = 60
endif
'check for collision detection
if offRockX > -5 then
offRockX = offRockX - 0.1-dt*7
if offRockX <= 10 and offRockY >= offY and offRockY <= offY+13 then
'reinitialize
objects = []
bigObject = []
count = 0
start = false
play sound crispSound
Intro(sprite[pet])
offRockX = 29
offRockY = rnd(-2,27)
h = h-5
life = life - 1
pet = rnd(1,4)
endif
else
play sound expSound,0.5
score = score + 10
offRockX = 29
offRockY = rnd(-2,27)
endif
'Space Rock #2
if offRockX2 > -5 then
offRockX2 = offRockX2- 0.1-dt*7
else
offRockX2 = 29
offRockY2 = 20
endif
'game over
if h <= 1 then
ShakeIt(sprite[pet],rp,gp,bp)
do
play sound boomSound
Message("GAME OVER",0)
Message("Your score "+score,20)
Message("Continue (Y/N) ?",40)
answer = rln(1,TYPE_STRING)
if upper(answer) = "Y" then
endgame = false
life = 4
gameSpeed = 1
h=20
pet = rnd(1,4)
elseif upper(answer) ="N" then
endgame = true
endif
set color black
draw rect 10,10,50,50,true
until upper(answer)="Y" or upper(answer)="N"
endif
'draw spaceDust, rock, rockTrace, and pet alien
spaceDust(gameSpeed+1)
rockTrace(offRockX,offRockY,1) 'vertical trace
Draw(rock[1],offRockX,offRockY,10,60,0,0)
Draw(sprite[pet],offX,offY,h,rp,gp,bp)
if gameSpeed > 2 then
rockTrace(offRockY2,offRockX2,2) 'horizontal trace
Draw(rock[1],offRockY2,offRockX2,10,60,0,0)
endif
if gameSpeed > 3 then
rockTrace(offRockY2-21,offRockX2,2) 'horizontal trace
Draw(rock[1],offRockY2-21,offRockX2,10,60,0,0)
endif
'ESC to quit
if keydown(KEY_ESCAPE) end
redraw
fwait 30
until endgame
end
'-----------
' FUNCTIONS
'-----------
function OmmaX(x1,y1)
return (12 * (24 - x1)) + (12 * y1)+ width()/8
endfunc
function OmmaY(x1,y1)
return (-6 * (24 - x1)) + (6 * y1) + height()/2
endfunc
'Why this function called Ommatidia ?
'The isometric platform consists of many small cells
'It reminds me of insect's compound eyes which are called ommatidia
function Ommatidia(x,y,h,ct,cl,cr)
'on top
set color ct
bar = [x, y - h, x + 10, y + 5 -h, x + 20, y - h, x + 10, y - 5 - h]
draw poly bar, 1
'left side
set color cl
bar = [x, y - h, x + 10, y + 5 - h, x + 10, y, x, y - 5]
draw poly bar, 1
'right side
set color cr
bar = [x + 10, y + 5 - h, x + 10, y, x + 20, y - 5, x + 20, y - h]
draw poly bar, 1
endfunc
function Draw(data,offsetX,offsetY,h,r,g,b)
tcolor = [r*2,g*2,b*2]
lcolor = [r,g,b]
rcolor = [r*3,g*3,b*3]
for y = 0 to sizeof(data) - 1 for x = 0 to sizeof(data[0]) - 1
if data[x][y] = 1 and h>0 then
Ommatidia(OmmaX(x+offsetX,y+offsetY),OmmaY(x+offsetX,y+offsetY),h,tcolor,lcolor,rcolor)
endif
next
endfunc
function Message(text,x)
set color white
set caret 10,10+x
wln text
redraw
endfunc
function CreateSineSfx(duration, startFreq, endFreq, fadeOut, sampleRate)
data = []
a = 0
da = 2*PI*startFreq/sampleRate
dda = (2*PI*endFreq/sampleRate - 2*PI*startFreq/sampleRate)/(duration*sampleRate)
vol = 1
fadeOut = fadeOut*duration*sampleRate
fadeOutDelta = 1/(duration*sampleRate - fadeOut)
for i = 0 to duration*sampleRate - 1
data[i] = sin(a)*vol
a = a + da
da = da + dda
if i > fadeOut vol = vol - fadeOutDelta
next
return createsound(data, data, sampleRate)
endfunc
function ShakeIt(s,r,g,b)
for t = 1 to 5
set color black;cls
tc = [130,130,130]
lc = [60,60,60]
rc = [150,150,150]
for y1 = 0 to platformSize
for x1 = 0 to platformSize
h1 = 60 * sin(x1 / 4 + t) + 60
Ommatidia(OmmaX(x1,y1),OmmaY(x1,y1),h1,tc,lc,rc)
next
Draw(s,0,5,5,r,g,b)
spaceDust(1)
next
fwait 10
redraw
next
endfunc
'---------------------------------------------------------------------------
function Intro(data)
' Big Object
bigObject = BigObject(data) 'one object bigObject
' Object Pieces
foreach row in bigObject.GetShape()
foreach piece in row 'see the shape matrix, 1 = true
if piece then
objects[sizeof(objects)] = SmallObject() 'more than one objects[] objects
endif
next
next
do
set color black;cls 'clear screen
start = true
'isometric platform
for x1 = 0 to platformSize
for y1 = 0 to platformSize
Ommatidia(OmmaX(x1,y1),OmmaY(x1,y1),20,topcolor,leftcolor,rightcolor)
next
next
bigObject.Update(0.01)
foreach i in objects 'for every entry in table objects
i.Update(0.01)
i.Draw()
next
'space dust
spaceDust(5)
redraw
fwait 30
until count > 1
endfunc
function BigObject(data)
'-------------Properties -----------------
e = []
e.shape = data
e.x = (platformSize - 1)/2; e.y = 3 'position x,y
e.dx = 0 'movement
e.hasForm = true 'true when shaped by small objects
e.formTimer = 0
'--------------Methods--------------------
e.GetShape = function(); return this.shape; endfunc
e.PieceX = function(x); return this.x + x; endfunc
e.PieceY = function(y); return this.y + y; endfunc
e.SetDirection = function() 'big shape moves horizontally
this.dx = platformSize
endfunc
e.Update = function(dt)
if keydown(KEY_SPACE) or start then
this.formTimer = max(this.formTimer - 0.01, 0)
start = true
endif
if this.formTimer=0 or (keydown(KEY_SPACE) and start = false) then
play sound expSound
if this.hasForm
this.hasForm = false
this.formTimer = 0.1
else
this.hasForm = true
this.formTimer = 2
this.ShapeObjects() 'assign position in the shape to objects
endif
endif
' Move inside the platform
if start = true then
this.x = this.x + this.dx*dt
if this.x < 0-2 then
this.dx = |this.dx|
elseif this.x > platformSize-sizeof(this.shape)-1
this.dx = -|this.dx|
count = count + 1
endif
endif
return true
endfunc
e.ShapeObjects = function()
positions = []
for y = 0 to sizeof(this.shape)-1
for x = 0 to sizeof(this.shape)-1
if this.shape[y][x] then 'this shape[y][x] = 1
positions[sizeof(positions)] = [x, y]
endif
next
next
' Assign shape positions to objects.
index = sizeof(positions)-1 'sizeof(positions) = the sum of 1 in the shape matrix
foreach e in objects
e.SetBigObject(this, positions[index][0], positions[index][1])
free key positions, index
index = index - 1
next
endfunc
e.SetDirection()
return e
endfunc
function SmallObject()
'-------------- Properties ---------------
e = []
e.selfX = rnd(platformSize -1) 'position X
e.selfY = rnd(platformSize -1) 'position Y
e.dx = 0 ; e.dy = 0 'movement
e.bigObject = unset 'set when connected to a big Object
'-------------- Methods -------------------
e.SetBigObject = function(bigObject, x, y)
this.bigObject = bigObject
this.bigX = x
this.bigY = y
this.formParam = 0
endfunc
e.Update = function(dt)
' Update personal position.
this.dx = this.dx*(1 - dt)
this.dy = this.dy*(1 - dt)
this.selfX = this.selfX + this.dx*dt
this.selfY = this.selfY + this.dy*dt
' Combine self position with position given by big object.
if this.bigObject
if this.bigObject.hasForm
this.formParam = min(this.formParam + dt,1)
p = this.formParam^2
this.x = this.selfX*(1-p) + this.bigObject.PieceX(this.bigX)*p
this.y = this.selfY*(1-p) + this.bigObject.PieceY(this.bigY)*p
' "explode"
'else
' a = rnd(360)
' this.dx = cos(rad(a))*platformSize
' this.dy = sin(rad(a))*platformSize
'
' this.selfX = this.x; this.selfY = this.y
'
' this.bigObject = unset
endif
' Only use self position.
else
this.x = this.selfX
this.y = this.selfY
endif
endfunc
e.Draw = function()
'color
r = 0 ; g = 0 ; b = 60
ct = [r*2,g*2,b*2]
cl = [r,g,b]
cr = [r*3,g*3,b*3]
'height
h = 10
'draw to isometric platform
Ommatidia(OmmaX(this.y,this.x),OmmaY(this.y,this.x),h,ct,cl,cr)
if not this.bigObject then
Ommatidia(OmmaX(this.y-1,this.x-1),OmmaY(this.y-1,this.x-1),h,ct,cl,cr)
endif
endfunc
return e
endfunc
'---------------------------------------------------------------------------
function spaceDust(n)
for i = 1 to n
r = rnd(255) ; g = rnd(255) ; b = 0
tc = [r*2,g*2,b*2]
lc = [r,g,b]
rc = [r*3,g*3,b*3]
sdx = rnd(platformSize)
sdy = rnd(platformSize)
h = rnd(5,10+n)
Ommatidia(OmmaX(sdx,sdy),OmmaY(sdx,sdy),h,tc,lc,rc)
Ommatidia(OmmaX(sdx-1,sdy),OmmaY(sdx-1,sdy),h,tc,lc,rc)
Ommatidia(OmmaX(sdx-1,sdy-1),OmmaY(sdx-1,sdy-1),h,tc,lc,rc)
Ommatidia(OmmaX(sdx,sdy-1),OmmaY(sdx,sdy-1),h,tc,lc,rc)
next
endfunc
function rockTrace(i,j,type)
h = 10
r = 100; g=40; b=20
ct = [r*2,g*2,b*2]
cl = [r,g,b]
cr = [r*3,g*3,b*3]
'vertical trace
if type = 1 then
for x1 = platformSize-2 to i
y1 = j
Ommatidia(OmmaX(x1,y1),OmmaY(x1,y1),h,ct,cl,cr)
Ommatidia(OmmaX(x1,y1+1),OmmaY(x1,y1+1),h,ct,cl,cr)
next
endif
'lower horizontal trace
if type = 2 then
for y1 = platformSize-2 to j
x1 = i
Ommatidia(OmmaX(x1,y1),OmmaY(x1,y1),h,ct,cl,cr)
Ommatidia(OmmaX(x1+1,y1),OmmaY(x1+1,y1),h,ct,cl,cr)
next
endif
endfunc