TinyCircuits

TinyCircuits Products => User Projects / Code Examples => Topic started by: zet23t on April 02, 2015, 06:54:07 AM

Title: Games / community with the tiny screen and gamepad?
Post by: zet23t on April 02, 2015, 06:54:07 AM
Hey there,
I am working on a 2d space game that utilizes the gamepad and I was wondering if there are others who work on other games as well. I couldn't find much. Is there a community or something alike for exchanging games and ideas?

If you have a tiny gamepad and a tinyscreen, you can give my code a try:
https://codebender.cc/sketch:98686 (https://codebender.cc/sketch:98686)

There's no gameplay yet, but you can fly a spaceship in front of a parallax starfield.

Any feedback is welcome!
Title: Re: Games / community with the tiny screen and gamepad?
Post by: calvinthedestroyer on April 03, 2015, 03:03:28 PM
Looks great, can't wait to see more
Title: Re: Games / community with the tiny screen and gamepad?
Post by: MrAkai on April 03, 2015, 07:02:29 PM
I forked the space invaders demo and added joystick support. 

https://codebender.cc/sketch:100732

It's mostly just pieces from two demos smooshed together now but I hope to flesh it out a bit (multiple rows of baddies, make them move, etc)
Title: Re: Games / community with the tiny screen and gamepad?
Post by: zet23t on April 06, 2015, 12:21:27 PM
Ah, the space invaders game! Yeah, I was thinking to do something more simple than what I am tackling right now, but I had more ambitions. One of the things I worked out was a more generic rendering system with which I can draw rectangles / circles / triangles with. I can't draw many since I have to keep them in memory, but it gives me more flexibility. I am right now working out a UI system to allow me doing something in that world. I am bit shocked how much flash memory that is eating up though D:
Title: Re: Games / community with the tiny screen and gamepad?
Post by: gary_f on May 02, 2015, 12:37:22 PM
I forked the space invaders demo and added joystick support. 
https://codebender.cc/sketch:100732
This is a good start. I like the joystick support and using the right stick to fire. I hope you can get the rest of the game working? Thanks.
Title: Re: Games / community with the tiny screen and gamepad?
Post by: gary_f on May 02, 2015, 12:41:51 PM
I am working on a 2d space game that utilizes the gamepad and I was wondering if there are others who work on other games as well. I couldn't find much. Is there a community or something alike for exchanging games and ideas?

If you have a tiny gamepad and a tinyscreen, you can give my code a try:
https://codebender.cc/sketch:98686 (https://codebender.cc/sketch:98686)

Hi. I tried to run your code in codebender but it said "There was an error compiling". It sounded promising. Do you have any plans to continue working on it?
Thanks.
Title: Re: Games / community with the tiny screen and gamepad?
Post by: jonwingrove on May 03, 2015, 02:44:32 PM
I've started working on this, a tiny Outrun style game:
https://www.youtube.com/watch?v=GYmHtBGt6fU

I'll post the code up soon!
Title: Re: Games / community with the tiny screen and gamepad?
Post by: gary_f on May 03, 2015, 08:02:24 PM
I've started working on this, a tiny Outrun style game:
https://www.youtube.com/watch?v=GYmHtBGt6fU
I'll post the code up soon!
That's really cool! Is it compatible with the Tiny Steering Wheel board? ;)
Title: Re: Games / community with the tiny screen and gamepad?
Post by: Tony Batey on May 04, 2015, 11:05:15 AM
I've got most of a space invaders code down. I just need to add a few details such as a death screen, score counter and have the invaders shoot back. Here this sketch https://codebender.cc/sketch:110168 let me know what you guys think!
Title: Re: Games / community with the tiny screen and gamepad?
Post by: gary_f on May 04, 2015, 04:55:30 PM
I've got most of a space invaders code down. I just need to add a few details such as a death screen, score counter and have the invaders shoot back. Here this sketch https://codebender.cc/sketch:110168 let me know what you guys think!
It's looking good, Tony. Don't make the invaders too mean unless you're going to supply a few barricades to hide behind! Or maybe a special weapon by pulling down on the right stick? (I guess that wouldn't be classic Invaders then)
Title: Re: Games / community with the tiny screen and gamepad?
Post by: jonwingrove on May 04, 2015, 06:30:23 PM
That's really cool! Is it compatible with the Tiny Steering Wheel board? ;)

Thanks :D I'll keep working on it later in the week.
Haha, it'd be great to play it with a wheel! I was thinking of building a miniature arcade cabinet to house it in...

I've been working on some helper stuff for efficiently drawing sprites and tiles - if anyone is interested, I've put it up on github, here:
https://github.com/jonwingrove/tinyscreen-spritetile-lib

Currently the tiling is limited to 8x8 sized tiles - but the sprites drawn on top can be any size (within memory limits, obviously!), and can be flipped and positioned however required. Screenshot attached!
It uses a line-by-line rendering set up, so there's no overdrawing or flickering. Hopefully this'll help people write some cool games!
Title: Re: Games / community with the tiny screen and gamepad?
Post by: rainnw on May 08, 2015, 02:51:40 PM
Nice work! I have been doing something similar.

I ended up forking the TinyScreen library to add support for tile maps, sprites, and a very useful drawBitmap(image,x,y). There are also some powerful screen functions that I added support to, especially the hardware copy.  I also have support for cropping tiles, which makes way for scrolling.. my goal is to add native side scrolling support.

My current implementation supports alpha sprites, but they draw after the tile map. This does introduce some flicker, so I am going to work them into my scanline routine.

One thing I noticed right away is that PROGMEM is where everything must be stored, otherwise, you can quickly run out of RAM. This introduces a little bit more latency, but it is tolerable.

Here is a game I have been working on. Tile graphics need work, and the sprite call is a bit sloppy (I call it several times in a loop, rather than once, making it flicker like crazy), but it's playable. I have about 20 screens now today.

https://www.youtube.com/watch?v=h3JklWtZTzk

I am using a homegrown pixel and map editor I wrote in HTML5. It needs work, but its usable. It generates C code for the graphics.

8x8 tile editor: http://mobilesquared.com/pixels/tinyscreen.php?x=8&y=8&w=125#

map editor: http://mobilesquared.com/pixels/game.php#


Title: Re: Games / community with the tiny screen and gamepad?
Post by: zet23t on May 09, 2015, 09:44:45 AM
Looks cool. What do you mean with hardware copy?

I also have implemented a scanline renderer - it's opensource and is available here: https://github.com/zet23t/tinyduinogame-playground (https://github.com/zet23t/tinyduinogame-playground)
Title: Re: Games / community with the tiny screen and gamepad?
Post by: rainnw on May 11, 2015, 12:38:26 AM
Looks cool. What do you mean with hardware copy?

I also have implemented a scanline renderer - it's opensource and is available here: https://github.com/zet23t/tinyduinogame-playground (https://github.com/zet23t/tinyduinogame-playground)

There is a screen command to take a screen X,Y and size and copy it to another position. You can use this as a way to implement a hardware scroll. You can also "conveyer belt" scanlines into a copy command and implement a very low overhead sideways scroller.
Title: Re: Games / community with the tiny screen and gamepad?
Post by: zet23t on May 12, 2015, 01:31:56 AM
Hm. Hardware copy sounds neat but without double buffering, the uses are a bit limited. I am most annoyed by the flickering - therefore I just use the scanline rendering for everything. It's fast enough to scroll all sprites/texts that I draw in any direction anyway.

It would be much more useful if the screen had

- Selectable 8bit palettes (currently it's 2-3-3)
- Double buffering
- Uploadable sprites that can be used as textures (32kb or so would suffice)

Essentially the Double buffering would make the difficult-to-use scanline renderer obsolete - which uses also quite a bit of precious ram. And it would make the hardware commands more attractive again - right now I chose not to use them.


Is there an overview what hardware commands are supported?
Title: Re: Games / community with the tiny screen and gamepad?
Post by: rainnw on May 12, 2015, 04:54:56 PM
Hm. Hardware copy sounds neat but without double buffering, the uses are a bit limited. I am most annoyed by the flickering - therefore I just use the scanline rendering for everything. It's fast enough to scroll all sprites/texts that I draw in any direction anyway.

It would be much more useful if the screen had

- Selectable 8bit palettes (currently it's 2-3-3)
- Double buffering
- Uploadable sprites that can be used as textures (32kb or so would suffice)

Essentially the Double buffering would make the difficult-to-use scanline renderer obsolete - which uses also quite a bit of precious ram. And it would make the hardware commands more attractive again - right now I chose not to use them.


Is there an overview what hardware commands are supported?

The good news is that hardware copy does not result in any flickering or tearing. I am using it for several smooth scrolling scenes in my game intro. I have been conveyer belting in the pixels (you do this simply using a static scanline and copying the screen over itself) and it looks great. Since the full resolution bitmap is almost 1/5 of the total available flash memory on the 328, I have been scaling up all of my full screen images by 4x.

The hardware copy is also very fast. If you do not have delays, you may not even see it.

There is a datasheet for the chip. It has a few other modes which are useful for hardware acceleration of graphics.

There are also several different color modes, including a 16 bit mode. The framebuffer on board is actually 96 x 64 x 16 bit.

One major compliant I have with this display driver is there is no way to read back the frame buffer. This makes it very difficult to efficiently draw graphics on the screen, implement sprites, and use windows. I mitigate this by using SetX() and SetY() and calculating what should be replaced.



 
Title: Re: Games / community with the tiny screen and gamepad?
Post by: zet23t on May 12, 2015, 05:30:01 PM

There is a datasheet for the chip. It has a few other modes which are useful for hardware acceleration of graphics.

One major compliant I have with this display driver is there is no way to read back the frame buffer. This makes it very difficult to efficiently draw graphics on the screen, implement sprites, and use windows. I mitigate this by using SetX() and SetY() and calculating what should be replaced.

Do you have a link to the datasheet?

As I wrote earlier - right now I am solely trusting my scanline renderer with which I can do quite many sprite renderings with reasonable frame rates. It's is quite optimized so I am fine for most games I was thinking of.
Title: Re: Games / community with the tiny screen and gamepad?
Post by: rainnw on May 12, 2015, 09:23:53 PM
Do you have a link to the datasheet?

As I wrote earlier - right now I am solely trusting my scanline renderer with which I can do quite many sprite renderings with reasonable frame rates. It's is quite optimized so I am fine for most games I was thinking of.

https://www.newhavendisplay.com/app_notes/SSD1331.pdf

Feel free to do what you want. From what I saw earlier, it is working out great for you.

My goal is to post as many details as I can about the hardware to assist others. There are probably a bunch of people asking themselves the same question.

Title: Re: Games / community with the tiny screen and gamepad?
Post by: zet23t on May 13, 2015, 01:19:04 AM
https://www.newhavendisplay.com/app_notes/SSD1331.pdf

This is interesting. The RAM is holding either 16bits or 8bits. And the address for read out can be set. So... if I am not mistaken from the short glance I had, double buffering might be possible by using 8bit mode and doing the page flip by setting the address respectively to the left or right half. If that would work, using the hardware commands for drawing rectangles and such becomes interesting again. I hope that this really works... it might be that the driver doesn't allow doing that - which would be a shame because the memory is available for that it appears. Have to invest more time in the evening.
Title: Re: Games / community with the tiny screen and gamepad?
Post by: rainnw on May 13, 2015, 12:54:51 PM
7.5.3 says that if you are using 8 bit color mode, the 16 bit color is generated into RAM.

In 8.1, it indicates you can read via parallel, but not in serial mode.

I really wonder how true this 'read' condition is. I guess it's worth a shot.
Title: Re: Games / community with the tiny screen and gamepad?
Post by: zet23t on May 13, 2015, 03:38:13 PM
7.5.3 says that if you are using 8 bit color mode, the 16 bit color is generated into RAM.

In 8.1, it indicates you can read via parallel, but not in serial mode.

I really wonder how true this 'read' condition is. I guess it's worth a shot.

Ah yes, that point looks pretty clear to me. Otherwise the logic for the screen would probably be much more complicated. I've been already thinking about the possibilities - like having an offscreen sprite atlas and copying it onto the front buffer. Then however I realized that this technique would also have severe drawbacks: No transparency support. And since sending the data line by line lacks also transparency, there's no solid way to fix it. Too bad they didn't just pack twice or four times more RAM and included some transparency mode. That would make making games quite easy...

I think I'll stick to scanline rendering as it requires less fiddling.

There are btw. two things I've been thinking in the past about regarding compression: Text compression and image compression. I dropped doing an implementation since I didn't see much use (yet) with the stuff I want to do, but by mentioning full screen images, I've been wondering if you would be interested in that.

The text compression I thought of would be quite simple: A script scans a file with all strings you want to use in your game. It determines the character usage and creates a custom compression table of all used characters. Depending on the number of distinct characters it would pack the strings into 4 bit tuples where certain sequences would tell the decompressor that the character needs another 4 bit tuple for unpacking. I wrote a simple Lua script for compression and it pretty much works... it would save 50-70% of storage space for all strings and the decompressor should be rather simple since the format is quite straight forward. It wouldn't however really matter unless you have ~1k of text.
I could finish that work if you are interested.

Another thing was image compression... I didn't follow that since rendering times would decrease significantly, however again, if you are interested, I could look into that direction as well. I think it wouldn't be too much work. I'm just also not sure how "good" it would look like. The idea is similar to DXT/ETC compression - with some adaptions: I would slice an image into a 4x4 or 8x8 block. Each block would have a color palette associated. An image would have 16 color palettes to pick from, 4 colors each. Each pixel would therefore use 2bits plus 4 bits for each 8x8 or 4x4 block for the palette selection. That would mean using 16.5 bytes for each 8x8 block instead of 64 bytes or 4.5 bytes for each 4x4 block instead of 16 bytes. Depending on the image content, it might look ok (of course it's lossy compression, so quality might be problematic ;)). The decompressor would be still rather simple to implement (read a byte, unpack pixels, load palette colors, translate colors to line pixels). However the compressor would require some more thinking to get "good" quality.

But it's been mostly just ideas. It would be more interesting to make use of that ;)
Title: Re: Games / community with the tiny screen and gamepad?
Post by: jonwingrove on May 14, 2015, 07:44:27 AM
Yeah - I've been going down the scanline render route exclusively.. I think as long as your scanline renderer is optimised - it seems to be the best bet. I've got tiles & sprites working with this (sprites layered on top of the tiles) - I've also got it working with my Outrun style game.

I'm going to add optional SD card writing in to my renderer, so I can occasionally save "screenshots" to the SD card - could even save multiple screenshots to make little animated gifs for uploading/showing.

I thought about palette based sprite storage, too - perhaps using a palette of 16 colours per sprite/tile (4-bits per pixel)..but I might come to that later, if I feel I'm going to run out of program memory.

Really cool to see some other projects coming together! I'll post my progress after the weekend :)
Title: Re: Games / community with the tiny screen and gamepad?
Post by: afelli on May 18, 2015, 04:38:43 AM
Hey all!

I recently bought one of the Tinyduino video game kits at the makers faire in the Bay Area, and I've got to say that everyone here and on CodeBender has given me quite a bit to play with! This is awesome!

I noticed that there was a FlappyBird port for the TinyScreen on CodeBender which had a counter for how many tubes you had flown through, but couldn't find a code for FlappyBird that was TinyJoystick compatible which also had a counter.

So - I merged the two codes :)

Here is what I ended up with: It loads just fine on what I (and I believe most of us) are using.

https://codebender.cc/sketch:115301

I hope it helps for you guys as well!
Title: Re: Games / community with the tiny screen and gamepad?
Post by: afelli on May 18, 2015, 04:44:13 AM
Also - a few questions.

I have been unable to get a few programs to run for some unknown reason. I figure most of you are the creators of these games, so maybe you will be able to point me in the right direction :) I have been able to get most things (flappy bird, mario, ect..) to run fine on the joystick and screen tinyduino package.

The games which I cant get to work are:

Asteroids: https://codebender.cc/sketch:107161#Asteroids%201.ino
Stellar Explorer: https://codebender.cc/sketch:98686#Stellar%20explorer.ino

Asteroids returns: "Could not connect to your device. Make sure that you have connected it properly, that you have selected the correct settings (device type and port) and try again" even though other programs are being uploaded successfully without this problem. Has anyone had this issue?

Stellar Explorer returns: "There was an error compiling." and I can't seem to figure out where it's going wrong.

Thanks for your help in advance!
Title: Re: Games / community with the tiny screen and gamepad?
Post by: zet23t on May 18, 2015, 06:23:41 AM

Asteroids: https://codebender.cc/sketch:107161#Asteroids%201.ino
Stellar Explorer: https://codebender.cc/sketch:98686#Stellar%20explorer.ino

Asteroids returns: "Could not connect to your device. Make sure that you have connected it properly, that you have selected the correct settings (device type and port) and try again" even though other programs are being uploaded successfully without this problem. Has anyone had this issue?

Stellar Explorer returns: "There was an error compiling." and I can't seem to figure out where it's going wrong.

Thanks for your help in advance!

Both are games I've uploaded. Interesting that they don't work for you  - both compile and upload for me without problems. Do they also report errors when you "verify code"?

I sometimes also have trouble with the serial connection. Most often it simply works by unplugging the device and plugging it in again.
Title: Re: Games / community with the tiny screen and gamepad?
Post by: afelli on May 19, 2015, 01:13:01 AM

Asteroids: https://codebender.cc/sketch:107161#Asteroids%201.ino
Stellar Explorer: https://codebender.cc/sketch:98686#Stellar%20explorer.ino

Asteroids returns: "Could not connect to your device. Make sure that you have connected it properly, that you have selected the correct settings (device type and port) and try again" even though other programs are being uploaded successfully without this problem. Has anyone had this issue?

Stellar Explorer returns: "There was an error compiling." and I can't seem to figure out where it's going wrong.

Thanks for your help in advance!

Both are games I've uploaded. Interesting that they don't work for you  - both compile and upload for me without problems. Do they also report errors when you "verify code"?

I sometimes also have trouble with the serial connection. Most often it simply works by unplugging the device and plugging it in again.

Thanks for the quick response!

I've "Clone and Edit"ed both games and they both return "Verification Successful!" when clicking the Verify Code button; but, for some reason I get the same response every time when trying to run on the arduino. Even after restarting my computer and unplugging/replugging everything back in, it still wont run. Hmm..

I'm running it on Google Chrome; what browser are you using to compile it?
Title: Re: Games / community with the tiny screen and gamepad?
Post by: afelli on May 19, 2015, 01:34:28 AM

Asteroids: https://codebender.cc/sketch:107161#Asteroids%201.ino
Stellar Explorer: https://codebender.cc/sketch:98686#Stellar%20explorer.ino

Asteroids returns: "Could not connect to your device. Make sure that you have connected it properly, that you have selected the correct settings (device type and port) and try again" even though other programs are being uploaded successfully without this problem. Has anyone had this issue?

Stellar Explorer returns: "There was an error compiling." and I can't seem to figure out where it's going wrong.

Thanks for your help in advance!

Both are games I've uploaded. Interesting that they don't work for you  - both compile and upload for me without problems. Do they also report errors when you "verify code"?

I sometimes also have trouble with the serial connection. Most often it simply works by unplugging the device and plugging it in again.

Thanks for the quick response!

I've "Clone and Edit"ed both games and they both return "Verification Successful!" when clicking the Verify Code button; but, for some reason I get the same response every time when trying to run on the arduino. Even after restarting my computer and unplugging/replugging everything back in, it still wont run. Hmm..

I'm running it on Google Chrome; what browser are you using to compile it?

Ah - it had to do with using Chrome. I switched to Firefox and got them running no problem :)

Thanks for your help nonetheless, and for writing these awesome games!

I had noticed that someone (maybe on youtube?) had mentioned wanting the left stick to be used to steer and the right stick to be used to shoot. I went ahead and modified your original code to switch these.

The code is posted on: https://codebender.cc/sketch:115627

Hope this is of some use to someone!
Title: Re: Games / community with the tiny screen and gamepad?
Post by: zet23t on May 19, 2015, 02:04:46 AM
I've "Clone and Edit"ed both games and they both return "Verification Successful!" when clicking the Verify Code button; but, for some reason I get the same response every time when trying to run on the arduino. Even after restarting my computer and unplugging/replugging everything back in, it still wont run. Hmm..

I'm running it on Google Chrome; what browser are you using to compile it?

I use firefox. If the verification is successful, it means that the program was created and that it's merely the upload the fails.

Have you checked the com port settings? I used com1 for my device, maybe it's different for yours?
Title: Re: Games / community with the tiny screen and gamepad?
Post by: afelli on May 19, 2015, 03:28:06 AM
I've "Clone and Edit"ed both games and they both return "Verification Successful!" when clicking the Verify Code button; but, for some reason I get the same response every time when trying to run on the arduino. Even after restarting my computer and unplugging/replugging everything back in, it still wont run. Hmm..

I'm running it on Google Chrome; what browser are you using to compile it?

I use firefox. If the verification is successful, it means that the program was created and that it's merely the upload the fails.

Have you checked the com port settings? I used com1 for my device, maybe it's different for yours?

Ah - it had to do with using Chrome. I switched to Firefox and got them running no problem :)

Thanks for your help nonetheless, and for writing these awesome games!

I had noticed that someone (maybe on youtube?) had mentioned wanting the left stick to be used to steer and the right stick to be used to shoot. I went ahead and modified your original code to switch these.

The code is posted on: https://codebender.cc/sketch:115627

Hope this is of some use to someone!
Title: Re: Games / community with the tiny screen and gamepad?
Post by: calvinthedestroyer on May 31, 2016, 01:16:00 PM
Wow, it's been a while since anyone has posted here.

Anyway, I am working on the graphics for a -Tiny Four- game.
I still need to make more sprites and like 2 more background sets. Then maybe we can just re-skin an existing game and call it done :)

here is some art shots of what the game should look like:
Title: Re: Games / community with the tiny screen and gamepad?
Post by: calvinthedestroyer on June 01, 2016, 08:23:57 PM
Here are the sprites I have so far. So tiny!
Title: Re: Games / community with the tiny screen and gamepad?
Post by: dulsi on August 29, 2017, 11:56:08 AM
Here are the sprites I have so far. So tiny!
Did you end up making anything with these sprites? Are these your creations or are some images from shows/games scaled down?

I've been coding up a pacman clone since I didn't see any version for the tinyscreen.