Hi folks,
You certainly have noticed that the new trends in software development are based on IA and 'No code'. They want to make us believe that code is 'has been': ChatGPT can code for you, you can use graphical editors instead of code, etc.
I love Gideros because it is code centered, and because I grew up and learned to code by typing code listings from magazines in the 80's (They were standard MSX, STMag, Hebdogiciel).
In that time, there were contests to write small demo programs. The best demos would then be published and rewarded ('best' here could mean various things: beautiful, technically interesting, etc). Typical restrictions would apply: using a specific language, number of characters or lines below a limit, etc.
What would you think about defining something similar for Gideros ? Constraints would be:
- Using lua/gideros (obviously)
- No more than 100 lines, no more than 3k characters (in the event we'd like to publish them in a magzine)
- One single file of code (a main.lua)
- No additional assets (builtin Gideros font is allowed)
- No plugins (pure Gideros only).
- No UrlLoader
- Use of Gideros supplied lua libraries allowed
Any thought ?
Comments
- no plugins allowed, pure gideros lua only.
I only fear that we are a too small community to have a contest like that, even if we are one of the best community that ever existed, gideros is awesome and reliable and Lua is gold.
However I'd like to see where we could go from here.. I wonder if we could somehow engage with other lua communities like from Love or Solaris, and catch 'em all!
If we can make stunning demos with short codes, that's a way to say: "see, coding isn't hard with Gideros".
Likes: pie
I have a 3D Maze generator (which I wrote in lua for Roblox) that would certainly fit too
Likes: hgy29
I would be more interested in a gideros fanzine Like a monthly release with all the good stuff, but who will make it? how long of personal time would we have to invest? ...
Gideros has a wonderful wiki (imho), this could (should) be the place to promote how awesome gideros is.
Ideally that paper would also contain short tutorials about coding with gideros, from very basic lua to advanced stuff, in the hope that it could get picked up by school/teachers or novices.
93 lines of code and 2737 characters, some of which are comments.
I think it might be optimized better and insert a "play again" and a score somewhere, but I am already satisfied with the result
GET YOURS OUT!
Play it here: http://giderosmobile.com/code/bfKYQRvPhsQY7uOmJfEJS2JE8n1vfnxD
Likes: hgy29
Here is mine:
- 91 lines
- 3054 characters (I can reduce further, it depends if we define 3k=3000 or 3072)
- Needs gideros lua libraries (3dbase and luashader)
Likes: pie, MoKaLux
Likes: vitalitymobile
I wonder how many lines of code will require to do the same thing in 2d 80s style I am not sure: I'd say yes if it is going to be a showcase for the complete gideros features, no if the goal is to demonstrate the simple but deep approach to coding that gideros lua has.
To me using libraries and plugins defies the original purpose to stick to something that can exist in a single lua file. Both approaches have pros and cons, and I won't say they can't coexist. Let's hear from the others too
Here is another pure gideros lua, single file mini game: 49 lines of code and 1558 chars. This one with RETRY button too!!
Likes: hgy29, MobAmuse
Likes: pie
meanwhile it would be great to put them on gideros page running as html so anybody can try out. or even better put them in some wrapper (scemenanaged) so only one gideros game needs to be rune and you can decide which demo to lead.
Likes: pie
Fragmenter - animated loop machine and IKONOMIKON - the memory game
BTW I think it needs an update because not everything is working as it should right now
SPAMFIGHTER
http://giderosmobile.com/code/UVS1sXjq1Lf74uJXBnkCa3gt8FBy3eap
[edit: http://giderosmobile.com/code/bfKYQRvPhsQY7uOmJfEJS2JE8n1vfnxD this is the retro version, which means that is 100% compatible with the current fiddle version.]
The click for speed
http://giderosmobile.com/code/hB4OSnmOSdEW4cJ1SZZVivWJZhnsfywE
Likes: keszegh
- 2632 characters
- 76 lines
- Pure gideros without plugins or libs
Likes: pie, MobAmuse
Likes: MoKaLux
Likes: pie
Likes: MoKaLux
EDIT: i keep updating it, last time i changed that it is a bit more friendly with different output resolutions.
97 lines, 2772 chars:
Likes: hgy29, MoKaLux, pie, MobAmuse
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Likes: vitalitymobile
Likes: vitalitymobile
Fragmenter - animated loop machine and IKONOMIKON - the memory game
You can embed images in your code though, I did it for my 'lander' demo. You can base64 encode a png or a jpg and put it in plain text in your code too. You can also generate textures by code, using math.random or https://wiki.gideros.rocks/index.php/Math.noise
Likes: keszegh, pie, vitalitymobile
So I make it with a lot of code learn from you and @hgy29 and some other games on GitHub
This is my version, 100 lines but 6.5k characters, I can make it shorter but I think it will be clear for you if you want to read something
- Rules: From the Top-Left Cell, click any color so that you will flood fill the board with the same color in 25 moves
I really enjoy when making this mini-game. Gideros really has OOP central code, we can make a game with nice and clear code!
Likes: MoKaLux, pie, MobAmuse
I broke lots of coding standards to squeeze this down to 98 lines. Later I might see about squeezing some sound into it.
Here's the code:
j1,j2,w,h=application:getLogicalBounds() cx,cy=w/2,h/2 ppl=2000
dfs={"More Asteroids", "Bigger Asteroids", "Higher Gravity", "More Varied Asteroid Trajectories"}
Sprite.gp=Sprite.getPosition Sprite.sp=Sprite.setPosition Sprite.gr=Sprite.getRotation Sprite.sr=Sprite.setRotation
floor,wht,sqrt,min,max,rand,deg,rad,sin,cos=math.floor,0xffffff,math.sqrt,math.min,math.max,math.random,math.deg,math.rad,math.sin,math.cos
application:setBackgroundColor(0x000010)
function angle_between_points(x1, y1, x2, y2)
local dy,dx = y2 - y1,x2 - x1
if dx == 0 then if dy < 0 then return 180 else return 0 end elseif dy == 0 then if dx < 0 then return 270 else return 90 end end
result = math.deg(math.atan(dx / dy)) if dy < 0 then return 180 + result elseif (dx < 0) then return 360 + result end return result
end
--[[stars--]]for i = 1,500 do s=Shape.new() s:setLineStyle(2, wht) s:moveTo(0,0) s:lineTo(0,0) s:endPath() s:sp(rand(0,w),rand(0,h)) s:setScale(rand(1,2)) s:setAlpha(rand(10,50)/100) stage:addChild(s) end
--[[ship--]]ship_points = {0,2,0.3,2.5,0.6, 2,0, 0.6,0,0,1,2,1,4,2,5,2,3,3,3,3,7,2,7,2,6,1,5,1,6,0,5,0,0}
ship = Sprite.new() s=Shape.new() s:setLineStyle(2, 0xffff00) s:setFillStyle(Shape.SOLID, 0x4040ff) s:beginPath() s:moveTo(0, 0) ssc=12 ship.size=7*ssc ship.name="ship"
for i = 1, #ship_points/2 do s:lineTo(ship_points[i*2-1]*ssc,(ship_points[i*2]-3.5)*ssc) end
for i = 1, #ship_points/2 do s:lineTo(-ship_points[i*2-1]*ssc,(ship_points[i*2]-3.5)*ssc) end s:endPath() ship:addChild(s)
--[[blackhole--]] bhsize=50 local nl = 1000 bh=Sprite.new()
for i = 1, nl do local s=Shape.new() bh:addChild(s) local b=rand(100,200) s:setLineStyle(3, 0xffffff) s:beginPath() local l = rand(0,1000)/1000 s.life=l*l
s.a = rand(0,3600)*0.1 s:moveTo(0,0) s:lineTo(0,0) s:endPath() s:sp(rand(1,bhsize),rand(1,bhsize)) end
bh:addEventListener(Event.ENTER_FRAME, function() for i = 1, bh:getNumChildren() do local ch = bh:getChildAt(i)
ch:sr(rand(0,360)) ch.life = ch.life * 0.97 if ch.life < 0.05 then ch.life = rand(90,100)/100 ch.a = rand(0,3600)*0.1 end
ch:sp(ch.life * sin(rad(ch.a)) * bhsize, ch.life * cos(rad(ch.a)) * bhsize) ch:setAlpha(1-ch.life) local br=(ch.life - 0.2)*2
ch:setColorTransform(br,br,br) end end) stage:addChild(bh) bh:sp(cx, cy)
exhaust_layer = Sprite.new() stage:addChild(exhaust_layer) asteroid_layer = Sprite.new() stage:addChild(asteroid_layer)
--[[score display --]]score = 0 score_tf = TextField.new(nil, "SCORE:") score_tf:setScale(3) score_tf:sp(50, 50) score_tf:setTextColor(0xffff00) stage:addChild(score_tf)
function cc(o) local x,y=o:gp() local sx,sy=ship:gp() local d=sqrt((x-sx)*(x-sx)+(y-sy)*(y-sy)) if not go and d < (o.size/2 + ship.size/2) then bs() end_game() end end
function msg(t,p) if msgtf then msgtf:removeFromParent() end if t then msgtf = TextField.new(null,t) msgtf:setTextColor(0xffff00) stage:addChild(msgtf) msgtf:setScale(4)
msgtf:sp((w-msgtf:getWidth()) / 2, 70) if not p then Timer.delayedCall(3000, msg) end end end
function tip(t,p) if tiptf then tiptf:removeFromParent() end if t then tiptf = TextField.new(null,t) tiptf:setTextColor(0xffff00) stage:addChild(tiptf) tiptf:setScale(4)
if go then return end
local x = (w-tiptf:getWidth()) / 2 if p=="l" then x = 50 elseif p=="r" then x=w-50-tiptf:getWidth() end
tiptf:sp(x, h-100) if not p then Timer.delayedCall(3000, tip) end end end
function make_asteroid()
local a, s = rand(0,3600) * 0.1, Shape.new() s.size = asteroid_size * 0.4 * rand(50,100)
s.vx,s.vy=rand(-100,100) * asteroid_trajectory_factor * 0.1, rand(-100,100) * asteroid_trajectory_factor * 0.1
s.vr=rand(-10,10)*0.1 s:setLineStyle(2, 0xffffff) s:setFillStyle(Shape.SOLID, 0xbbbbbb) s:beginPath() s:moveTo(0, s.size/2)
for a=10,360,10 do s:lineTo(sin(rad(a))*s.size/2+rand(-10,10)*s.size/200,cos(rad(a))*s.size/2 + rand(-10,10)*s.size/200) end s:lineTo(0,s.size/2) s:endPath()
asteroid_layer:addChild(s) s:sp(w/2+sin(rad(a))*max(w,h)*0.6, h/2+cos(rad(a))*max(w,h)*0.6) s:addEventListener(Event.ENTER_FRAME, function()move(s,1) cc(s) end)
end
function wait_for_player() waiting_for_player=1 msg("Tap to Play",1) end
function start_game()
go=null level=1 asteroid_rate=1 gravity_level=1 asteroid_size=1 asteroid_trajectory_factor = 0 score=0
while asteroid_layer:getNumChildren()>0 do local c=asteroid_layer:getChildAt(1) c:removeAllListeners() c:removeFromParent() end
ship.vx,ship.vy=0,0 ship:sp(w*0.1, h*0.1) ship:sr(-45) stage:addChild(ship) ship:setScale(1) ship.collapsing=null
Timer.delayedCall(1000,function()tip("Touch To Turn", "l")end) Timer.delayedCall(5000,function()tip("Touch To Turn", "r")end)
Timer.delayedCall(9000,function()tip("Touch To Burn")end) Timer.delayedCall(13000,function()tip("Avoid the Black Hole")end)
Timer.delayedCall(17000,function()tip("Avoid the Asteroids")end)
end
wait_for_player()
function end_game() if not go then go=1 msg("Game Over", 1) Timer.delayedCall(5000, wait_for_player) if tiptf then tiptf:removeFromParent() end end end
function move(o,g) -- Move the object, applying decceleration, with optional gravity
if o.collapsing then
o.collapsing = o.collapsing * 0.9 o.vx,o.vy=0,0 local x,y=o:gp() o:sp(cx+(x-cx)*o.collapsing,cy+(y-cy)*o.collapsing)
o:setScale(o.collapsing) if o.collapsing < 0.01 then o:removeFromParent() end
end
o.vx=o.vx or 0 o.vy=o.vy or 0 local ox,oy = o:gp() if o.vr then o:sr(o:gr()+o.vr) end
local d = sqrt((ox-cx)*(ox-cx)+(oy-cy)*(oy-cy)) local ge = min(1/max(d,1), 100) * 2 * gravity_level
if g then local a=rad(angle_between_points(ox, oy, cx, cy)) o.vx+=sin(a)*ge o.vy+=cos(a)*ge end
df=0.995 o.vx,o.vy=o.vx*df,o.vy*df o:sp(ox+o.vx, oy+o.vy)
if o.size and d < o.size/2 + bhsize/2 then o.collapsing=o.collapsing or 1 if o==ship then end_game() end end
end
function add_exhaust(side) -- Show the thrust from both nacelles
local ang = -ship:gr() + 35 if side == "l" then ang-=35*2 end local sx,sy,l=ship:gp()
local ex, ey, s = sx + ship.size*0.63*sin(rad(ang)), sy + ship.size*0.63*cos(rad(ang)), Shape.new()
s:setLineStyle(2, 0xff5000) s:moveTo(-5,0) s:lineTo(5,0) s:endPath() s:sp(ex,ey) s:sr(ship:gr()) exhaust_layer:addChild(s)
s.life, s.vx, s.vy = 1, ship.vx, ship.vy
s:addEventListener(Event.ENTER_FRAME, function() s.life-=0.02*rand(0.9,1) if s.life<=0 then s:removeFromParent() else s:setAlpha(s.life/4)
s:setScale(min(5, 1/s.life)) move(s) end end )
end
function bs()
local sx, sy = ship:gp() local x, y, w, h = ship:getBounds(ship) local rt=RenderTarget.new(w,h)
ship:sp(0-x, 0-y) rt:draw(ship) ship:sp(sx, sy) local np = 5
for i = 1, np do local s = Shape.new() s:setLineStyle(0,0xff0000) s:setFillStyle(Shape.TEXTURE, rt) local x1, y1 = rand(1, w),rand(1,h)
s:moveTo(sx, sy) for j=1,3 do s:lineTo(rand(1, w),rand(1,h)) end s:lineTo(x1, y1) s:endPath() asteroid_layer:addChild(s) s.size=h s:sp(sx+x, sy+y)
s.vx, s.vy,s.vr=ship.vx+rand(-10,10)* 0.1,ship.vy+rand(-10,10) * 0.1,rand(-10,10)*0.1 s:addEventListener(Event.ENTER_FRAME, function()move(s,1) end) end
ship:removeFromParent()
end
stage:addEventListener(Event.ENTER_FRAME,
function()
if waiting_for_player then return end
local rs,thrust = 3,0
if left_touches > 0 then ship:sr(ship:gr()-rs) thrust=0.5 end if right_touches > 0 then ship:sr(ship:gr()+rs) thrust=0.5 end
if (left_touches > 0 or middle_touches > 0) and not go then add_exhaust("r") end if (right_touches > 0 or middle_touches > 0) and not go then add_exhaust("l") end
if middle_touches > 0 then thrust=1 end
local sr, tf = ship:gr(), 0.05 if not go then score+=1 score_tf:setText(string.format("SCORE: %d",score)) end
if rand(0,1000)<(asteroid_rate + 1)*5 then make_asteroid() end ship.vx+=sin(rad(sr))*thrust*tf ship.vy-=cos(rad(sr))*thrust*tf move(ship,1)
local x,y=ship:gp() if x<1 or x>w or y<1 or y>h then ship.vx, ship.vy =0,0 ship:sp(min(w,max(1,x)), min(h,max(1,y))) end
if score%ppl==1 then level=floor(score/ppl)+1 local nfi=(level+#dfs-1) % #dfs + 1 local txt="Level " .. level if level > 1 then txt=txt .. ": " .. dfs[nfi] end msg(txt)
if nfi==1 then asteroid_rate+=1 elseif nfi==2 then asteroid_size+=1 elseif nfi==3 then gravity_level+=0.25 elseif nfi==4 then asteroid_trajectory_factor += 0.2 end end
end)
left_touches, right_touches, middle_touches = 0,0,0 -- Keep count of touches on left, middle, center
function ntouches(zone,n) if zone=="l" then left_touches+=n elseif zone=="r" then right_touches+=n elseif zone=="m" then middle_touches+=n end end
function setzone(event)
local zone if event.touch.xw*2/3 then zone="r" else zone="m" end
if event.zone ~= zone then ntouches(event.zone,-1) event.zone = zone ntouches(event.zone, 1) end
end
stage:addEventListener(Event.TOUCHES_MOVE, setzone)
stage:addEventListener(Event.TOUCHES_BEGIN, function (event) event.zone=null setzone(event) if waiting_for_player then waiting_for_player = nil start_game() end end )
stage:addEventListener(Event.TOUCHES_END, function (event) ntouches(event.zone, -1) end )
Likes: MoKaLux, pie, hgy29, vitalitymobile, MobAmuse
Fragmenter - animated loop machine and IKONOMIKON - the memory game
I see I'm way, way over the 3K character goal, almost triple that. Now I've got it down to around 6k, but I'll never get it to 3K without cutting into the gameplay.