Tile map collision and some other basic questions


(Jeremy Wood) #1

Hi

I’m thinking about trying to make a color library for the arduboy if I can get some support but I have some questions.

Has any one come up with a tilemap engine? I have one but I can’t seem to get it to work with the color arguments added. Is there an example I can look at.

What about collision detection? I’m not seeing any code in the library. Can I get a link


(Trevor Ancona) #2

Well, the arduboy doesn’t have color besides black, white and inverted, so I’m not sure there. But collision detection has to be done manually. Like in my code I’m testing whether the bullet’s x and y coordinates are within the target’s x and y coordinates.


#3

Please check Sprites engine. :smiley:


(Cody) #4

I reckon the first person who makes colour will be a hero


(Jeremy Wood) #5

By support i mean is it easy to get help here?

I would like to update the library as a whole, ive got stuff like a collision and tilemap that would need to be reworked but will improve the overall game building and playing experience and not just the color library.

The only problem is that i need experienced support group to get this done. I just started coding this year so i may ask alot of questions.


(Holmes) #6

There are a few really dedicated members here. They have always helped me, so I am sure they’d be willing to help answer any questions you being up.


(Scott) #7

Have you looked at the Arglib library that is included in the Team A.R.G. games? It’s based on an early version of the Arduboy library and incorporates code from the ArduboyExtra project and also a compressed bitmap draw function. ArduboyExtra has sprite handling, extra button handling functions, and some collision detection functions.

Very shortly, I plan to release an updated version of my Arduboy2 library that includes the additional Arglib functionality.


(Gavin Atkin) #8

The problem with tile maps is that they really need to be implemented differently for different types of games. There isn’t enough storage to have a one-size-fits-all approach. For a platformer tilemap system check out the technical page for Mystic Balloon http://team-arg.org/mybl-technical.html
I’m working on a completely different way of handling tiles for another TEAM arg game. If flash space was not an issue you could just use a byte per tile for every game and all would be right and easy, but it’s not going to get you very far on this device.
For a top down tilemap system you can also check out Virus LQP-79 from TEAM arg http://team-arg.org/vlqp-technical.html


(Holmes) #9

For the games that I’ve made, I have an array of bytes where each byte is a different image.

For instance, a my could look like this:

const unsigned char levelmap[][112] PROGMEM = {
	{ // Level 1
		1,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  2,
		6, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,  6,
		6, 50, 50, 50, 50, 37, 50, 37, 50, 12, 50, 50, 50,  6,
		6, 50, 51, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,  6,
		6, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,  6,
		6, 50, 50, 50, 50, 37, 50, 37, 50, 12, 50, 38, 50,  6,
		6, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,  6,
		3,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  4
	},
        //...
}

Whenever I move the character around, I check which space he’s going to move into. If it’s higher than 25, I don’t allow movement since I consider it to be a solid object that I don’t want the player to walk through.

You could alternatively use halfbytes if you know how to do that where every byte either starts with 0 or 1, which makes the tile solid or walkable.

My Circuit Dude game has a really simple/easy map system that includes collision detection. Try to check out the source code whenever it’s out for a more detailed explaination on that.


(Jeremy Wood) #11

I could call each function with a setcolor() function which will take up more space because i would have to call draw tilemap blah blah blah as many times as needed for colors. I can afford it with no problem with with 256k flash. But i would rather have the color parts built into those which seriously optimize the efficiency of the above and allow for more gaming options.

Heres a part list thats around $50

Teensy 3.2 $25
Usb charger module $4.99
Buttons $2.99
Color oled tft $4.99
Battery $5
Sd card holder $1.99
Perf board $.99

Thats just as much as an arduboy


(Gavin Atkin) #12

The nice thing about the Arduboy is the design is finished, it’s durable, portable and already has an audience. If I make a game for the Arduboy, there are potentially thousands of people I could reach. If I build my hardware I’m cutting it down to possibly a dozen that want to build the hardware to the exact specification that I did, and it still won’t be very portable.

I really encourage you to re-evaluate everything you are getting with the Arduboy, it really is an awesome device that is worth the price and if you are open to being clever, great games can be made.


(Holmes) #13

I’m actually really interested in what he comes up with. :slight_smile:


(Jeremy Wood) #15

I’m actually a lot closer than I let on I just need help with the drawBitMap functions and adding color but I came up with a better alternative. I just set the color before calling each bitmap function.

I understand about the availability but this is just an option for someone who wants more. if y’all don’t want to help that’s fine but I’m making a color game system either way.


(Gavin Atkin) #16

Are you wanting to draw the entire image in a single color? Or draw the image with every pixel as 16 bit color?


(Holmes) #17

Why not use pallets? Before drawing something, you could define the pallet instead of just a single color.


(Gavin Atkin) #18

That’s what I was going to suggest as well. That would mean each pixel would take a lot less space in memory. If the colors per palette could be kept to 16 (or 15 with transparency?) then it would only take 4 bits per pixel.

A 16x16 pixel image would take 128 bytes. Whereas if everything is uint16_t a 16x16 image would be 512 bytes.

Building a library or engine you’ll want it to be as efficient as possible so that people wanting to push the hardware to it’s limits don’t have to write their own. Retro style graphics typically use palettes anyway since it is more aesthetically pleasing.

That’s probably the approach I’d take anyway. As far as converting the library, you’ll want to find out how your display organizes it’s pixels and organize your display buffer the same way so that you don’t get screen tearing when transferring.