Color library works just need a game

Advice on general approaches or feasibility and discussions about game design

Color library works just need a game

Postby Duhjoker » Sun Oct 30, 2016 1:23 am

Well I finally got the color library fixed so now it's time to make a game. I decided on Dragonwarrior (the NES version) as the first game.

gonna be a pretty big game to start out with. All the graphics are 16-bit but it's gonna be pretty monotonous to start with. Some sprites use 4 colors so now I have to go through the long process of loading my png's to the encoder and copy the binary.

Would be awesome if there was a bitmap encoder that allowed you too copy and paste the binary or hex code produced.

Any way doing the world map is gonna be the hardest part since I have to layer them on top of each other to get the colors. Fortunately summoner123's tilemap() function won't take up hardly any of flash space so that means way bigger games.

Also looking for beta testers to try the updated library
User avatar
Duhjoker
 
Posts: 446
Joined: Sat Jul 02, 2016 4:57 am
Location: Where Palm trees grow

Re: Color library works just need a game

Postby rodot » Mon Oct 31, 2016 1:20 pm

I'm not sure I got your idea, but If you plan to draw each color bitmap as a stack of monochrome bitmaps, it's going to be pretty slow and memory inefficient. Maybe you should start with a simple game to get started with your fresh library (and debug it haha), and make the new functions you will need ?
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: Color library works just need a game

Postby Duhjoker » Tue Nov 01, 2016 5:22 am

What function do I need to make? Can you elaborate?

Don't get why it would be so inefficient? It works the same way the regular library does just with color added. Most of the sprites are 3 color with some at 4. It's a lot of sprites but I've been making games with three color sprites since the beginning.

What do you suggest to make it more efficient?

Is there a way for the game sketch to pull bit maps from and use in a way where I can display a Sprite at full color? I've looked and looked and looked for an easier option but all I can find is what's already in the Gamebuino and adafruit GFX libraries.
User avatar
Duhjoker
 
Posts: 446
Joined: Sat Jul 02, 2016 4:57 am
Location: Where Palm trees grow

Re: Color library works just need a game

Postby rodot » Tue Nov 01, 2016 9:06 am

Well I don't know, color bitmaps functions for example ;)

Well by stacking color bitmaps, your code is going to be pretty obfuscated, but that's none of my business ^^
Let say you have a 16x16 sprite :
Monochrome = 16x16x1 = 256 bits (black&white = 2 colors)
4 x monochrome = 512 x 4 = 1024 bits
4 colors indexed = 16x16x2 = 512 bits => half of the memory
But if you have more than 4 colors in your whole game it's going to be a mess to handle all the different color indexes.
16 colors indexed = 16x16x4 = 1024 bits => same size but WAY cleaner and faster code .

Because to draw 4 monochrome bitmaps your have to iterates through 4 bitmaps instead of 1, and to do a lot of bitwise operations. That's why it would be slower.
And when then you have to call 4 drawBitmap functions for each sprite, and remember which layers is which color, which is obfuscated code.

Reminder :
On 1 bit you can store 1^2 = 2 colors
On 2 bits you can store 2^2 = 4 colors
On 4 bits you can store 4^2 = 16 colors
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: Color library works just need a game

Postby Duhjoker » Tue Nov 01, 2016 9:25 am

Ok i get that. But what color bitmap functions? By bitmap functions are color as long as its one at a time and i havent found a way to store full color bitmaps and display them from progmem. If you know of way PLEASE link me to it. But like i said ive looked and looked for a way to do so but i cant find one.

Plus all my bitmaps have no back ground to them. I used the no background function in the library for that reason. There wont be any overlap from using bitmaps with a background color.

Edit::: ok so far I have 197 no background mono color bitmaps. One for each color used and no pixels overlapping other pixels. Tedious work done by erasing all pixels that aren't the chosen color. Sooooooo bigger game needs more Progmem space. Out of 256k it will use maybe 50k. At 197 bitmaps it used 25,000B right now.

Now the only other way I could think of doing is storing 4 color bitmaps on the sd card and trying to pull them off that way but have no idea if it would work or if it would be fast enough.

And I'm pretty sure the single chip controller in the LCD takes care of the memory for the colors.

Not trying to be argumentative but I don't get the problem. If I'm using the tilemap function OG GB with three color, white, black and grey, I would still have to provide a non-background bitmap for each color. That's exactly how I've been building the legend of Zelda port and it works well with very lil Progmem used since it's only storing each bitmap only once in Progmem. Plus the library is set to work in two ways.

1 you use the OG GB bitmap functions and use setcolor() or

2 use the color drawBitMap command from the added functions that belong to adafruits teensy library.
User avatar
Duhjoker
 
Posts: 446
Joined: Sat Jul 02, 2016 4:57 am
Location: Where Palm trees grow

Re: Color library works just need a game

Postby Duhjoker » Mon Nov 14, 2016 9:02 pm

Ok so I finally got done encoding all PC'S and NPC's sprites last night. Looks to be about 70kb out of 256k. I've been investigating other ways of storing full color bitmaps and using them. I found 2 ways in which it could be done.......

1st I could use the sd card as my storage and use drawXbitmap() but I have no idea wether that option is viable for gaming.

2nd someone pointed out to me the functions TFT.pushcolors() to display the bitmaps in color from Progmem. Only problem with this solution is that there is no reference and the person who pointed it out (also the writer for the code) refuses to explain how to use the functio because "my project doesn't interest him". His own words.

But here's where my head is at. If I draw the bitmaps in the same way the OG GB library works I can automatically call each bitmap with out a background color but with a foreground color of my choosing.

gb.display.drawbitmap(16,16,bitmapname, 110, 88, colorname)

I could also call the same function with background and foreground but I have very few tiles that only use two colors all the rest are 3 colors. But drawing a bitmap for each color takes up space. But wouldn't storing three color bitmaps straight up still use the same amount of bits as separating them?

Edit::: would it be possible to store the world maps and backgrounds on the SD then draw the character sprites on top? What is the loss in speed from Progmem to sd
User avatar
Duhjoker
 
Posts: 446
Joined: Sat Jul 02, 2016 4:57 am
Location: Where Palm trees grow

Re: Color library works just need a game

Postby Duhjoker » Tue Dec 13, 2016 4:55 am

Update on the project.

We now have an SD function for drawing bitmaps instead of using Progmem. The original concept was drawn up by Mougino but with advice from here and there I was able to update it and it now resides in library and set to go.

The function called simply DrawBitmapFromSD uses petitfatfs to open up a directory on the SD card and display the bitmap images.

Now this is a prototype function that I'm hoping people in the future will be able optimize or come up with better, but it should break that Progmem barrier. I also hooked it up with a tile map function so you can create tilemaps using the tilemapper although it might be better to store the whole bitmap. Any way it should still work like the original Gamebuino library. At least I designed it so.

It will probably not be very good for animations yet but with the reccomended teeny3.2 or higher with its 256k+ you shouldn't have a problem with your animated sprites. By which I mean bitmaps that switch back and fourth like walking.

Edit::::
After doing some thinking I think this will be as far as I go with the library for now. what I realized was that it would be more efficient to store terrain bitmap data and sprites from Progmem. While the SD is for character bitmaps and such. My reasoning is that it takes more processing power to display so many bitmaps in array. Instead put all the terrain in Progmem and use the tilemap routine. Then you can draw your character sprites from sd on the tilemap. So it's only processing one grouping bitmaps per character per movement.

My full color terrain tiles split into separate colors for the dune RPG only use 22Kb, it's the characters and monsters and items that need the space.
User avatar
Duhjoker
 
Posts: 446
Joined: Sat Jul 02, 2016 4:57 am
Location: Where Palm trees grow


Return to Project Guidance & Game development

Who is online

Users browsing this forum: No registered users and 23 guests

cron