Hi All
If you are anything like me, and probably are - wherever you are, you are either very busy fighting CVD19, ill with it or subject to Lockdown. So I am posting some incomplete code which I started a few months ago and shelved. It’s based on a 1K challenge to make a Space Invaders game up. I didn’t intend limiting it to 1K but I tried to use the principle by using emojis as an alternative to sprites.
Got the base system up and running, not cleaned up or optimised, and haven’t yet added the touch control interactions and scores - so I am hoping that you can fill those in. This is intended to give users a target, entertain/distract/frustrate them in a hope what is happening in the World for most of us can be put on hold for a while. If you do get anywhere with this please post with your ideas/problems so other users can learn from it. Also if anyone else has similar half finished projects - Now’s the time to share the work. Code below:
-- 1KSpaceInvaders
displayMode(FULLSCREEN)
function setup()
W,H = WIDTH,HEIGHT
N={5,5,5,5,5,5,5,5,5,5,5}
S,B,V,D,I,O,P = W/24,350,0,300,1,0,0,0
buttons = {""}
vaders = {{""},
{""},
{""},
{""}
}
bpos = vec2(350,160)
x,y,bw,vh,mv = 350,W/24,S+44,980,12
blimL,blimR = 128,638
bmv = 8
blts = {x={},y={}}
dark = fill(76, 37, 129, 255)
ground = fill(118, 78, 37, 255)
myMesh = mesh()
myMesh.vertices = {vec2(0,1024),vec2(0,0),vec2(768,0),vec2(0,1024),vec2(768,0),vec2(768,1024)}
myMesh.colors = {color(94, 22, 241, 255),color(60, 120, 38, 255),color(50,120,38,255),
color(94,22,241,255),color(50,120,38,255),
color(94,22,241,255)}
end
function draw()
background(1, 132, 254, 255)
-- S is image size, H is screen Height, W is screen Width
-- P is
-- V is
-- I is
-- O is
myMesh:draw()
y = H-S
if I < 1 then
O = O +.5
else
O = O -.5
end
if O > S then
I = 1
P = P+S
end
if O < -S then
I = 0
P = P+S
end
V = V-1
fontSize(84)
fill(254, 254, 254, 255)
pushMatrix()
-- 160
text(buttons[1],40,100)
text(buttons[3],726,100)
text(buttons[2],bpos.x,bpos.y)
noFill()
strokeWidth(5)
fill(240, 42, 65, 255)
ellipse(720,240,80,80)
fill(220, 228, 201, 31)
strokeWidth(1)
rect(84,72,600,40)
popMatrix()
-- D is
-- i is column number
-- j is row number
-- B is
-- N{} is
if V < 0 then
D = 1
end
for i = 1,10 do
for j = 1,4 do
tmp = 2*i*S
if B > tmp+O and B < tmp+S and V > tmp+P and V < tmp+P+S then
if N[i] > j and D < 1 then
D = 1
N[i] = N[i]-1
end
end
fontSize(54)
fill(255, 255, 255, 255)
for si =1,4 do
for sv = 1,10 do
if vaders[si][sv] > "-" then
text(vaders[si][sv],sv*66+20+O,vh-si*64-P+S)
end
end
end
if N[i] > j then
end
end
end
strokeWidth(5)
for f = 1, #blts do
line(blts[f].x,blts[f].y+bmv,bmv,5,bmv)
end
end
function touched(t)
if t.state ~ ENDED then
if t.y >= 60 and t.y <= 190 then
-- print(t.x,t.y)
bpos.x = t.x
if bpos.x <= blimL then
bpos.x = blimL
elseif bpos.x >= blimR then
bpos.x = blimR
end
elseif t.x >= 680 and t.y >= 200 and t.y <= 280 then
-- print("fire")
-- table.insert(blts,x=bpos.x,y=bpos.y+8)
end
else
end
end
p.s. the buttons and invaders have been removed as they can not be printed in the format. I have posted an image below and will post a little code later with the character codes for the aliens and buttons. I may try another approach with another image to achieve this.