Author Topic: Minicraft / Terraria clone  (Read 27054 times)

0 Members and 2 Guests are viewing this topic.

Offline linuxgeek96

  • LV3 Member (Next: 100)
  • ***
  • Posts: 99
  • Rating: +4/-0
  • ( ͡° ͜ʖ ͡°)
    • View Profile
    • Personal Site
Minicraft / Terraria clone
« on: April 08, 2012, 05:37:51 pm »
Hi guys,

I recently began work on a minicraft like game in Lua, but I realized it was missing something (I'll give you a hint -- another dimension). I decided to make a minicraft with TERRARIA view! What do y'all think?

EDIT: here are some planning notes.
Blocks
stage1
0/nil → air (maybe vaccum?), rgb(254,254,255)
1 → dirt, rgb(150,100,50)
stage2
2 → stone, rgb(200,200,200)
3 → cobble, rgb(150,150,150)
4 → wood, rgb(150,100,50)
5 → leaf/air, rgb(100,200,100)
stage3
6 → coal (ore)
7 → coal (drop)
8 → iron (ore)
9 → iron (ingot)
10 → crafting table
11 → furnace

Ideas
store last key (instabreak to start)
sparse matrix of fixed size (to start)
UPDATE 2:
Check daily for Updates!!!
Code: [Select]
function create(mode)
t=1/2
timer.start(t)
sprites={image.new("\008\000\000\000\008\000\000\000\000\000\000\000\016\000\000\000\016\000\001\000\000\000\000\000\000\000)\165)\165\000\000\000\000\000\000\000\000\000\000)\165\000\000\000\000)\165\000\000\000\000)\165\000\000\000\000)\165)\165\000\000\000\000)\165\000\000)\165\000\000\000\000\000\000\000\000)\165\000\000\000\000\000\000)\165)\165)\165)\165\000\000\000\000\000\000\000\000\000\000)\165)\165\000\000\000\000\000\000\000\000\000\000)\165\000\000\000\000)\165\000\000\000\000\000\000\000\000)\165\000\000\000\000)\165\000\000\000\000"),image.new("\008\000\000\000\008\000\000\000\000\000\000\000\016\000\000\000\016\000\001\000\000\128\140\177\000\128\140\177\000\128\140\177\000\128\140\177\140\177\000\128\140\177\000\128\140\177\000\128\140\177\000\128\000\128\140\177\000\128\140\177\000\128\140\177\000\128\140\177\140\177\000\128\140\177\000\128\140\177\000\128\140\177\000\128\000\128\140\177\000\128\140\177\000\128\140\177\000\128\140\177\140\177\000\128\140\177\000\128\140\177\000\128\140\177\000\128\000\128\140\177\000\128\140\177\000\128\140\177\000\128\140\177\140\177\000\128\140\177\000\128\140\177\000\128\140\177\000\128")}
inventory={current=0,select=1,{type=0,number=0},{type=0,number=0},{type=0,number=0},{type=0,number=0},{type=0,number=0},{type=0,number=0},{type=0,number=0},{type=0,number=0}}
i=0
view=0
position={1,1,1}
pause=0
w=316
h=210
xlen=math.floor(w/j)
ylen=math.floor(h/j)
color={}
for x=1,xlen do
color[x]={}
for y=1,xlen do
color[x][y]={}
for z=1,xlen do
color[x][y][z]={visited=false,type=0}
if y==xlen then
color[x][y][z].type=-1
elseif y<=8 then
color[x][y][z].visited=true
elseif mode=="clear" then
elseif math.random()>(y-4)/ylen then
color[x][y][z].type=1
elseif math.random()>1-y/ylen then
if math.random()>1-(y*0.25-8)/ylen then
color[x][y][z].type=4
else
color[x][y][z].type=2
end
end
end
end
end
reloadMenu()
end
function reloadMenu()
menu={{"Functions",{"Reset",reset},{"Clear",clear}}}
toolpalette.register(menu)
end
function clear()
create("clear")
end
function reset()
create("reset")
end
function on.arrowLeft()
c="4"
end
function left()
if (position[1]~=1 and view~=1) then
position[1]=position[1]-1
elseif (position[2]~=1 and view==1) then
position[2]=position[2]-1
end
end
function on.arrowRight()
c="6"
end
function right()
if (position[1]~=xlen and view~=1) then
position[1]=position[1]+1
elseif (position[2]~=xlen and view==1) then
position[2]=position[2]+1
end
end
function on.arrowDown()
c="2"
end
function down()
if (position[3]~=ylen and view~=2) then
position[3]=position[3]+1
elseif (position[2]~=ylen and view==2) then
position[2]=position[2]+1
end
end
function on.arrowUp()
c="8"
end
function up()
if (position[3]~=1 and view~=2) then
position[3]=position[3]-1
elseif (position[2]~=1 and view==2) then
position[2]=position[2]-1
end
end
function pickColor(top,d)
local t = {255,0,0}
if top==0 then
t = {255*d,255*d,255*d}
elseif top==1 then
t = {150*d,100*d,50*d}
elseif top==2 then
t = {150*d,150*d,150*d}
elseif top==3 then
t = {200*d,200*d,200*d}
elseif top==4 then
t ={175*d,100*d,0}
end
return t
end
function calcFog(x,y,z,position)
local d
if not color[x][y][z].visited then
d = math.sqrt((x-position[1])*(x-position[1])+(y-position[2])*(y-position[2])*4+(z-position[3])*(z-position[3]))
d=1-(d/xlen*4)
if d<0 then
d=0
elseif d>1 then
d=1
end
else
d=1
end
return d
end
function on.charIn(ch)
c=ch
end
function on.timer()
platform.window:invalidate()
end
function on.mouseDown(x,y)
local coords={position[1],position[2],position[3]}
if view==0 then
coords[1]=math.ceil(x/j)
coords[3]=math.ceil(y/j)
elseif view==1 then
coords[2]=math.ceil(x/j)
coords[3]=math.ceil(y/j)
elseif view==2 then
coords[1]=math.ceil(x/j)
coords[2]=math.ceil(y/j)
end
if color[coords[1]][coords[2]][coords[3]].type==0 and inventory[inventory.select].number>0 then
color[coords[1]][coords[2]][coords[3]].type=inventory[inventory.select].type
inventory[inventory.select].number=inventory[inventory.select].number-1
end
end
function on.paint(gc)
gc:setColorRGB(0,0,64)
gc:fillRect(0,0,316,210)
if j==nil then
j=8
create("clear")
end
--Keypresses and d-pad
if c=="." then
if view==2 then
view = 0
else
view=view+1
end
elseif c=="1" then
down()
left()
elseif c=="2" then
down()
elseif c=="3" then
down()
right()
elseif c=="4" then
left()
elseif c=="6" then
right()
elseif c=="7" then
up()
left()
elseif c=="8" then
up()
elseif c=="9" then
up()
right()
elseif c=="a" then
inventory.select=1
elseif c=="b" then
inventory.select=2
elseif c=="c" then
inventory.select=3
elseif c=="d" then
inventory.select=4
elseif c=="e" then
inventory.select=5
elseif c=="f" then
inventory.select=6
elseif c=="g" then
inventory.select=7
end
if c then
c=""
end

--Gravity
i=1-i
if i==1 and  color[position[1]][position[2]+1][position[3]] .type==0 then
position[2]=position[2]+1
end

--Lighting / shroud
for x=-1,1 do
for y=-1,1 do
for z=-1,1 do
if not ((x==-1 and position[1]==1) or (y==-1 and position[2]==1) or (z==-1 and position[3]==1) or (x==1 and position[1]==xlen) or (y==1 and position[2]==xlen) or (z==1 and position[3]==xlen)) then
color[position[1]+x][position[2]+y][position[3]+z].visited=true
end
end
end
end

--Inventory/mining
if color[position[1]][position[2]][position[3]].type>0 then
local slot=inventory.current+1
for i=1,inventory.current do
if inventory[i].type==color[position[1]][position[2]][position[3]].type then
slot=i
end
end
if not inventory[slot].type or
inventory[slot].type==0 then
inventory.current=inventory.current+1
inventory[slot].type=color[position[1]][position[2]][position[3]].type
inventory[slot].number=1
else inventory[slot].number=inventory[slot].number+1
end
color[position[1]][position[2]][position[3]].type=0
end

--Draw tiles
if view==0 then
for x=1,xlen do
for z=1,ylen do
local top=1
for y=position[2],xlen do
if top==1 and color[x][y][z].type~=0 then
top=y
end
end
local type=color[x][top][z].type
if type>0 then
local triple=pickColor(type,calcFog(x,top,z,position))
gc:setColorRGB(triple[1],triple[2],triple[3])
gc:fillRect(x*j-j*0.5,z*j-j*0.5,j,j)
elseif type==-1 then
gc:drawImage(sprites[2],x*j-j*0.5,z*j-j*0.5)
end
if x==position[1] and z==position[3] then
gc:drawImage(sprites[1],x*j-j*0.5,z*j-j*0.5)
end
end
end
elseif view==1 then
for y=1,xlen do
for z=1,ylen do
local type=color[position[1]][y][z].type
if type>0 then
local triple = pickColor( color[position[1]][y][z].type, calcFog(position[1],y,z,position))
gc:setColorRGB(triple[1],triple[2],triple[3])
gc:fillRect(y*j-j*0.5,z*j-j*0.5,j,j)
elseif type==-1 then
gc:drawImage(sprites[2],y*j-j*0.5,z*j-j*0.5)
end
if y==position[2] and z==position[3] then
gc:drawImage(sprites[1],y*j-j*0.5,z*j-j*0.5)
end
end
end
elseif view==2 then
for x=1,xlen do
for y=1,ylen do
local type=color[x][y][position[3]].type
if type>0 then
local triple=pickColor(type,calcFog(x,y,position[3],position))
gc:setColorRGB(triple[1],triple[2],triple[3])
gc:fillRect(x*j-0.5*j,y*j-0.5*j,j,j)
elseif type==-1 then
gc:drawImage(sprites[2],x*j-j*0.5,y*j-j*0.5)
end
if x==position[1] and y==position[2] then
gc:drawImage(sprites[1],x*j-j*0.5,y*j-j*0.5)
end
end
end
end
--Inventory overlay
for x=1,7 do
local triple=pickColor(inventory[x].type,1)
gc:setColorRGB(triple[1],triple[2],triple[3])
gc:fillRect(118+x*10,195,10,10)
gc:setColorRGB(0,0,0)
gc:drawString(inventory[x].number,120+x*10,189,"top")
end
gc:setColorRGB(255,255,255)
gc:drawString("("..position[1]..","..position[2]..","..position[3]..")",0,0,"top")
end
« Last Edit: April 18, 2012, 07:20:45 am by linuxgeek96 »

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Minicraft / Terraria clone
« Reply #1 on: April 08, 2012, 05:42:01 pm »
This sounds promising. Have screenshots/photos?
I'm not a nerd but I pretend:

Offline linuxgeek96

  • LV3 Member (Next: 100)
  • ***
  • Posts: 99
  • Rating: +4/-0
  • ( ͡° ͜ʖ ͡°)
    • View Profile
    • Personal Site
Re: Minicraft / Terraria clone
« Reply #2 on: April 08, 2012, 05:44:59 pm »
currently, no sprites, just colored blocks, but ill upload some when i get a chance to use ti nspire connect at school. How have you guys been doing w/ the TI.IMAGE format?

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Minicraft / Terraria clone
« Reply #3 on: April 08, 2012, 06:06:09 pm »
Basically Minecraft, but instead of Tinycraft,s flat, top-down view, you want to make it like Mario? It would be a great idea I think, because Minecraft relies a lot on digging, so a flat world doesn't sound as fun to me. Is it your first project by the way? As this might be kinda challenging if you go for large maps and keep every Minecraft option, if it's your first ever venture into programming. Good luck regardless, though. :)

Offline AzNg0d1030

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 522
  • Rating: +45/-4
  • Hardcore anime watcher.
    • View Profile
Re: Minicraft / Terraria clone
« Reply #4 on: April 08, 2012, 07:14:08 pm »
Basically Minecraft, but instead of Tinycraft,s flat, top-down view, you want to make it like Mario? It would be a great idea I think, because Minecraft relies a lot on digging, so a flat world doesn't sound as fun to me. Is it your first project by the way? As this might be kinda challenging if you go for large maps and keep every Minecraft option, if it's your first ever venture into programming. Good luck regardless, though. :)
And it's in Lua too.  It might be faster and better in C, but then again, that would be much harder O_o
Good luck! Is it possible to add the other dimension to make it a bird's eye view?
You just lost the game.



Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Minicraft / Terraria clone
« Reply #5 on: April 08, 2012, 08:13:53 pm »
Well for such game, I think Lua might be just fine enough, and if Lua is fast enough for that type of game, I guess it's a good idea to make it in that language so whenever Ndless gets blocked by TI, people can still play the game.

Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: Minicraft / Terraria clone
« Reply #6 on: April 08, 2012, 08:15:56 pm »
Nice job linuxgeek96! I've been thinking of a Terraria clone in Lua too for a while (check my signature) but I was planning to learn and release some more easier games first before I tackle this more ambitious project myself. Have you created any other projects? Cuz attempting this as one of your first projects will be difficult.
Anyway good luck!
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Offline Spyro543

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1189
  • Rating: +74/-3
    • View Profile
Re: Minicraft / Terraria clone
« Reply #7 on: April 08, 2012, 08:18:02 pm »
Oh wow! I was just working on a game like this! I swear, as soon as I start working on a project, someone else makes a topic about them making the exact same thing.

Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: Minicraft / Terraria clone
« Reply #8 on: April 08, 2012, 08:19:01 pm »
Oh wow! I was just working on a game like this! I swear, as soon as I start working on a project, someone else makes a topic about them making the exact same thing.
Lol yes, looks like we might have several clones of Terraria or Minecraft. :P Minecraft 3D would be very hard to do though.
« Last Edit: April 08, 2012, 08:27:11 pm by Jonius7 »
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Minicraft / Terraria clone
« Reply #9 on: April 08, 2012, 08:26:00 pm »
Most usually die, though, so I guess that's good there are other clones being worked on, in case the rest die and yours becomes finished. :P

Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: Minicraft / Terraria clone
« Reply #10 on: April 08, 2012, 08:26:56 pm »
Many die due to the sheer difficulty and mass scale of these types of projects. It could probably take years for a project like this to near completion.
Side view is much simpler than 3D viewing.
« Last Edit: April 08, 2012, 08:29:48 pm by Jonius7 »
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: Minicraft / Terraria clone
« Reply #11 on: April 08, 2012, 08:30:01 pm »
*cough*tinycraft*cough*

Offline AzNg0d1030

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 522
  • Rating: +45/-4
  • Hardcore anime watcher.
    • View Profile
Re: Minicraft / Terraria clone
« Reply #12 on: April 08, 2012, 08:43:58 pm »
You just lost the game.



Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Minicraft / Terraria clone
« Reply #13 on: April 08, 2012, 10:05:45 pm »
*cough*tinycraft*cough*
Yeah I mentionned it above, but he wants a more side-scrolling approach with pits and cliffs rather than the flat lands in Tinycraft.

Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: Minicraft / Terraria clone
« Reply #14 on: April 09, 2012, 01:47:39 am »
*cough*tinycraft*cough*
Yeah I mentionned it above, but he wants a more side-scrolling approach with pits and cliffs rather than the flat lands in Tinycraft.
I'd prefer the Terraria style any day. Allows fall damage and other things.
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)