|
Post by Frank on Mar 10, 2020 2:53:14 GMT -8
Vertex2ii does not work for x values greater than 512 on 7" GD3x screen. for example this wont show the two points:
# include <EEPROM.h> # include <SPI.h> # include <GD2.h>
void setup() { GD.begin(); } void loop() { GD.ClearColorRGB(0x000050); GD.Clear(); GD.cmd_text(GD.w / 2, GD.h / 2, 31, OPT_CENTER, "Gameduino 3 Test"); GD.Begin(POINTS); GD.Vertex2ii(600, 100); GD.Vertex2ii(700, 170); GD.swap(); }
please fix!
|
|
|
Post by Frank on Mar 10, 2020 3:01:47 GMT -8
(i am using library version Gameduino2-v1.2.2)
incidentally, i cant get the walk example to show bitmaps past x values of 512 using vertex2ii on 7" screen for example:
#include <EEPROM.h> #include <SPI.h> #include <GD2.h>
static int a[256]; static int xvals = 800; static int numsprites = 240;
#include "walk_assets.h"
void setup() { GD.begin(~GD_STORAGE); LOAD_ASSETS(); for (int i = 0; i < numsprites; i++) a = GD.random(xvals); }
void loop() { GD.ClearColorRGB(0x000050); GD.Clear(); GD.Begin(BITMAPS); for (int i = 0; i < numsprites; i++) { GD.ColorRGB(i, i, i); GD.Vertex2ii(a, i*2, WALK_HANDLE, (a >> 2) & 7); //a = (a + 1) & 511; a++; if (a > (xvals-1)) { a=0; } } GD.cmd_number(GD.w-100, GD.h-140, 31, OPT_CENTER, GD.w); GD.cmd_number(GD.w-100, GD.h-100, 31, OPT_CENTER, GD.h); GD.swap(); }
|
|
|
Post by Frank on Mar 10, 2020 3:08:31 GMT -8
The posted code above is stripping off the brackets in a
void setup() { GD.begin(~GD_STORAGE); LOAD_ASSETS(); for (int i = 0; i < numsprites; i++) a = GD.random(xvals); }
void loop() { GD.ClearColorRGB(0x000050); GD.Clear(); GD.Begin(BITMAPS); for (int i = 0; i < numsprites; i++) { GD.ColorRGB(i, i, i); GD.Vertex2ii(a, i*2, WALK_HANDLE, (a >> 2) & 7); //a = (a + 1) & 511; a++; if (a > (xvals-1)) { a=0; } } GD.cmd_number(GD.w-100, GD.h-140, 31, OPT_CENTER, GD.w); GD.cmd_number(GD.w-100, GD.h-100, 31, OPT_CENTER, GD.h); GD.swap(); }
|
|
|
Post by Frank on Mar 10, 2020 3:15:00 GMT -8
and it removed the array brackets again.... at any rate, you should understand and be able to repeat this issue.
Vertex2ii is not working for x values past 512 for the 7" gdx3 screen.
I am using the latest 1.2.2 library. if this is something i'm doing wrong on my end please show what the issue is.
this is a very nice screen and great work. just frustrating. cant believe someone else hasn't seen this!!!
|
|
|
Post by Frank on Mar 10, 2020 3:29:57 GMT -8
sorry, i saw previous post with this issue solution is: use Vertex2f instead since Vertex2ii has a limit of 511 pixels in X and Y. example:
GD.BitmapHandle(1); GD.Cell(0); GD.Vertex2f(16 * 623, 16 * 410);
|
|
|
Post by Frank on Mar 10, 2020 3:31:55 GMT -8
this wasn't very apparent in the documentation and/or examples. maybe i should have just got the smaller screen...
|
|
|
Post by Frank on Mar 10, 2020 4:37:45 GMT -8
ok, so vertex2f solution will not work for animated bitmaps!
we need the equivalent of:
GD.Vertex2ii(799, 10, WALK_HANDLE, (i>>2)&7); for x values past 511.
or are we just unable to place bitmaps past x vals of 511?
this is a really unfortunate limitation if true...
|
|
|
Post by jamesbowman on Mar 10, 2020 18:45:02 GMT -8
The code:
GD.Vertex2ii(799, 10, WALK_HANDLE, (i>>2)&7);
can be replaced by:
GD.BitmapHandle(WALK_HANDLE); GD.Cell((i >> 2) & 7); GD.Vertex2f(16 * 799, 16 * 10);
this works for any (x,y) position. The Vertex2ii() version is best thought of as an optimization. It saves a couple of instructions when x,y are small.
|
|
|
Post by Frank on Mar 10, 2020 19:22:45 GMT -8
Thanks, James! That’s what I was going to try next was the separate cell and bitmap handle methods along with vector2f. I might make a wrapper function that mimics the vector2ii method, but with the float arguments just to tidy it up. Thank you for the quick reply. If you want I can write an addendum or revision to your manual that addresses the 7” screen additional requirements and add to the example code for clarity. That way other users/potential customers will quickly understand what is going on with the 7” screen instead of having to dig through the forum to solve the large screen bitmap issues. I’ve seen several posts on this and similar issues. Perhaps a library update to include the extra methods for the 7” screen. Also wouldn’t hurt to put in your manual that the accelerometer was removed in the 7@ version. Especially on that section of the manual. Regards, Frank
|
|
|
Post by Frank on Mar 10, 2020 19:25:00 GMT -8
I meant Vertex2f. Not vector2f. :-)
|
|
|
Post by Frank on Mar 12, 2020 11:55:15 GMT -8
Just to close, the code below works for the full 7" screen 800x480 walk demo I created a function Putsprite() with arguments similar to the vertex2ii of course this could be easily added to the GDClass library as well (NB, the dimension brackets on the variable a [ i ] in the code below are stripped off in this forum post)
#include <EEPROM.h> #include <SPI.h> #include <GD2.h>
#define NUMSPRITES 240 #define XMAX 800 static int a[NUMSPRITES]; #include "walk_assets.h"
void setup() { GD.begin(~GD_STORAGE); LOAD_ASSETS(); for (int i = 0; i < NUMSPRITES; i++) { a = GD.random(XMAX); } }
void Putsprite(uint16_t x, uint16_t y, byte handle, byte cell, uint32_t rgb) { GD.ColorRGB(rgb); GD.BitmapHandle(handle); GD.Cell(cell); GD.Vertex2f(16*x, 16*y); }
void loop() { GD.ClearColorRGB(0x000010); GD.Clear(); GD.Begin(BITMAPS); for (int i = 0; i < NUMSPRITES; i++) { Putsprite(a, i*2, WALK_HANDLE, (a >> 2) & 7, 0x00ddff); if (a++ > XMAX-1) { a = 0; }
//Old code: //GD.Vertex2ii(a, i*2, WALK_HANDLE, (a >> 2) & 7); //a = (a + 1) & 511; } GD.swap(); }
|
|