It looks like you're new here. If you want to get involved, click one of these buttons!
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.
Comments
Hi there,
Space Invaders, nice! Thanks for the inspiration.
I used this as a starting point to try to make a simple game and try out codea and lua.
The structure is about the same.
You can play with touch control but also with an external keyboard.
@Atopia - excellent, very neat game. I was begining to think no-one would contribute to this but your program is a good example. Tnnk I'll start to add a few exxtras on the one I started. Tanks.
Great stuff guys, I've zero game writing experience and just starting to dabble with Codea and using invaders type things to experiment with so this will be invaluable.
Probably started too hard as going with voxels too and that is bending my head.
@Bri_G Ha, I'm sure you're right, but I'm a glutton for punishment and will go a little way down the path, probably before seeing sense and coming back with my tail between my legs...
I think it's fun trying!
Here’s a space invaders version that I had. Tilt the iPad left or right to move the ship. Tap the screen to shoot. Play in portrait orientation for more room up/down. Each time you shoot all the enemy players, the game will restart at a faster pace. If the enemy reaches near the bottom, the game restarts starting with the slow speed. There isn’t much to this, so don’t expect much.
@dave1707 - sorry I’ve been slow to reply to this, family matters!! This is a very neat and concise code, keeps all the features needed despite it’s size. Must admit I tend not to think of the gyroscope for controlling movement but it works well here. Now in my useful demos list. Thanks for that.
Hi All,
Thanks for the contributions here, didn’t get the progressive development I hoped for here but thanks for your posts. I’ve decided to post a project which is almost finished, just needs a little tidying - something I started years ago got to work then messed up and shelved. Largely fixed, grandkids love it. You have all probably seen this especially at Christmas. When I finished was going to offer to 2LL as a finished demo. Here it is in bits, I have posted some of the sprites to get it working.
Here is the main tab:
Here is the utils/resources code:
Finally here are the classes involved:
I am sure many of you will be able to suggest refinements, simplifications, bug fixes!!! All would be welcome.
Hi All,
Finally images of how it should look, and my own setup for it.
Oh, for all who have not seen this you have to select a number between 1 and 32 then drag the cards which contain that number to the present chest, and the other to the absent chest. Then your iPad will tell you which number you chose.
I’m looking at increasing the cards to six and selecting number for 1 to 64.
Any issues - just post em.
Edit: A little bit of colour helps, see attached pics. Your main edits will be to set up the path links to the graphic sprites either in the text form “Dropbox:..panel1” or with the asset.path list method asset.documents.Dropbox. .. panel1 or similar.
All - just been fiddling with @Jarc ’s loader and thinking about text size/colour display to make formatting in it easier? Came up with this - needs a little more polishing to make it generally applicable but - here it is:
Anyone any ideas on pushing this further?