| View previous topic :: View next topic |
| Author |
Message |
Giuliano
Joined: 13 Sep 2005 Posts: 78
|
Posted: Tue Sep 13, 2005 10:30 am Post subject: 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 ? |
|
| Back to top |
|
 |
chaos
Joined: 10 Apr 2005 Posts: 135
|
Posted: Tue Sep 13, 2005 11:58 am Post subject: |
|
|
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. _________________ Chaosmachine Studios: High Quality Homebrew. |
|
| Back to top |
|
 |
Giuliano
Joined: 13 Sep 2005 Posts: 78
|
Posted: Tue Sep 13, 2005 12:42 pm Post subject: |
|
|
Alright thanks. I actually wasn't aware of that lua.org documentation. Makes life much easier.
How is your game doing on speed btw ? |
|
| Back to top |
|
 |
chaos
Joined: 10 Apr 2005 Posts: 135
|
Posted: Tue Sep 13, 2005 12:57 pm Post subject: |
|
|
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.
Last edited by chaos on Tue Sep 13, 2005 1:29 pm; edited 1 time in total |
|
| Back to top |
|
 |
Giuliano
Joined: 13 Sep 2005 Posts: 78
|
Posted: Tue Sep 13, 2005 1:24 pm Post subject: |
|
|
| chaos wrote: | 60fps most of the time.. i've done a lot of optimizing..
things start to drop below than if i'm drawing more than about 80 16x16 tiles per refresh. |
that's only about an 128x128 tile screen... pretty small .. I'm trying to cover a 352x272 tile screen |
|
| Back to top |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Tue Sep 13, 2005 7:43 pm Post subject: |
|
|
| 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. |
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. |
|
| Back to top |
|
 |
Giuliano
Joined: 13 Sep 2005 Posts: 78
|
Posted: Tue Sep 13, 2005 11:16 pm Post subject: |
|
|
| Shine wrote: | | 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. |
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. |
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 ? |
|
| Back to top |
|
 |
chaos
Joined: 10 Apr 2005 Posts: 135
|
Posted: Wed Sep 14, 2005 1:04 am Post subject: |
|
|
| Shine wrote: | | 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. |
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. |
i actually found this method to be slower in my initial testing.. i'll have to take another look at it. _________________ Chaosmachine Studios: High Quality Homebrew. |
|
| Back to top |
|
 |
LuMo
Joined: 21 Aug 2005 Posts: 410 Location: Austria
|
Posted: Wed Sep 14, 2005 3:19 am Post subject: Re: IO File Handling ? |
|
|
| 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 even create your own level files (as i am going to for bomberman)
you can use my Explode/Implode function to convert a string to a table
greets
Lumo |
|
| Back to top |
|
 |
Giuliano
Joined: 13 Sep 2005 Posts: 78
|
Posted: Wed Sep 14, 2005 5:40 am Post subject: |
|
|
| Shine wrote: | | 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. |
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. |
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 .. ? |
|
| Back to top |
|
 |
chaos
Joined: 10 Apr 2005 Posts: 135
|
Posted: Wed Sep 14, 2005 10:03 am Post subject: |
|
|
maximum texture/image size is 512x512, afaik. _________________ Chaosmachine Studios: High Quality Homebrew. |
|
| Back to top |
|
 |
Giuliano
Joined: 13 Sep 2005 Posts: 78
|
Posted: Wed Sep 14, 2005 10:09 am Post subject: |
|
|
| chaos wrote: | | maximum texture/image size is 512x512, afaik. |
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.
Btw, it's a hellllll lot faster for me .. running at full speed and I am drawing a 352x272 screen of 16x16 tiles |
|
| Back to top |
|
 |
Giuliano
Joined: 13 Sep 2005 Posts: 78
|
Posted: Wed Sep 14, 2005 10:57 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Wed Sep 14, 2005 12:11 pm Post subject: |
|
|
| chaos wrote: | | maximum texture/image size is 512x512, afaik. |
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. |
|
| Back to top |
|
 |
Giuliano
Joined: 13 Sep 2005 Posts: 78
|
Posted: Wed Sep 14, 2005 12:25 pm Post subject: |
|
|
| Shine wrote: | | chaos wrote: | | maximum texture/image size is 512x512, afaik. |
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. |
I made it 240x240 and it's very fast, check out the file I uploaded |
|
| Back to top |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Wed Sep 14, 2005 1:07 pm Post subject: |
|
|
| Giuliano wrote: |
I made it 240x240 and it's very fast, check out the file I uploaded |
This is nice, now we can make all those cool old games like R-Type, Turrican, Giana Sisters etc.
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. |
|
| Back to top |
|
 |
Giuliano
Joined: 13 Sep 2005 Posts: 78
|
Posted: Wed Sep 14, 2005 10:01 pm Post subject: |
|
|
| Shine wrote: | | Giuliano wrote: |
I made it 240x240 and it's very fast, check out the file I uploaded |
This is nice, now we can make all those cool old games like R-Type, Turrican, Giana Sisters etc.
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 :)
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) |
|
| Back to top |
|
 |
Giuliano
Joined: 13 Sep 2005 Posts: 78
|
Posted: Thu Sep 15, 2005 5:42 am Post subject: |
|
|
| Those are way too old.. I am hoping to make something newer but w/ 2d graphics |
|
| Back to top |
|
 |
|