Possibility of an Asset-less Game?

This is just an idea. Since Corona allows the drawing of shapes and polygons with line append, and we can use this to fill the shapes: http://developer.anscamobile.com/forum/2011/05/17/drawing-polygon-fill

Let’s say I want to create a game (just for the heck of it) that uses minimal colours with everything in game drawn using polygon fills grouped together. Essentially, vector graphics with zero bitmap assets.

I’m not sure how Corona manages the graphics on screen, but would it be able to handle such a game and to what extent? [import]uid: 108204 topic_id: 27699 reply_id: 327699[/import]

I can’t see why not. you could also use the graphics.newGradient api to make things prettier.

Would be an interesting project (both visually and programmatically)

Keep us updated if you try it [import]uid: 84637 topic_id: 27699 reply_id: 112335[/import]

How’s this sloppily put together nightscene look?
0 texture memory, 1.4mb memory, 3.5mb APK file.

The only catch is that polygon fill causes such a massive drop in frame rate(crap tons of lines in each fill) on my android device.

Conclusions/Findings:

  1. Idea is very plausible if polygon fill is not used.
  2. If only I could use gradients for circles and rounded rectangles because it doesn’t work.
  3. With the right colors and art direction, it is possible to create something pretty neat with no texture memory usage.

config.lua
[lua]application =
{
content =
{
width = 640,
height = 960,
scale = “zoomEven”,
fps = 30,
},
} [/lua]

main.lua
[lua]display.setStatusBar( display.HiddenStatusBar )
math.randomseed(os.time())

local sW, sH = display.contentWidth, display.contentHeight

local bg_g = graphics.newGradient({15,37,64},{0,137,167})

local bg = display.newRect(0,0,sW,sH)
bg.x, bg.y = sW*0.5, sH*0.5
bg:setFillColor(bg_g)

local function sparkle(self,e)
if math.random(1,20) == 1 then
local alpha = math.random(100,255)
for i=1,2 do
self[i].xScale, self[i].yScale = math.random(5,10)*0.1,math.random(5,10)*0.1
self[i]:setFillColor(255,255,255,alpha)
end
end
end

local function spawnStar()
local starGroup = display.newGroup()
starGroup:insert(display.newRect(0,0,10,3))
starGroup:insert(display.newRect(0,0,3,10))

starGroup[1].x,starGroup[1].y = 0,0
starGroup[2].x,starGroup[2].y = 0,0

– animation
starGroup.enterFrame = sparkle

– functions
function starGroup:stop()
Runtime:removeEventListener(“enterFrame”, self)
end

function starGroup:start()
Runtime:addEventListener(“enterFrame”, self)
end

return starGroup
end

for i=1,30 do
local star= spawnStar()
star.x,star.y = math.random(0,640), math.random(0,sH*0.8)
star:start()
end

local function paintPoly(poly, xoffset, yoffset, rgba)
n = #poly
miny = poly[1].y
maxy = poly[1].y
local group = display.newGroup()
for i = 2, n do
miny = math.min(miny, poly[i].y)
maxy = math.max(maxy, poly[i].y)
end

for y = miny, maxy do
ints = {}
int = 0
last = n

for i = 1, n do

y1 = poly[last].y
y2 = poly[i].y
if y1 < y2 then
x1 = poly[last].x
x2 = poly[i].x
if (y >= y1) and (y < y2) then
int = int + 1
ints[int] = math.floor((y-y1) * (x2-x1) / (y2-y1) + x1)
end
elseif y1 > y2 then
x1 = poly[last].x
x2 = poly[i].x
if (y >= y2) and (y < y1) then
int = int + 1
ints[int] = math.floor((y-y2) * (x1-x2) / (y1-y2) + x2)
end
end
last = i
end

—[[
i = 1
while i < int do
line = display.newLine(ints[i] + xoffset, y + yoffset, ints[i+1] + xoffset, y + yoffset)
line:setColor( rgba[1], rgba[2], rgba[3], rgba[4] )
i = i + 2
group:insert(line)
end
–]]

end

return group
end

– local myRectangle = {
– {x=40,y=100},
– {x=180,y=100},
– {x=180,y=50},
– {x=40,y=50},
– }

– local colors = { {128,255,255,255}, {255,128,255,255}, {255,255,255,255}}
– paintPoly(myRectangle, 0, 0, colors[3])

local ray = {}
local raygroup = display.newGroup()
local trapez = {
{x=100,y=0},
{x=250,y=0},
{x=400,y=1000},
{x=0,y=1000},
}

for i=1,8 do
local alpha = 40
if i%2 > 0 then
alpha = 20
end
ray[i] = paintPoly(trapez, 0, 0, {255,255,255,alpha})
ray[i].x,ray[i].y = sW*0.5,sH*0.8
ray[i]:setReferencePoint(display.TopCenterReferencePoint)
ray[i]:rotate(45*(i-1))
raygroup:insert(ray[i])
end
ray[2].x,ray[2].y = ray[1].x-135,ray[1].y-35
ray[3].x,ray[3].y = ray[1].x-205,ray[1].y-155
ray[4].x,ray[4].y = ray[1].x-170,ray[1].y-290
ray[5].x,ray[5].y = ray[1].x-50,ray[1].y-360
ray[6].x,ray[6].y = ray[1].x+85,ray[1].y-325
ray[7].x,ray[7].y = ray[1].x+155,ray[1].y-205
ray[8].x,ray[8].y = ray[1].x+120,ray[1].y-70
raygroup:setReferencePoint(display.CenterReferencePoint)
raygroup:translate(sW*0.7-raygroup.x,sH*0.9-raygroup.y)

local prevTime = system.getTimer()
local function spinrays(e)
local deltaTime = e.time - prevTime
prevTime = e.time
raygroup:rotate(0.01*deltaTime)
end

Runtime:addEventListener(“enterFrame”,spinrays)
local moon = display.newCircle(0,0,250)
moon:setFillColor(255,255,180)
moon:translate(sW*0.7-moon.x,sH*0.9-moon.y)

local hillgroup = display.newGroup()
local hill = display.newCircle(0,0,200)
hillgroup:insert(hill)
hill:setFillColor(190,194,63)
hill.x,hill.y = 200,200

for i=1,20 do
local x,y = math.random(0,400),math.random(0,400)
while math.sqrt((x-200)*(x-200)+(y-200)*(y-200)) > 180 do
x,y = math.random(0,400),math.random(0,400)
end
hillgroup:insert(display.newRect(0,0,math.random(3,5),math.random(3,5)))
hillgroup[i+1].x,hillgroup[i+1].y = x,y

if math.random(1,2) == 1 then
hillgroup[i+1]:setFillColor(108,106,45)
else
hillgroup[i+1]:setFillColor(233,205,76)
end
end
hillgroup:setReferencePoint(display.CenterReferencePoint)
hillgroup.x,hillgroup.y = sW*0.8,sH*1.1
hillgroup:scale(1.5,1)


local hillgroup2 = display.newGroup()
local hill2 = display.newCircle(0,0,200)
hillgroup2:insert(hill2)
hill2:setFillColor(144,180,75)
hill2.x,hill2.y = 200,200

for i=1,20 do
local x,y = math.random(0,400),math.random(0,400)
while math.sqrt((x-200)*(x-200)+(y-200)*(y-200)) > 180 do
x,y = math.random(0,400),math.random(0,400)
end
hillgroup2:insert(display.newRect(0,0,math.random(3,5),math.random(3,5)))
hillgroup2[i+1].x,hillgroup2[i+1].y = x,y

if math.random(1,2) == 1 then
hillgroup2[i+1]:setFillColor(75,78,42)
else
hillgroup2[i+1]:setFillColor(255,255,255,100)
end
end
hillgroup2:setReferencePoint(display.CenterReferencePoint)
hillgroup2.x,hillgroup2.y = sW*0.2,sH*1.1
hillgroup2:scale(2,1.2)


–clouds–

local clouds = {}
local cloudprevTime = system.getTimer()
local function moveclouds(e)
local deltaTime = e.time - cloudprevTime
cloudprevTime = e.time

if #clouds > 0 then
for i=#clouds,1,-1 do
clouds[i]:translate(clouds[i].dX*deltaTime*0.001,0)
if clouds[i].x < -clouds[i].width or clouds[i].x > sW+clouds[i].width*0.5 then
display.remove(clouds[i])
table.remove(clouds,i)
end
end
end

while #clouds < 3 do
clouds[#clouds+1] = display.newRoundedRect(0,0,math.random(200,500),math.random(100,200),45)
clouds[#clouds]:setFillColor(255,255,255,math.random(100,150))
if math.random(1,2) == 1 then
clouds[#clouds].x, clouds[#clouds].y = -clouds[#clouds].width*0.5,math.random(100,700)
clouds[#clouds].dX = math.random(5,20)
else
clouds[#clouds].x, clouds[#clouds].y = sW+clouds[#clouds].width*0.5,math.random(100,700)
clouds[#clouds].dX = 0-math.random(5,20)
end
end
– collectgarbage(“collect”)
– print(collectgarbage(“count”))
– print(system.getInfo(“textureMemoryUsed”))
end

Runtime:addEventListener(“enterFrame”,moveclouds)[/lua] [import]uid: 108204 topic_id: 27699 reply_id: 113001[/import]

nice landscape :slight_smile:
now make it interactive!

-finefin [import]uid: 70635 topic_id: 27699 reply_id: 113010[/import]

@timespace: Very nice!! [import]uid: 84637 topic_id: 27699 reply_id: 113204[/import]

Checkout Asteroids in the share your code section.

In fact my latest game was almost finished and just consisted of circles and rectangles. Finally got a graphics person to do the graphics. It’s funny cause I would show people and they would hardly look at it, now it has graphics, they want to play it.

Dave [import]uid: 117617 topic_id: 27699 reply_id: 113412[/import]