IO File Handling ?
Moderators: Shine, Insert_witty_name
IO File Handling ?
Is this possible on Lua ? I wish to make games but it would be much harder to create level files and such within my code. I was wondering if it's possible to load files into tables (arrays) in Lua.
edit:if it's not possible yet, would it be possible to declare my level tables in a separate file as a const.. such as
map={ {1,2,3}, {1,2,3} .... etc... }
and then use dofile("level1.lua") to load in that array ?
edit:if it's not possible yet, would it be possible to declare my level tables in a separate file as a const.. such as
map={ {1,2,3}, {1,2,3} .... etc... }
and then use dofile("level1.lua") to load in that array ?
both are possible. currently i use the dofile method to load my levels.. i also have a level editor that uses the io library to create .lua files on the fly..
unfortunately, the documentation kind of sucks.
http://www.lua.org/manual/5.0/manual.html#5.6
i suggest checking out the source code for one of those lua notepad editor programs, that's what i based my code off of.
unfortunately, the documentation kind of sucks.
http://www.lua.org/manual/5.0/manual.html#5.6
i suggest checking out the source code for one of those lua notepad editor programs, that's what i based my code off of.
Chaosmachine Studios: High Quality Homebrew.
60fps most of the time.. i've done a lot of optimizing..
things start to drop below that if i'm drawing more than about 80 16x16 tiles per refresh.
things start to drop below that if i'm drawing more than about 80 16x16 tiles per refresh.
Last edited by chaos on Tue Sep 13, 2005 1:29 pm, edited 1 time in total.
Chaosmachine Studios: High Quality Homebrew.
You can blit the tiles to an offscreen image first, which is created on level start and then blit this to screen on every vsync (or multiple offscreen images, which are updated, when you are scrolling out of range of one image). For many small tiles the overhead for blitting is high.chaos wrote:60fps most of the time.. i've done a lot of optimizing..
things start to drop below that if i'm drawing more than about 80 16x16 tiles per refresh.
Not a bad idea. It's a scrolling tile engine though. Would there be a problem if I am creating the primary level image as like 500x500 and then blit that on every vsync then draw my sprites on top of it ?Shine wrote:You can blit the tiles to an offscreen image first, which is created on level start and then blit this to screen on every vsync (or multiple offscreen images, which are updated, when you are scrolling out of range of one image). For many small tiles the overhead for blitting is high.chaos wrote:60fps most of the time.. i've done a lot of optimizing..
things start to drop below that if i'm drawing more than about 80 16x16 tiles per refresh.
i actually found this method to be slower in my initial testing.. i'll have to take another look at it.Shine wrote:You can blit the tiles to an offscreen image first, which is created on level start and then blit this to screen on every vsync (or multiple offscreen images, which are updated, when you are scrolling out of range of one image). For many small tiles the overhead for blitting is high.chaos wrote:60fps most of the time.. i've done a lot of optimizing..
things start to drop below that if i'm drawing more than about 80 16x16 tiles per refresh.
Chaosmachine Studios: High Quality Homebrew.
Re: IO File Handling ?
you can even create your own level files (as i am going to for bomberman)Giuliano wrote:Is this possible on Lua ? I wish to make games but it would be much harder to create level files and such within my code. I was wondering if it's possible to load files into tables (arrays) in Lua.
you can use my Explode/Implode function to convert a string to a table
greets
Lumo
After a small test I'm guessing you said "or multiple offscreen images when you are scrolling out of range" because I can't create a 1000x1000 image for the offscreen buffer, it's too big .. ?Shine wrote:You can blit the tiles to an offscreen image first, which is created on level start and then blit this to screen on every vsync (or multiple offscreen images, which are updated, when you are scrolling out of range of one image). For many small tiles the overhead for blitting is high.chaos wrote:60fps most of the time.. i've done a lot of optimizing..
things start to drop below that if i'm drawing more than about 80 16x16 tiles per refresh.
Dunno, 500x500 didnt work for me. I just made them 240x240 and I am almost done w/ my code that allows for scrolling and connects them up to it's seamless to the user :)... I just dont really know what kind of game I will be making.chaos wrote:maximum texture/image size is 512x512, afaik.
Btw, it's a hellllll lot faster for me .. running at full speed and I am drawing a 352x272 screen of 16x16 tiles
Okay.. here it is.. check it out.. I did what Shine said and the speed is a hell lot faster.. If you are interested to see how to make a scrolling tile engine w/ offscreen images and make it seamless this will show you how (a little complicated so don't expect to understand in one reading of the code) .. the white part is going to be a stats panel
Any ideas of what kind of game I should make ?
ps: please don't use my tiles.. the bird is from Mario
Here you go:http://www.peoplegrade.com/g/ATest.zip
Any ideas of what kind of game I should make ?
ps: please don't use my tiles.. the bird is from Mario
Here you go:http://www.peoplegrade.com/g/ATest.zip
For loading images this is right, but for creating currently it is 480x272, I'll fix this in the next release, there is no reason why it should not be 512x512. Perhaps even larger images maybe possible, I'll check this. Of course, blitting maybe slower then, because of less good cache usage.chaos wrote:maximum texture/image size is 512x512, afaik.
I made it 240x240 and it's very fast, check out the file I uploadedShine wrote:For loading images this is right, but for creating currently it is 480x272, I'll fix this in the next release, there is no reason why it should not be 512x512. Perhaps even larger images maybe possible, I'll check this. Of course, blitting maybe slower then, because of less good cache usage.chaos wrote:maximum texture/image size is 512x512, afaik.
This is nice, now we can make all those cool old games like R-Type, Turrican, Giana Sisters etc.Giuliano wrote: I made it 240x240 and it's very fast, check out the file I uploaded
I've found a Java applet which simulates the good old C64 games in your browser: http://www.dreamfabric.com/c64/ Would you believe it some 20 years ago, if someone tells you that you can download a full emulation of your C64 in some seconds in a browser window, including a running game? Oh yes, and some "tilesets" http://kofler.dot.at/c64/font_14.html but some are "multi-color" fonts, with 2 pixels per pixel and maybe some are used as C64 "extended-color" fonts, with different foreground and background colors per char :-)
BTW: you can use image:width and image:height in your sprite class instead of passing it in the constructor.
I'll check those out when I get back home. I have college classes right now :)Shine wrote:This is nice, now we can make all those cool old games like R-Type, Turrican, Giana Sisters etc.Giuliano wrote: I made it 240x240 and it's very fast, check out the file I uploaded
I've found a Java applet which simulates the good old C64 games in your browser: http://www.dreamfabric.com/c64/ Would you believe it some 20 years ago, if someone tells you that you can download a full emulation of your C64 in some seconds in a browser window, including a running game? Oh yes, and some "tilesets" http://kofler.dot.at/c64/font_14.html but some are "multi-color" fonts, with 2 pixels per pixel and maybe some are used as C64 "extended-color" fonts, with different foreground and background colors per char :-)
BTW: you can use image:width and image:height in your sprite class instead of passing it in the constructor.
I can't use image:width and image:height because it's the "frame" sprite width and height not the image.. the image contains all the animation and such.. however, since there are always 4 sprites in a row I could do image:width()/4 and then do a mod to see how many frames are in the image (it varies)