Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
21 May, 2013, 15:14:50 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: 1 2 [3] 4 5   Go Down
  Print  
Author Topic: Minicraft / Terraria clone -  (Read 3687 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
linuxgeek96
LV3 Member (Next: 100)
***
Offline Offline

Last Login: Today at 14:01:49
Date Registered: 17 October, 2011, 18:15:24
Location: WLHS
Posts: 96


Topic starter
Total Post Ratings: +3

View Profile WWW
« Reply #30 on: 10 April, 2012, 00:25:25 »
0

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!
Logged

aeTIos
You got stair'd!
LV12 Extreme Poster (Next: 5000)
************
Offline Offline

Gender: Male
Last Login: Today at 12:50:50
Date Registered: 15 September, 2010, 06:00:00
Location: Netherlands, Overijssel
Posts: 3113


Total Post Ratings: +120

View Profile
« Reply #31 on: 11 April, 2012, 04:24:31 »
0

side-view seems perfect indeed.
Logged

If something above sounds rude, feel free to vote it down, it was not meant to be rude<<lolol
--Always stay relAXEd!--


Spoiler for Hidden:


[







Spoiler for Still Alive:
This was a triumph.
I'm making a note here: HUGE SUCCESS.
It's hard to overstate my satisfaction.

Aperture Science:
We do what we must because we can.
For the good of all of us
Except the ones who are dead.

But there's no sense crying over every mistake
You just keep on trying till you run out of cake
And the science gets done and you make a neat gun
For the people who are still alive.

I'm not even angry.
I'm being so sincere right now.
Even though you broke my heart and killed me.
And tore me to pieces.
And threw every piece into a fire.
As they burned it hurt because
I was so happy for you.

Now these points of data make a beautiful line
And we're out of beta we're releasing on time.
So I'm GLaD I got burned think of all the things we learned
For the people who are still alive.

Go ahead and leave me.
I think I prefer to stay inside.
Maybe you'll find someone else to help you.
Maybe Black Mesa -
THAT WAS A JOKE. HA HA, FAT CHANCE.
Anyway, this cake is great:
It's so delicious and moist.

Look at me still talking when there's science to do.
When I look out there it makes me GLaD I'm not you.
I've experiments to run there is research to be done
On the people who are still alive

And believe me I am still alive.
I'm doing science and I'm still alive.
I feel FANTASTIC and I'm still alive.
While you're dying I'll be still alive.
And when you're dead I will be still alive.

Still alive
Still alive
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 08:22:03
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50208


Total Post Ratings: +2613

View Profile WWW
« Reply #32 on: 11 April, 2012, 04:35:34 »
0

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?
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
leafy
Coder Of Tomorrow
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Yesterday at 21:59:01
Date Registered: 26 December, 2010, 05:27:03
Location: the ninth circle of hell
Posts: 1545


Total Post Ratings: +371

View Profile WWW
« Reply #33 on: 11 April, 2012, 04:51:50 »
0

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.
Logged

In-progress: Blastlabs, TMJO, qb?, VVVVVV?
Finished: Tag, Tap, MFQT, Nyan
Dead: Graviter
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 08:22:03
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50208


Total Post Ratings: +2613

View Profile WWW
« Reply #34 on: 11 April, 2012, 04:54:47 »
0

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.
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
Builderboy
Physics Guru
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: Today at 11:56:23
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5642


Total Post Ratings: +589

View Profile
« Reply #35 on: 11 April, 2012, 05:19:09 »
0

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.
Logged

leafy
Coder Of Tomorrow
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Yesterday at 21:59:01
Date Registered: 26 December, 2010, 05:27:03
Location: the ninth circle of hell
Posts: 1545


Total Post Ratings: +371

View Profile WWW
« Reply #36 on: 11 April, 2012, 05:49:33 »
0

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.
Logged

In-progress: Blastlabs, TMJO, qb?, VVVVVV?
Finished: Tag, Tap, MFQT, Nyan
Dead: Graviter
linuxgeek96
LV3 Member (Next: 100)
***
Offline Offline

Last Login: Today at 14:01:49
Date Registered: 17 October, 2011, 18:15:24
Location: WLHS
Posts: 96


Topic starter
Total Post Ratings: +3

View Profile WWW
« Reply #37 on: 11 April, 2012, 06:13:31 »
0

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).
Logged

DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 08:22:03
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50208


Total Post Ratings: +2613

View Profile WWW
« Reply #38 on: 11 April, 2012, 06:43:28 »
0

Leafy do you mean some kind of circle like if you had a flash light?
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
linuxgeek96
LV3 Member (Next: 100)
***
Offline Offline

Last Login: Today at 14:01:49
Date Registered: 17 October, 2011, 18:15:24
Location: WLHS
Posts: 96


Topic starter
Total Post Ratings: +3

View Profile WWW
« Reply #39 on: 12 April, 2012, 19:15:40 »
0

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.
Logged

Nick
LV9 Veteran (Next: 1337)
*********
Offline Offline

Gender: Male
Last Login: Yesterday at 20:44:19
Date Registered: 05 June, 2011, 20:01:07
Location: 51° 12′ 34″ N, 3° 13′ 31″ E
Posts: 1178


Total Post Ratings: +158

View Profile WWW
« Reply #40 on: 12 April, 2012, 19:41:22 »
0

something lik ethis?

Logged

linuxgeek96
LV3 Member (Next: 100)
***
Offline Offline

Last Login: Today at 14:01:49
Date Registered: 17 October, 2011, 18:15:24
Location: WLHS
Posts: 96


Topic starter
Total Post Ratings: +3

View Profile WWW
« Reply #41 on: 13 April, 2012, 02:10:36 »
0

Slightly functional Pre-alpha available on first post. Docs coming soon. ("." to switch views, there is a menu, please comment)
Logged

Jim Bauwens
Lua! Nspire! Linux!
Editor
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 00:39:35
Date Registered: 28 February, 2011, 22:32:12
Location: Belgium
Posts: 1733


Total Post Ratings: +180

View Profile WWW
« Reply #42 on: 13 April, 2012, 02:32:12 »
0

Linuxgeek, I have a little request.
Could you please please use indentation for your code?
I almost get a hard attack looking through it Tongue

I've been indenting it manually until a point where there are syntax errors (I think).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
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

Logged

someone
LV3 Member (Next: 100)
***
Offline Offline

Gender: Male
Last Login: Today at 00:05:00
Date Registered: 12 January, 2012, 19:07:23
Posts: 48


Total Post Ratings: +9

View Profile
« Reply #43 on: 13 April, 2012, 06:07:16 »
0

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:

1
2
3
4
5
6
7
8
9
10
11
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
Logged
Jim Bauwens
Lua! Nspire! Linux!
Editor
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 00:39:35
Date Registered: 28 February, 2011, 22:32:12
Location: Belgium
Posts: 1733


Total Post Ratings: +180

View Profile WWW
« Reply #44 on: 13 April, 2012, 06:12:25 »
0

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 Wink
You will also see your bugs much clearer.
Logged

Pages: 1 2 [3] 4 5   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.353 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.