Omnimaga
Calculator Community => Other Calc-Related Projects and Ideas => TI-Nspire => Topic started by: linuxgeek96 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!!!
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
-
This sounds promising. Have screenshots/photos?
-
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?
-
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. :)
-
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?
-
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.
-
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!
-
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.
-
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.
-
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
-
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.
-
*cough*tinycraft*cough*
-
*cough*tinycraft*cough*
^^^
-
*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.
-
*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.
-
I too prefer the side-view style for a game such as this. Do you plan to have some sort of field of view code, or something equivalent such that people can only see area's they have been in before? I think that would be cool and useful, and it would make exploring caves and stuff more interesting because you don't necessarily know what is coming up, and you would have to dig and explore to find minerals and stuff.
Can't wait for some screenies!
-
This looks like a nice project !
I think I prefer side-view.
Good luck !
-
Wow! Lots of intrest! I'm excoted that you guys care. This is one of my first projects for the CX, but I've been programming with my 84+ for over 4 years now, starting with BASIC, but I dabbled in assembly (Hex codes only tho, I really don't use computers for programming), and when Axe came out I used that. Currently, I've written a small 3d cube renderer in Lua, a classic bouncing ball (DVD screensaver), and a GOL simulator. If anyone wants the source code, I can post them on Tuesday or Thursday. This project grew out of the GOL sim, as I finally got the hang of Lua tables. I currently don't have any gravity or physics implemented (Builderboy, please forgive me :P), and have a fixed world size. However, I do have world slices implemented (ie Terraria mode). Basically, the world is a (sparse) 3-d table. The -1 element (w
- [y][-1]) of each square (w
- [y]) is the color shown on the map, as its the top block. My worldgens pretty bad though, as I have no idea how to make the kind of terrain minecraft has. Any help's appreciated. Do you want a minimap view in Terraria mode? Thanks for the support, I'll at least post a block list and some plans in my first post soon, if not beuatiful screenies. Also, I don't know how to animate screenies, but static one's are planned to be released thursday at the earliest, if I get sprites working. Anyone know a good tutorial for making them on-calc?
-
game of life, post it!
Also is the 3d cube renderer perspective or orthographic?
-
Sorry for the double post, but I see that some people were already working on this. Oops. I did see Tiny craft, was excited for a while and thought about getting involved, but I couldn't put in the time (EXAMS, scourge of the student coder). I believe it has stalled AND it was for the 84+ series. With the extra memory of the nSpires, this could become much bigger. Right now, this is basically minecraft creative w/o mobs (for now) and w/very few blocks and no redstone, till I have some idea of how redstone works in actual minecraft. BTW, does anyone know the ComputerCraft mod? I think it might be easier to incorporate (at least the computers) then you think. Also, my projected timeline is that I'll post alpha by Sunday. Crossing fingers :-)
-
perspective,
the GOL uses a fixed matrix, but I'll post it anyways soon.
game of life, post it!
Also is the 3d cube renderer perspective or orthographic?
-
Luckily, it's not a doublepost. (thats what you get for using so much tux avatars XD)
Also this is for the CX not? Then it's all right, tinycraft is for the 84+ series.
edit: woah huh? :confused:
-
Yup CX to start, back-compatibility as soon as I have time.
-
I made something like this for the TI-83+/84+/SE. I did it using XLib. You can find it in the Cemetech archives
-
@Linux Tinycraft died. The authors decided to cancel it completely. I hope your Minecraft game doesn't know the same fate as most others.
-
I hope not... I do have support from a group at school who might help me plan some.
-
That's good, and also feel free to ask help in the Lua programming section if you ever run into troubles with some coding. :)
-
Thanks, I appreciate having community support. It gives me a warm fuzzy feeling!
-
This would be great, don't hesitate to ask questions for the coding too if you have some, we can help :) i hope the alpha comes out soon
-
It'll be awesome to see terraria in nspire. :)
-
FOV, seems possible...maybe with a distance formula with onchange(x,y,z) events and viewed property in table each cell. No lighting for now though.
I too prefer the side-view style for a game such as this. Do you plan to have some sort of field of view code, or something equivalent such that people can only see area's they have been in before? I think that would be cool and useful, and it would make exploring caves and stuff more interesting because you don't necessarily know what is coming up, and you would have to dig and explore to find minerals and stuff.
Can't wait for some screenies!
-
side-view seems perfect indeed.
-
By field of view, do you mean like fog of war in Joltima for the 83+? That would be interesting, although would it cause lag?
-
I don't think field of view should present too much of a problem - it may even help reduce the number of sprites to be drawn if you do it right.
-
Oh, right, I didn't think about that part. Draw black tiles instead of actual sprites. But I'm a bit concerned about the complex algorithm. Is that complicated to implement such thing in any language? I remember Michael_Lee tried something similar last year in his game Light and it was extremely slow. Joltima, on the other hand, manages to do it fine and the Nspire is 120 MHz.
-
I think with this game it could be implemented in a much different way that would actually be better and faster. The way I would do it is to have all tiles in the world either hidden or visible. The tiles above ground would all be visible, and all the tiles below ground (including caves) would be hidden. Whenever you are able to see a hidden tile, it would become visible permanently, that way if you explore a cave you would be able to see all the areas you had already explored, and the areas you haven't would still be dark.
-
I know in Terraria it's more like any tiles around you or a light source show up, and those that don't fade to black.
-
builderboy, that seems like a good idea. I'll try that. BTW, the other method didn't cause all that much lag, but this is better (and easier to code).
-
Leafy do you mean some kind of circle like if you had a flash light?
-
UPDATE:
Hi guys,
It appears I promised an unrealistic release schedule. I'll work like mad to keep it today, but chances are I'll upload on Saturday or even Sunday. :-(. But on the upside, I have lighting working, mining partially working and inventoruy partially working. If anyone has a 7x7 iron ore sprite, it would be appreciated (writing sprites by hand on the calc is hard!).
If you don't get an upload by 2:30, you know what to expect now.
-
something lik ethis?
(http://img.removedfromgame.com/imgs/iron%20ore.jpg)
-
Slightly functional Pre-alpha available on first post. Docs coming soon. ("." to switch views, there is a menu, please comment)
-
Linuxgeek, I have a little request.
Could you please please use indentation for your code?
I almost get a hard attack looking through it :P
I've been indenting it manually until a point where there are syntax errors (I think).
function create(mode)
t=1/2
timer.start(t)
sprites={image.new("\007\000\000\000\007\000\000\000\000\000\000\000\014\000\000\000\016\000\001\000\031\128\031\252\224\131\031\128\031\252\224\131\031\128\031\252\224\131\031\128\031\252\224\131\031\128\031\252\224\131\031\128\031\252\224\131\031\128\031\252\224\131\031\128\031\252\224\131\031\128\031\252\224\131\031\128\031\252\224\131\031\128\031\252\224\131\031\128\031\252\224\131\031\128\031\252\224\131\031\128\031\252\224\131\031\128\031\252\224\131\031\128\031\252\224\131\031\128")}
inventory={current=1,{type=0,amount=0},{type=0,amount=0},{type=0,amount=0},{type=0,amount=0},{type=0,amount=0},{type=0,amount=0},{type=0,amount=0},{type=0,amount=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()>0.3 then
color[x][y][z].type=1
elseif math.random()>0.3 then
color[x][y][z].type=2
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 on.charIn(ch)
c=ch
end
function on.timer()
platform.window:invalidate()
end
function on.paint(gc)
--BG
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()
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=-1
for i=1,8 do
if inventory[1].type==color[position[1]][position[2]][position[3]].type then
end
if not inventory[color[position[1]][position[2]][position[3]].type] then
inventory[color[position[1]][position[2]][position[3]].type]=1
else
inventory[color[position[1]][position[2]][position[3]].type]=inventory[color[position[1]][position[2]][position[3]].type]+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
top=1
for y=position[2]+1,ylen do
if top==1 and color[x][y][z] then
top=y
end
end
if x==position[1] and z==position[3] then
gc:drawImage(sprites[1],x*j-j*0.5-1,z*j-j*0.5-1)
else
--Lighting/fog
if color[x][top][z].visited==false then
d = (math.sqrt((x-position[1])*(x-position[1])+(top-position[2])*(top-position[2])+(z-position[3])*(z-position[3])))
d=1-(d/ylen)
if d<0 then
d=0
elseif d>1 then
d=1
end
else
d=1
end
--Color picker
top=color[x][top][z].type
if top==0 then
gc:setColorRGB(255*d,255*d,255*d)
elseif top==1 then
gc:setColorRGB(150*d,100*d,50*d)
elseif top==2 then
gc:setColorRGB(150*d,150*d,150*d)
elseif top==3 then
gc:setColorRGB(200*d,200*d,200*d)
end
gc:fillRect(x*j-j*0.5-1,z*j-j*0.5-1,j-1,j-1)
end
end
end
elseif view==1 then
for y=1,xlen do
for z=1,ylen do
top=position[1]
--for x=position[1]+1,ylen do
--if top==1 and color[x][y][z] then
--top=x
--end
--end
if y==position[2] and z==position[3] then
gc:drawImage(sprites[1],y*j-j*0.5-1,z*j-j*0.5-1)
else
--Lighting/fog
if not color[top][y][z].visited then
d = (math.sqrt((top-position[1])*(top-position[1])+(y-position[2])*(y-position[2])+(z-position[3])*(z-position[3])))
d=1-(d/ylen*3)
if d<0 then
d=0
elseif d>1 then
d=1
end
else
d=1
end
--Color picker
top=color[top][y][z].type
if top==0 then
gc:setColorRGB(255*d,255*d,255*d)
elseif top==1 then
gc:setColorRGB(150*d,100*d,50*d)
elseif top==2 then
gc:setColorRGB(150*d,150*d,150*d)
elseif top==3 then
gc:setColorRGB(200*d,200*d,200*d)
end
gc:fillRect(y*j-j*0.5-1,z*j-j*0.5-1,j-1,j-1)
end
end
end
elseif view==2 then
for x=1,xlen do
for y=1,ylen do
top=position[3]
--for z=position[1]+1,ylen do
--if top==1 and color[x][y][z] then
--top=z
--end
--end
if x==position[1] and y==position[2] then
gc:drawImage(sprites[1],x*j-j*0.5-1,y*j-j*0.5-1)
else
--Lighting/fog
if color[x][y][top].visited==false then
d = (math.sqrt((x-position[1])*(x-position[1])+(y-position[2])*(y-position[2])+(top-position[3])*(top-position[3])))
d=1-(d/ylen*3)
if d<0 then
d=0
elseif d>1 then
d=1
end
else
d=1
end
--Color picker
top=color[x][y][top].type
if top==0 then
gc:setColorRGB(255*d,255*d,255*d)
elseif top==1 then
gc:setColorRGB(150*d,100*d,50*d)
elseif top==2 then
gc:setColorRGB(150*d,150*d,150*d)
elseif top==3 then
gc:setColorRGB(200*d,200*d,200*d)
end
gc:fillRect(x*j-j*0.5-1,y*j-j*0.5-1,j-1,j-1)
end
end
end
end
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 then
color[coords[1]][coords[2]][coords[3]].type=1
end
end
-
The function on.paint misses an END (you can see this fairly easy with notepad++). I added it, but all I can see is a blue screen...
I would also recommend (apart of indenting the code) is that since I saw several pieces of code that repeats, it should be good to identify them & create a function for them, like for example, the color picker.
Something like this could do:
function color_picker(gc, top)
if top==0 then
gc:setColorRGB(255*d,255*d,255*d)
elseif top==1 then
gc:setColorRGB(150*d,100*d,50*d)
elseif top==2 then
gc:setColorRGB(150*d,150*d,150*d)
elseif top==3 then
gc:setColorRGB(200*d,200*d,200*d)
end
end
^This can be optimized, but I think is ok for now...
This will make the code more legible
-
There are many things that can be changed, but the most important thing right now is identation.
Getting used to it will be a very great help. Do not under estimate it ;)
You will also see your bugs much clearer.
-
Hi all,
I thoughtlessly uploaded a version where I was still working on the inventory. Fixed. Hopefully, I'll be able to use LuaCS to help prettify this code. Update available tomorrow (maybe docs, maybe trees, I'm still deciding). Oh, and the code prettying is last priority: First I want to have something with crafting, then it will start to be more like minecraft then the current version.
-
The prettying is not a last priority. It is a coding style that will help you a great deal.
Trust me, your code will be a lot more clear and easy to work with.
Normally you use indentation while programming ;)
Another thing you should know is that LuaCS is still a bit buggy, and might not be suitable for development.
Anyway, good luck!
-
I agree with jim, identation is really useful.
It's a good habit, because it doesn't just make your code prettier, but it makes it much clearer (especially for other people if you need help)
Anyway, it's nice to see progress on this :)
EDIT :
I modified one line in your code and got it to work... The results are quite strange (maybe my modification is wrong).
It displays a black grid on a white background, and sometimes, randomly, it displays a gray gradient. (see attachment)
-
Yeah, I get the same result in PCspire.
But I guess he is still busy on it, so I'm patient :)
-
I got a crash when using the click button, it throws an error on the function on.mouseDown(x,y) on the last conditional (IF)
-
Indenting is hard on the calculator, as tab moves to the next line :-(. LuaCS is definitely beta, it is slower then using notes. To use theis project (no name yet, post names if you want one), use d-pad or number keys to move around, "." to switch views, and the world is initially clear. press menu, then reset to build a new one. view 0 (default) is top down, views 2 and 3 are different sides. letters a-g switch inventory slot. CODE IS UPDATED AS OF 04/15/2012 09:14 EST
-
I agree indenting helps, but not on-calc IMHO. It makes the code even harder to read because the screen is too small (especially on a 83+ where only 16 chars fit in one line). Even on the computer it can be annoying on some editors, because tab doesn't produce the same indentation lenght every line.
Anyway any progress, since what matters the most is what the code do (assuming it does it well)? I'm curious how well this project will go, since I have been waiting for a Minecraft-style clone for a long while.
-
Trees work, as do dirt and stone. I'm working on crafting today (as I've been for a while) and expect to upload an update today.
-
Indenting is hard on the calculator, as tab moves to the next line :-(.
I think I just put in two spaces as an indent. Works well enough!
Then Notepad++ should do indenting very nicely on the PC
Nice progress you have here so far linuxgeek.
-
May I ask about your progress so far?
-
Hi guys, sorry I haven't posted in a while (finals cramming :P). Right now, I am working on crafting. If I can get crafting working, I will release another version. My current version doesn't work, as you can move around, but no blocks can be broken (pickax code is broken). Is it worth it to try and 3dify it? I am having trouble finding a good tutorial (mostly, they let an engine do the math).
-
Could you post a TNS file?
i have tried compiling this but as soon as I copy the machine code into the student software it instantly crashes.
-
By the way, will it be possible to cycle through your various equipped items like how you can cycle through guns in a FPS? I noticed many Minecraft clones lacks this and it can be annoying to have to use the number keys everytime. Also in the original game, when you ran out of slots to equip items on, you had to open your inventory everytime.
-
Is this project still continued or has it been terminated?
-
Probably been inactive for a while. It's an ambitious project. Besides there are several similar projects also going on.
PS: Haven't posted much in a few months
-
Yeah Minecraft is really ambitious. Notice how every other project like this died. X.x
Also welcome back Jonius7
-
Its been a little slow to develop lately, with the contest and summer work. However, I am starting to make le crafting table! Coming soon to a calculator near you! Also, to answer DJ_O's question, you should be able to cycle tools: I hooked that functionality to -/+
-
Nice to hear :)
-
Any updates?
-
Looks completely awesome to me! However, there might be some *lag* issues. You'll have to make it pretty lightweight for it to run on such low hardware specs.
-
Looks completely awesome to me! However, there might be some *lag* issues. You'll have to make it pretty lightweight for it to run on such low hardware specs.
It's in Lua so it shouldn't have a problem supposedly. If it did I'd guess it would have been mentioned, so for right now I think its a ok :)
-
Oh, the creator has been gone for 2 months now... (double post since last one was a month ago)