RANT - DemoScenes

I am unsure if this post is even related to the topic, it is definitely a RANT. Some of you might know what DemoScenes are, earlier they were very active and it used to be a show of mastery that the demo group had over a particular hardware. They would push the boundaries of the hardware to the max and come up with some really cool stuff. Even today some of those demos are worth much more than many games created.

On the iTunes store people look at the graphics and decide to either buy or not buy an App. The major thing that many forget is that sometimes there is a lot of cool stuff that might have gone into making of the app. Things that generally cause headaches for developers.

I was responding to someone’s question that asked about how to not have overlapping sprites as it spoils the perspective, In my app Office Blues, I had this issue where the dividers and the sprites had to be depth sorted to place them in front of or behind the other sprites to keep the isometric illusion intact. Many of my games might not have much in terms of Graphics as I am *not* a graphic artist, but then there is always that little learning that is present that does some really cool things… now let me work out the 3D routines using Corona :wink:

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 16222 reply_id: 316222[/import]

3D like Wolfenstein? :slight_smile: Just finish this code cuz :wink:

[lua]local map = {
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,2,2,2,2,2,0,0,0,0,3,0,3,0,3,0,0,0,1},
{1,0,0,0,0,0,2,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,2,0,0,0,2,0,0,0,0,3,0,0,0,3,0,0,0,1},
{1,0,0,0,0,0,2,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,2,2,0,2,2,0,0,0,0,3,0,3,0,3,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,4,0,4,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,4,0,0,0,0,5,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,4,0,4,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,4,0,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
}

local map_height,map_width = #map,#map[1]

local posX,posY = 22,12
local dirX,dirY = -1,0
local planeX,planeY = 0,0.66
local time,oldtime = 0,0
local w = display.contentWidth
local h = display.contentHeight

local moveSpeed, rotSpeed = 0,0

function update(dt)
moveSpeed = dt*3
rotSpeed = dt
— !!! ADD JOYSTICK FUNCTION!!!
–[[
if (forward) then
if map[math.floor(posX+dirX*moveSpeed)][math.floor(posY)] == 0 then
posX = posX + dirX*moveSpeed
end
if map[math.floor(posX)][math.floor(posY+dirY*moveSpeed)] == 0 then
posY = posY + dirY*moveSpeed
end
end

if (back) then
if map[math.floor(posX-dirX*moveSpeed)][math.floor(posY)] == 0 then
posX = posX - dirX*moveSpeed
end
if map[math.floor(posX)][math.floor(posY-dirY*moveSpeed)] == 0 then
posY = posY - dirY*moveSpeed
end
end

if (left) then
local oldDirX = dirX
dirX = dirX * math.cos(rotSpeed)- dirY*math.sin(rotSpeed)
dirY = oldDirX * math.sin(rotSpeed)+ dirY*math.cos(rotSpeed)
local oldPlaneX = planeX
planeX = planeX * math.cos(rotSpeed) - planeY*math.sin(rotSpeed)
planeY = oldPlaneX * math.sin(rotSpeed) + planeY*math.cos(rotSpeed)
end

if (right) then
local oldDirX = dirX
dirX = dirX * math.cos(-rotSpeed)- dirY*math.sin(-rotSpeed)
dirY = oldDirX * math.sin(-rotSpeed)+ dirY*math.cos(-rotSpeed)
local oldPlaneX = planeX
planeX = planeX * math.cos(-rotSpeed) - planeY*math.sin(-rotSpeed)
planeY = oldPlaneX * math.sin(-rotSpeed) + planeY*math.cos(-rotSpeed)
end

]]–

end
function draw()

for x = 0,w do
local camX = 2*(x/w)-1
local rayPosX = posX
local rayPosY = posY
local rayDirX = dirX + planeX*camX
local rayDirY = dirY + planeY*camX
local mapX = math.floor(rayPosX)
local mapY = math.floor(rayPosY)
local sideDistX,sideDistY

local deltaDistX = math.sqrt(1+(rayDirY^2)/(rayDirX^2))
local deltaDistY = math.sqrt(1+(rayDirX^2)/(rayDirY^2))
local perpWallDist

local stepX,stepY

local hit = 0
local side

if rayDirX<0 then
stepX = -1
sideDistX = (rayPosX - mapX)*deltaDistX
else
stepX = 1
sideDistX = (mapX+1-rayPosX)*deltaDistX
end

if rayDirY <0 then
stepY = -1
sideDistY = (rayPosY - mapY) * deltaDistY
else
stepY = 1
sideDistY = (rayPosY +1-rayPosY)*deltaDistY
end

while (hit==0) do
if (sideDistX < sideDistY) then
sideDistX = sideDistX + deltaDistX
mapX = mapX+stepX
side = 0
else
sideDistY = sideDistY + deltaDistY
mapY = mapY + stepY
side = 1
end

if map[mapX][mapY] > 0 then hit = 1 end
end

if side==0 then
perpWallDist = math.abs((mapX - rayPosX+(1-stepX)/2)/rayDirX)
else
perpWallDist = math.abs((mapY - rayPosY+(1-stepY)/2)/rayDirY)
end

local lineHeight = math.abs(math.floor(h/perpWallDist))
local drawStart = -lineHeight/2 + h/2
if drawStart < 0 then drawStart = 0 end
local drawEnd = lineHeight/2 + h/2
if drawEnd >= h then drawEnd = h-1 end

local color = {}
local square = map[mapX][mapY]
if square == 1 then color = {255,0,0,255}
elseif square == 2 then color = {0,255,0,255}
elseif square == 3 then color = {0,0,255,255}
elseif square == 4 then color = {255,255,255,255}
else color = {255,255,0,255}
end

if side == 1 then
for k,v in ipairs(color) do v = v/2 end
end
local line = display.newLine(x,drawStart,x,drawEnd)
line:setColor(color)
end

end

Runtime:addEventListener( “enterFrame”, draw )[/lua] [import]uid: 12704 topic_id: 16222 reply_id: 60411[/import]