TinyCircuits

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - johnbbq

Pages: [1] 2
1
Tiny Arcade / Re: Font use on screen
« on: August 17, 2018, 09:23:16 PM »
I'm happy to say that I was able to complete the solution to display the score system in my game. Please let me know what you think.

Here is what I did:

I created sprites for each number. For example:

Code: [Select]
ts_sprite zero = { offscreen, offscreen, 3, 5, 0, zeroBitmapFont };
There is a bitmap for each number.

Then I defined 4 sprites, one for each digit (for a number from 0 to 9999), displayed on the top right:

Code: [Select]
ts_sprite onesdigit = { 91, 2, 3, 5, 0, zeroBitmapFont };
ts_sprite tensdigit = { 87, 2, 3, 5, 0, empty };
ts_sprite hundredsdigit = { 83, 2, 3, 5, 0, empty };
ts_sprite thousandsdigit = { 79, 2, 3, 5, 0, empty };

(the empty sprite contains the same size of a number, but with ALPHA on each pixel)

I defined a score global variable:

Code: [Select]
int score = 0;
And two arrays: One for all the numbers, and one for all the digits:

Code: [Select]
ts_sprite * numbersBitmapFont[10] = { &zero, &one, &two, &three, &four, &five, &six, &seven, &eight, &nine };
ts_sprite * digits[4] = { &thousandsdigit, &hundredsdigit, &tensdigit, &onesdigit };

I added a scoreUpdate() function to the loop(), and every time I kill an enemy I add +1 to the score variable.

Here is what's in scoreUpdate():

Code: [Select]
void scoreUpdate() {
  //Convert score to string
  String scoreDisplay = String(score);
  //Determine how big is the score and how many digits will be needed to display it
  int startAt = 4 - scoreDisplay.length();

  //Go through the string, and draw each character
  for (int i = 0; i < scoreDisplay.length() ; i++) {
    int c = scoreDisplay.charAt(i);
    //c will have the ASCII value of the character, number 0 is 48 in ASCII
    int n = c - 48;
    //make digit be the right number
    digits[startAt+i]->bitmap = numbersBitmapFont[n]->bitmap;
  }
}

Cheers,


2
Tiny Arcade / Re: How do you compare the TinyArcade hardware with?
« on: August 17, 2018, 08:40:20 PM »
Thanks to both of you for the answers. This gives me a much better idea of what kind of hardware the TinyArcade is.

Cheers,

3
Tiny Arcade / Re: Font use on screen
« on: August 15, 2018, 08:47:19 AM »
That was it Hunter, thank you! I'll continue working on the code to display the score beyond 1 digit, and I'll post my solution.

Cheers,


4
Tiny Arcade / Re: How do you compare the TinyArcade hardware with?
« on: August 15, 2018, 08:23:51 AM »
Hello Réna! Thank you very much for your answer. Yes, it seems that on paper, the TinyArcade is between a Super Nintendo and a Sega Saturn on CPU, but I haven't done a stress test and see how many sprites I can get running on screen. Have anybody tried benchmarking the TinyArcade?

In terms of pixel size, it's almost half of the screen resolution of an Atari 2600, but because of the small screen size the TinyArcade looks much better :).

5
Tiny Arcade / Re: Font use on screen
« on: August 13, 2018, 02:53:36 PM »
Hello guys. I'm struggling with how to assign a new bitmap to a sprite on runtime. So for example:

ones->bitmap = spriteList[20]; //Assign zero sprite (sprite 20 in sprite list), to the place where the ones digit goes.

I get the following error:

base operand of '->' has non-pointer type 'ts_sprite'

What's the right way to call the instruction to change a bitmap on a sprite?

Thanks!

6
Tiny Arcade / Re: Font use on screen
« on: August 12, 2018, 04:15:19 PM »
Hello guys! Sorry for this late reply. Thank you for the ideas. I'll be implementing it based on your recommendations, and I'll post my solution to see what do you think.

Cheers,

7
Tiny Arcade / Re: Font use on screen
« on: August 09, 2018, 02:10:43 AM »
Hey Hunter. Thanks for the reply. I looked into it today, but I'm not sure what to do.

I was going to start creating a bitmap font routine to display the scores, but if you guys can give me any pointers on how to use the fonts with the drawbuffer function, that will save me a lot of time. Thank you!

Our second TinyArcade arrived yesterday, and we promptly put it together today :). We are now working on two projects at the same time.

8
Tiny Arcade / Font use on screen
« on: August 07, 2018, 01:06:09 AM »
Hi there. I have tried today to print a score in our game, but I'm not sure how the font system works.

I found an example in how fonts are used here: https://tinycircuits.com/blogs/learn/tinyscreen-battery-voltage

So I put the following lines in my setup() function:

display.setFont(thinPixel7_10ptFontInfo);
display.fontColor(0xFFFF, 0x0000);

Then in the loop function, i have an scoreUpdate() function called. Here is what it is in scoreUpdate:

display.setCursor(12, 12);
  display.print(score);

(score is a global variable, initialized to 0)
As it stands, when I run the program everything on screen is "frozen" (player can't move, nothing is updating on the screen except the player and the score), and the 0 value for the score is displayed there and it's flickering constantly.

For drawing the screen I am using the drawbuffer function that came with the TinyArcade tutorial.

Could anyone point me to the right way of doing this?

Thanks,

9
Tiny Arcade / How do you compare the TinyArcade hardware with?
« on: August 06, 2018, 01:43:05 AM »
Hello everyone. I was explaining to a friend how much fun we were having with the TinyArcade, and he wanted to know how does it compare in terms of hardware with old video game consoles. What do you think it would be a fair comparison to?

Cheers,

10
Hi Hunter! Great recommendations, thank you. I'll work on these changes on my game.

Cheers,

11
Tiny Arcade / Re: Custom colors (other than the 16 pre-defined?)
« on: August 03, 2018, 12:59:51 AM »
Hello! Sorry it took me so long to reply. I was immersed in trying to get a gameplay feature to work, and just today I've got back to this.

Dulsi, thank you for pointing my error out. Unfortunately for me I am not sure how to have the sprites be a char instead of an int (as the TinyArcade tutorial uses). But I'll start a separate thread as the tool you pointed out can be really useful.

Hunter, thank you again. I understand what the issue is now. Here is what I did to fix the problem:

- I chose to go with RGB, so I set the color mode in my program to RGB (is there a reason why BGR is better?).
- I found this online tool: http://www.barth-dev.de/online/rgb565-color-picker/ . In my Mac, pressing the color opens the color wheel, which has a color picker functionality. I kept Piskel in one window next to the browser side by side, and I was able to pick the colors directly from my image.

I replaced the default color values for the values that page me gave me, and it works like a charm!

I hope this info helps anyone who will stumble into this issue.

Cheers,

12
Tiny Arcade / Re: Custom colors (other than the 16 pre-defined?)
« on: July 25, 2018, 06:41:04 PM »
Hey Dulsi, thanks for your reply. Yes, display is set to 16 bit in my code, the exact line you wrote is in the setup.

Here is how I define the display:

TinyScreen display = TinyScreen(TinyScreenPlus);

And here is what my setup function looks like:

void setup() {
  arcadeInit();
  display.begin();
  display.setBitDepth(TSBitDepth16);
  display.setBrightness(15);
  display.setFlip(false);

  USBDevice.init();
  USBDevice.attach();
  SerialUSB.begin(9600);

}

Here is what the sprite code looks like:

const unsigned int tacoInvaderBitmap[] = {
  0x00,0x00,0x00,0x00,0x00,0x1f,0x46,0xcb,0x46,0xcb,0x46,0xcb,0x00,0x1f,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x1f,0x46,0xcb,0x2c,0xdb,0x34,0xba,0x2c,0xbb,0x46,0xcb,0x00,0x1f,0x00,0x00,
  0x46,0xcb,0x21,0x09,0x2c,0xdb,0x2c,0xda,0x34,0xbb,0x2c,0xba,0x2c,0xbb,0x21,0x09,0x46,0xcb,
  0x21,0x09,0x2c,0xdb,0x2c,0xda,0x2c,0xbb,0x2c,0xba,0x34,0xbb,0x2c,0xba,0x34,0xbb,0x21,0x09,
  0x21,0x09,0x2c,0xbb,0x34,0xda,0x2c,0xbb,0x2c,0xba,0x34,0xbb,0x2c,0xba,0x34,0xbb,0x21,0x09,
  0x2c,0xbb,0x34,0xba,0x2c,0xbb,0x34,0xba,0x2c,0xbb,0x34,0xba,0x2c,0xbb,0x34,0xba,0x2c,0xbb,
  0x2c,0xbb,0x34,0xba,0x2c,0xdb,0x2c,0xba,0x34,0xdb,0x2c,0xba,0x2c,0xdb,0x34,0xba,0x2c,0xdb,
 
};

Attached is how the image is looking like on the TinyScreen. The red square is this sprite, right below is another sprite defined with pre-defined colors.

Any ideas what may be causing this? Thanks again for your help.

13
Tiny Arcade / Re: Custom colors (other than the 16 pre-defined?)
« on: July 24, 2018, 10:02:42 PM »
So I tried the tool, but I'm not being able to make it work:

https://screencast.com/t/yUwMqJBo

The C code generated by the tool has 18 entries per line (when the image is 9 pixels wide), but it has the right number of lines (7). I am not sure if the settings I entered are the right ones. They are in the screenshot above.

All I get if I use that code is a square of red and black pixels.

But everything works great when I use the pre-defined colors.

Can anyone help? Thanks in advance.

14
Tiny Arcade / Re: Custom colors (other than the 16 pre-defined?)
« on: July 24, 2018, 09:20:39 AM »
Thank you Dulsi! I will check it out.

15
Tiny Arcade / Custom colors (other than the 16 pre-defined?)
« on: July 23, 2018, 11:25:57 PM »
Hi there. Today I have been creating new sprites for our game, and I've been having a hard time finding how I can set up an RGB color. I am not sure what's the right format.

I found this page: http://www.barth-dev.de/online/rgb565-color-picker/ . But if I use their color values (for example 0xFE82), I get a completely different color on screen.

The only colors that work well are the ones defined in the library (TS_16b_Yellow for example).

Can you tell me what format should I enter the color values for each sprite pixel?

Thank you,


Pages: [1] 2