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 - dreamerman

Pages: 1 ... 21 22 [23] 24
GLBasic - en / Re: Compiling for Android?
« on: 2013-Mar-31 »
To debug on android use: 'GLBasic\Compiler\platform\android\bin\_Logview.bat' - of course edit it and change path to same as you have installed GLB and JDK.. it lets you view shorter version of logs, to full log file find 'android-sdk\platform-tools\adb.exe' and make bat file with such cmd:
'adb.exe shell logcat > log.txt'
it will create full log file for attached device..
To print some debug info onto adb debugger use STDOUT command in GLB - instead of DEBUG.

For example if you are using opengl inlines, don't use functions not available on OpenGL ES - such as glPolygonMode, glBegin... - that causes such crashes.

I also have Win7 64bit, both 'jdk1.6.0_41' and 'jdk1.7.0_15' installed, but PATH variable was set to JDK 6, also JRE6 installed.

There can be problems with spaces in JAVA_HOME, so I keep all java/android stuff in 'c:/android/' ;d
Similar problem:
Don't forget to set ANDROID_SWT as system variable, mine look like this: 'C:\Android\android-sdk\tools\lib\x86'

Everything fine with GLB, you just made simple mistake in code ;-)
As mentioned above, you are drawing player character every iteration so, in shorts:
tile 1x1 -> draw layer, draw player on his position, draw layer
tile 2x1 -> draw layer, draw player on his position (even if he's not on that tile), draw layer
so player char always will be on top..
Correctly it shoul be made like in your second post or as fuzzy70 written.
You can also easily optimize your code a little, just store 'u+x_off' and other similar in some variables for each iteration.
Code: (glbasic) [Select]
FOR u = 0 TO w
FOR v = 0 TO h
cu = u+x_off; cv = v+y_off
IF (cu<=map_data.width) AND (cv<=map_data.height)
cx = x+(u*tile_height); cy = y+(v*tile_height)
IF L1 THEN DRAWANIM 0,map[cu][cv].L1_tile,cx,cy
IF L2 THEN DRAWANIM 0,map[cu][cv].L2_tile,cx,cy
IF L3 THEN DRAWANIM 0,map[cu][cv].L3_tile,cx,cy

GLBasic - en / Re: TCP over the internet
« on: 2013-Mar-26 »
If server and client aren't in same local network, then port forwarding on server side is always needed. Of course if you are not using some VPN software that could bypass that issue.
You should also remember to add your app (on host system) to firewall excludes, or just ports range that app is using.

Main purpose of glBasic is to make games, apps also can be made but on such platforms you need to use specific inline code for particular platform.
What OpenGl native game/application on Android uses such features that you have specified? Probably not many and you could count them. That is obvious, if you want to make some interactive app, use tools designed for apps, not for games. Of course you can find others 'professional tools' that will allow to use of additional phone features, because they cost much more than glBasic, and are developed by large teams = they can add more stuff.

And when it goes to native, or interpreted.. Basic4Android -> converts to java, thats not native, whatever you will call it, bytecode, managed or other...
They were topics, about that why compiled files have such size, what they contain and so on.. So for me there is no point to repeat same thing again.
I'm not telling you 'man GLB is the best, others are crap, buy it now!' or something like this.. just that: each tool/language is designed to do other things, or similar things in other way, and for multi-platform 2D game developing GLB is very good.

GLBasic - en / Re: Android compiling help
« on: 2013-Mar-16 »
Touch input is little different from mouse.. on my device with screen that has 5 multitouch, with GetMouseCount I always get 5, MouseState for all touch inputs returns some position on the screen, but if user isn't currently touching screen left button has state 0, if he touches but state is 1. You have to take this into consideration, when creating input functions.

GLBasic - en / Re: Android compiling help
« on: 2013-Mar-15 »
Erico, don't forget about second part - enable debug mode on phone.
I think that such device should have good usb debug drivers, maybe they are on cd or can be downloaded from net..
The method that I posted can be used for any kind of android based device and it's recommended on many forums - mostly in terms of rooting device - but this part is only how to make your device visible on debugger list, so does not interfere in phone, and take only a little time ;-)
About jdk version.. after successfully deployment of your app, you must sign it to publish it on market, there were some issues with that in jdk7 and normal glBasic version, so I installed jdk6, and don't know does it works now. :-)

GLBasic - en / Re: Android compiling help
« on: 2013-Mar-15 »
So currently app isn't automatically installed on your device?
Despite that I read some time ago that jdk6 is recommended to use - due some signing problems - I don't know current status of that issue so next thing:

1. Does your device is recognized by Google adb debugger? after pluging in, it should be visible on device list, to check it:
run cmd, navigate to your 'android-sdk\platform-tools' folder, type:
Code: (glbasic) [Select]
adb devicesIf you device doesn't have correct USB drivers for debug mode then it wont be visible. Probably most cheap Chinese based tablets (as mine :D) have such problem, so in that case you need to add it manually to debugger files.

Plug your android device to usb - don't select usb connection type on device, run system 'device manager' / Control Panel - System - Dev mgr, navigate to device entry - at this stage it can be unrecognized and visible as some mysterious txt, go to it properties - details, from combo choose  'device identy/description' or similar there should be string similar to this:
Code: (glbasic) [Select]
USB\VID_2207&PID_0010&REV_0222&MI_01 it can have different numbers of course.. copy it..
Go to 'android-sdk\extras\google\usb_driver', edit 'android_winusb.inf', in sections '[Google.NTx86]' and '[Google.NTamd64]' add two lines for your device:
Code: (glbasic) [Select]
%SingleAdbInterface% = USB_Install, copied_info_string_without_last_&
%CompositeAdbInterface%= USB_Install, copied_info_string
next go to: 'C:\Users\your_user\.android', edit 'adb_usb.ini', add first value from id string, for my device it would be: 0x2207
restart adb debugger, reconnect your device, now it should be recognized as 'google .. adb driver' or something like this, and should be visible on adb devices list..

2. have you enabled debug mode on device? -> settings - system - programming options - enable debug mode

For me auto installing apps by glBasic is stable, always installed correctly, no problems.
And you can see debugger output with this file: 'GLBasic\Compiler\platform\android\bin' -> '_Logview.bat', but edit it and check paths - they need to be correct, to print debug info on android use 'stdout' in glBasic...

Answer is same as for Your other topic - about sprites..
You can replace function parameters with variables so:
Code: (glbasic) [Select]
CONSTANT mykey_W% = 17
Global mykey_A% = 30

if Key(mykey_W%)
if Key(mykey_A%)

@mentalthink: thanks, 'bug' fixed..

@matchy: I think that we should try to use such custom ad clients as this, and t least check does it work properly.

Little update. I have added 'madvertise' network with html & xml parsers, it's working properly, on pc test banner is shown.
That provider requires our IP as parameter in body of POST request so additional php script is needed, example in source, link to temporary script on my server is in first post.

True test would be if someone will register his game on one of these networks (it does not oblige to anything), and test 'basad' with real app_id/keys and on real device.

I know it's Friday night, but the sooner the better.
One form of making $$ from games is in-app advertising, but so far we had no luck with it. Although there were attempts to make iads working on ios, but from what I see, now it does not work. That's why it's time to move on.
When it goes to writing custom ad network client there are several fundamental problems:
1. gif loading - this format is used for animated banners by some ad networks..
Now, thanks to the gif loader (available here), we can use this format so the problem disappeared.
2. user-agent string - such as in a default browser on the phone .. now we have to manually type it into code, and as you know, it will not be 100% correct with what is shown by browser.
3. uuid / imei - I do not know how it currently looks like - whether the uuid collecting applications are rejected? because, some networks require to pass encoded (eg md5) uuid or MAC address - which you can not currently retrieve in GLBasic.

After recently viewing different source codes  (eg 'ad mediator' for corona sdk) I stated that if they can use in-app advertising, we also should do it! ;] I have rewritten my old unfinished custom parser for one of ad networks, improved many things and now alpha code is ready to testing. Unfortunately I do not have any other device than my pc  so I ask you to help with testing.

Currently there are parsers for 3 ad networks: InnerActive, InMobi and madvertise - on the pc when setting test APP_ID for them, all these networks response with test banners showing that implementation is correct. Another ad networks can be easily added - it would be good if such network would have a Client API - not only sdk.

A lot of talk but how to test it?
We need real device testing, on some ready games/apps - check if ad providers response with real ads, does parsers work properly on them, and most important, does clicks are counted.

Example use of code - to see test banners:
Code: (glbasic) [Select]
//remember to include gif loading routines
LOCAL t1%, t2%, t3%, gif_cframe%, gif_frames%, ad_loaded%, ad_frame%

Init_basad_ads(100, 1, 480, 800, "games", 20, "m", "")
basad_enableInnAct("", 0)
basad_enableInMobi("", 0)
basad_setnetorder("innact") //change to inmobi/madv, or combination "innact,inmobi,madv" - uncomment debug cmd in basad to see how networks response
while (basad_sock%<>-1)
DEBUG "error: " + basad_errcode% + " -> " + basad_errstr$ + "\n" //if all ok should return err=0

LOCAL done% = 1
CLEARSCREEN RGB(100, 50, 50)
WHILE done%
IF KEY(01); done% = 0; ENDIF

INC ad_frame%
IF (ad_frame% >= basad_banner_frames%); ad_frame% = 0; ENDIF

IF (basad_banner_frames% <> -1); DRAWANIM basad_spriteid%, ad_frame%, 10, 300; ENDIF //draw fancy ad banner

NOTE: 'madvertise' ad network need our IP address as parameter in POST body, so additional script is required to retrieve our ip, example code included in source.
Also this provider doesn't like some 'user-agents'  for example TouchPad isn't recognized = even test ads aren't served.

[attachment deleted by admin]

2D-snippets / Loading GIF files/animations...
« on: 2012-Aug-21 »
We can load jpg, png and bmp files, but whole gifs world was beyond our reach, until now.
From long time I was thinking about making gif importer, but LZW compression looked complicated, it still look strange ;d
But after long searches for most understandable code, I found some source in Java, and translation to GLB began..
Here it is, GIF loading code, with examples.

NOTE: I only 'converted' that module to GLBasic, real thanks should go to Jitsu Wan for his Java source.

GIF module:
Code: (glbasic) [Select]
// --------------------------------- //
// Project: gif_loader

// No copyright asserted on this source code. May be used for
// any purpose, however, refer TO the Unisys LZW patent FOR any additional
// restrictions. I am NOT responsible IF something will not work properly.

// GLBasic GIF load port by dreamerman[at]
// heavily based on gif loader for Java ME by Jitsu Wan with reference to work done by Kevin Weiner, FM Software; LZW decoder adapted from John Cristy's ImageMagick.
// includes c++ inline
// any other info in code
// --- HOW TO USE ---
// - first initialize gif vars by calling -
// Init_Gif_loader()
// - next load gif file as sprite -
// Load_gif_file("some.gif", sprite_id%, frame_count%, frame_width%, frame_height%)
// DrawSprite sprite_id%, 0, 0
// - or load directly as animation for use with DrawAnim ... -
// Load_gif_as_anim("some.gif", anim_id%, frame_count%, frame_width%, frame_height%)
// DrawAnim anim_id%, current_frame%, 0, 0
// - that's all... -

//ver: public 2
//- public 2: added Redim's to clear image buffers

//two importants variables, set max sprite size - lower for compatibility with legacy gpu/mobile devices
GLOBAL gif_max_sprite_width% = 2048, gif_max_sprite_height% = 2048
//other gif loader variables
GLOBAL gif_curr_posx%, gif_curr_posy%, gif_currxlen%
GLOBAL gif_bytes%[], gif_file_size%, gif_error%, gif_rposition%, gif_tpixels%[], gif_framecount%
GLOBAL gif_width%, gif_height%, gif_gct_flag%, gif_gct_size%, gif_pixelaspect%, gif_bgindex%, gif_bgcolor%, gif_lastbgcolor%
GLOBAL gif_lctFlag%, gif_interlace%, gif_lct_size%, gif_islastimg%
GLOBAL gif_gctab%[], gif_lctab%[], gif_blockb%[], gif_block_size%
GLOBAL gif_delay%, gif_transparency%, gif_transIndex%, gif_dispose%, gif_lastDispose%
GLOBAL gif_MaxStackSize% = 4096, gif_prefix%[], gif_suffix%[], gif_pixelStack%[]
GLOBAL gif_ix%, gif_iy%, gif_iw%, gif_ih%, gif_done%, gif_loopcount%
GLOBAL gif_lastImage_id%, gif_lastRect%[], gif_image%[], gif_lastimage%[], gif_wholesprite%[]

//init function
FUNCTION Init_Gif_loader:

DIM gif_bytes%[2]
DIM gif_gctab%[256]
DIM gif_lctab%[256]
DIM gif_blockb%[256]
DIM gif_tpixels%[256]
DIM gif_prefix%[gif_MaxStackSize%]
DIM gif_suffix%[gif_MaxStackSize%]
DIM gif_pixelStack%[gif_MaxStackSize%+1]
DIM gif_lastRect%[4]
DIM gif_image%[256]
DIM gif_lastimage%[256]
DIM gif_wholesprite%[256]


//gif loading errors:
//1 - no such file
//2 - error with opening file
//3 - not a gif file - if it's bmp/jpg/png it will be loaded
//4 - ???
//5 - to small sprite size - to many gif frames
FUNCTION Load_gif_file: filename$, sprite_id%, BYREF frame_count%, BYREF frame_width%, BYREF frame_height%
LOCAL i1%, i2%, i3%, wp%, czs1$

gif_file_size% = GETFILESIZE(filename$); gif_error% = 0
IF (gif_file_size% = 0)
DEBUG "GIF load error: wrong file size\n"
gif_error = 1; RETURN 0
ENDIF //no file size?
// DEBUG "reading start: " + GETTIMERALL() + "\n"
wp% = GENFILE()
IF (OPENFILE(wp%, filename$, 1))
REDIM gif_bytes%[gif_file_size%]
READSTR wp%, czs1$, gif_file_size%
FOR i1% = 0 TO gif_file_size%-1
gif_bytes%[i1%] = ASC(MID$(czs1$, i1%, 1))
gif_rposition% = 6
ELSE //some error with loading file
gif_error = 2; RETURN 0

// DEBUG "reading end: " + GETTIMERALL() + ", file size: " + gif_file_size% + "\n"

gif_curr_posx% = 0; gif_curr_posy% = 0; gif_framecount% = 0
czs1$ = CHR$(gif_bytes%[0]) + CHR$(gif_bytes%[1]) + CHR$(gif_bytes%[2]) + CHR$(gif_bytes%[3]) + CHR$(gif_bytes%[4]) + CHR$(gif_bytes%[5])
IF (czs1$ = "GIF87a" OR czs1$ = "GIF89a")
// DEBUG "it's a gif file..\n"
//clear last image buffer
REDIM gif_image%[0]; REDIM gif_wholesprite%[0]; REDIM gif_lastimage%[0]
IF (gif_gct_flag%); gif_readColorTable(1); ENDIF
//redim sprite array
i1% = INTEGER(gif_max_sprite_width% / gif_width%)
gif_currxlen% = i1% * gif_width%
REDIM gif_wholesprite%[gif_currxlen% * gif_max_sprite_height%]


// DEBUG "loading end: " + GETTIMERALL() + "\n"
// DEBUG "array x-size: " + gif_currxlen% + ", loop count: " + gif_loopcount% + ", delay: " + gif_delay% + " \n"
// DEBUG "frame count: " + gif_framecount% + ", in-sprite pos: " + gif_curr_posx% + "x" + gif_curr_posy% + "\n"
IF (gif_error% = 5); DEC gif_curr_posy%, gif_height%; DEC gif_framecount%; ENDIF
REDIM gif_wholesprite%[gif_currxlen% * (gif_curr_posy%+gif_height%)] //cut of unnecessary data
//create sprite from array
MEM2SPRITE(gif_wholesprite%[], sprite_id%, gif_currxlen%, gif_curr_posy%+gif_height%)

ELSE //check if it's bmp, jpg  or png for normal loading
IF (gif_bytes%[0] = 66 AND gif_bytes%[1] = 77) OR (gif_bytes%[0] = 255 AND gif_bytes%[1] = 216) OR (gif_bytes%[0] = 137 AND gif_bytes%[1] = 80 AND gif_bytes%[2] = 78 AND gif_bytes%[3] = 71)
LOADSPRITE filename$, sprite_id%
GETSPRITESIZE sprite_id%, gif_width%, gif_height%
IF (gif_width% > 0 AND gif_height% > 0)
gif_framecount% = 1
gif_error = 3; RETURN 0
gif_error = 3; RETURN 0
frame_count% = gif_framecount%; frame_width% = gif_width%; frame_height% = gif_height%
REDIM gif_bytes%[1]
REDIM gif_wholesprite%[1]


//equivalent for LoadAnim
FUNCTION Load_gif_as_anim: filename$, anim_id%, BYREF frame_count%, BYREF frame_width%, BYREF frame_height%
LOCAL ws% = GENSPRITE(), temp%, tcount%, twidth%, theight%
temp% = Load_gif_file(filename$, anim_id%, tcount%, twidth%, theight%)
SETSPRITEANIM anim_id%, twidth%, theight%
frame_count% = tcount%; frame_width% = twidth%; frame_height% = theight%
RETURN temp%

//main loop
FUNCTION gif_readContents:
LOCAL i1%, code%, czs1$

gif_done% = 0
WHILE (gif_done% = 0)
code% = gif_read()
SELECT code%
CASE 44 //0x2C - image separator
// DEBUG "new image: " + gif_framecount% + "\n"
CASE 33 //0x21 - extension
code% = gif_read()
// DEBUG "extension: " + "\n"
SELECT code%
CASE 0xf9 //graphic control extension
// DEBUG "graphic ext: dispose: " + gif_dispose% + " \n"
CASE 0xff //application extension
// DEBUG "netscape ext \n"
czs1$ = ""
FOR i1%=0 TO 10; INC czs1$, CHR$(gif_blockb%[i1%]); NEXT
IF (czs1$ = "NETSCAPE2.0")
CASE 59 //0x3b - terminator
gif_done% = 1
CASE 0 //0x00 - bad byte
//raise error - format error?


// original comment
// Decodes LZW image data into pixel array.
// Adapted from John Cristy's ImageMagick.
FUNCTION gif_decodeImageData:
LOCAL NullCode% = -1, npix% = gif_iw% * gif_ih%
LOCAL available%, clear%, code_mask%, code_size%, end_of_information%, in_code%, old_code%, bits%, code%, count%, i%, datum%, data_size%, first%, top%, bi%, pi%

IF (LEN(gif_tpixels%[]) < npix); REDIM gif_tpixels%[npix]; ENDIF

data_size% = gif_read() //  Initialize GIF data stream decoder.
clear% = ASL(1, data_size%)
end_of_information% = clear% + 1
available% = clear% + 2
old_code% = NullCode%
code_size% = data_size% + 1
code_mask% = ASL(1, code_size) - 1
FOR code% = 0 TO clear%-1
gif_prefix%[code%] = 0
gif_suffix%[code%] = code%

         //  Decode GIF pixel stream.
         datum = bits = count = first = top = pi = bi = 0;

         while (i < npix)
             if (top == 0)
                 if (bits < code_size)
                     //  Load bytes until there are enough bits for a code.
                     if (count == 0)
                         // Read a new data block.
                         count = gif_readBlock();
                         if (count <= 0) {
                         bi = 0;
                     datum += ((gif_blockb(bi)) & 0xff) << bits; //(((int) gif_blockb(bi)) & 0xff) << bits;
                     bits += 8;

                 //  Get the next code.

                 code = datum & code_mask;
                 datum >>= code_size;
                 bits -= code_size;

                 //  Interpret the code

                 if ((code > available) || (code == end_of_information)) {
                 if (code == clear)
                     //  Reset decoder.
                     code_size = data_size + 1;
                     code_mask = (1 << code_size) - 1;
                     available = clear + 2;
                     old_code = NullCode;
                 if (old_code == NullCode)
                     gif_pixelStack(top++) = gif_suffix(code);
                     old_code = code;
                     first = code;
                 in_code = code;
                 if (code == available)
                     gif_pixelStack(top++) = first; //(byte) first
                     code = old_code;
                 while (code > clear)
                     gif_pixelStack(top++) = gif_suffix(code);
                     code = gif_prefix(code);
                 first = (gif_suffix(code)) & 0xff; //((int) gif_suffix(code)) & 0xff;

                 //  Add a new string to the string table,

                 if (available >= gif_MaxStackSize) {
                 gif_pixelStack(top++) = first; //(byte) first
                 gif_prefix(available) = old_code; //(short) old_code
                 gif_suffix(available) = first; //(byte) first
                 if (((available & code_mask) == 0) && (available < gif_MaxStackSize))
                     code_mask += available;
                 old_code = in_code;

             //  Pop a pixel off the pixel stack.

             gif_tpixels(pi++) = gif_pixelStack(top);

         for (i = pi; i < npix; i++)
             gif_tpixels(i) = 0; // clear missing pixels


FUNCTION gif_readImage:

gif_ix% = gif_readShort()
gif_iy% = gif_readShort()
gif_iw% = gif_readShort()
gif_ih% = gif_readShort()

LOCAL packed% = gif_read(), save%
gif_lctFlag% = bAND(packed%, 0x80) //1 - local color table flag
gif_interlace% = bAND(packed%, 0x40) //2 - interlace flag
//3 - sort flag, 4-5 - reserved
gif_lct_size% = ASL(2, bAND(packed%, 7)) //6-8 - local color table size
IF (gif_lctFlag%) //use local table
FOR i1% = 0 TO gif_gct_size%-1
gif_lctab%[i1%] = gif_gctab%[i1%]
IF (gif_bgindex% = gif_transIndex%); gif_bgcolor% = 0; ENDIF

IF (gif_transparency%)
save% = gif_lctab%[gif_transIndex%]
gif_lctab%[gif_transIndex%] = 0


INC gif_framecount%
//check for space
IF (gif_curr_posy% + gif_height% >= gif_max_sprite_height%)
gif_error% = 5; gif_done% = 1
IF (gif_error% = 0)
gif_setPixels() // transfer pixel data to image
IF (gif_transparency%); gif_lctab%[gif_transIndex%] = save%; ENDIF

//calculate new position in our sprite
INC gif_curr_posx%, gif_width%
IF (gif_curr_posx% >= gif_currxlen%)
gif_curr_posx% = 0
INC gif_curr_posy%, gif_height%
IF (gif_curr_posy% >= gif_max_sprite_height%)
gif_error% = 5
gif_done% = 1
// DEBUG "new position in sprite: " + gif_curr_posx% + "x" + gif_curr_posy% + "\n"


FUNCTION gif_setPixels:
LOCAL n%, i1%, i2%, i3%, i4%, i5%, i6%, dlug% = gif_width% * gif_height%, ccolor%

IF (gif_lastDispose% > 0)
IF (gif_lastDispose% = 3)
n% = gif_framecount% - 2 //use image before last
IF (n% > 0)
i1% = (n - 1) * gif_width%; i2% = 0 //x & y pos of that frame on sprite array
WHILE (i1% > gif_currxlen%)
DEC i1%, gif_currxlen%; INC i2%, gif_height%

FOR i4% = i2% TO i2% + gif_height%
i5% = gif_height% * i4%
FOR i3% = i1% TO i1% + gif_width%
gif_image%[i6%] = gif_wholesprite%[i5% + i3%]
INC i6%
ELSEIF (gif_lastDispose% = 2)
IF (gif_transparency%)
ccolor% = INTEGER(0x00000000)
ccolor% = gif_lastbgcolor%
FOR i1% = 0 TO dlug%-1
gif_image%[i1%] = ccolor%
//should be: g.fillRect(lastRect[0],lastRect[1],lastRect[2],lastRect[3]);
FOR i1% = 0 TO dlug% - 1
gif_image%[i1%] = gif_lastimage%[i1%]

         // copy each source line to the appropriate place in the destination
         int pass = 1;
         int incr = 8;
         int iline = 0;
         for (int i = 0; i < gif_ih; i++) {
             int line = i;
             if (gif_interlace) {
                 if (iline >= gif_ih) {
                     switch (pass) {
                         case 2 :
                             iline = 4;
                         case 3 :
                             iline = 2;
                             incr = 4;
                         case 4 :
                             iline = 1;
                             incr = 2;
                 line = iline;
                 iline += incr;
             line += gif_iy;
             if (line < gif_height) {
                 int k = line * gif_width;
                 int dx = k + gif_ix; // start of line in dest
                 int dlim = dx + gif_iw; // end of dest line
                 if ((k + gif_width) < dlim) {
                     dlim = k + gif_width; // past dest edge
                 int sx = i * gif_iw; // start of line in source
                 while (dx < dlim) {
                     // map color and insert in destination
                     int index = (gif_tpixels(sx++)) & 0xff;
                     int c = gif_lctab(index);
                     if (c != 0) {
                         gif_image(dx) = c;


//paste current frame to our sprite
i2% = 0; i3% = gif_curr_posy% * gif_currxlen% + gif_curr_posx%
FOR i1% = 0 TO gif_height% * gif_width% - 1
gif_wholesprite%[i3%+i2%] = gif_image%[i1%]
INC i2%
IF (i2%>=gif_width%); i2% = 0; INC i3%, gif_currxlen%; ENDIF


FUNCTION gif_readGraphicControlExt:
gif_read() //block size
LOCAL packed% = gif_read() //packed fields
gif_dispose% = ASR(bAND(packed%, 0x1c), 2) //disposal method -> dispose = (packed & 0x1c) >> 2
IF (gif_dispose% = 0); gif_dispose% = 1; ENDIF
gif_transparency% = bAND(packed%, 1) //transparency = (packed & 1) != 0;
gif_delay% = gif_readShort() * 10 //delay in miliseconds
gif_transIndex% = gif_read() //transparent color index
gif_read() //block terminator

//how many loops/repeats - does we care about it? ;]
FUNCTION gif_readNetscapeExt:
LOCAL b1%, b2%
IF (gif_blockb%[0] = 1)
b1% = bAND(gif_blockb%[1], 256)
b2% = bAND(gif_blockb%[2], 256)
gif_loopcount% = bOR(ASL(b2%, 8), b1%)
UNTIL (gif_block_size% = 0 OR gif_error% <> 0)

//read Logical Screen Descriptor
gif_width% = gif_readShort()
gif_height% = gif_readShort()
LOCAL packed% = gif_read(), dlug% = gif_width% * gif_height%
gif_gct_flag% = bAND(packed%, 128) // = (packed & 0x80) != 0
gif_gct_size% = ASL(2, bAND(packed%, 7))
// 1   : global color table flag
// 2-4 : color resolution
// 5   : gct sort flag
// 6-8 : gct size

gif_bgindex% = gif_read()
gif_pixelaspect% = gif_read()
//redim our image tables
REDIM gif_image%[dlug%]
REDIM gif_lastimage%[dlug%]

//DEBUG "info: " + gif_width% + "x" + gif_height% + ", colors count: " + gif_gct_size% + "\n"


//read one byte from gif file array
FUNCTION gif_read:
LOCAL i1% = 0
i1% = gif_bytes%[gif_rposition]
INC gif_rposition

FUNCTION gif_readShort:
RETURN gif_read() + ASL(gif_read(), 8)

//block reading
FUNCTION gif_readBlock:
gif_block_size% = gif_read()
IF (gif_block_size% > 0)
LOCAL count% = 0
FOR i2%=0 TO gif_block_size%-1
gif_blockb%[i2%] = gif_bytes%[gif_rposition+i2%]
INC gif_rposition%, gif_block_size%
RETURN gif_block_size%

FUNCTION gif_skipblock:
UNTIL (gif_block_size%=0 OR gif_error%<>0)

FUNCTION gif_readColorTable: is_global%
IF (is_global% = 1)
FOR i1%=0 TO gif_gct_size%-1
gif_gctab%[i1%] = 0xff000000 + ASL(gif_bytes%[gif_rposition+2], 16) + ASL(gif_bytes%[gif_rposition+1], 8) + gif_bytes%[gif_rposition]
INC gif_rposition, 3
FOR i1%=0 TO gif_lct_size%-1
gif_lctab%[i1%] = 0xff000000 + ASL(gif_bytes%[gif_rposition+2], 16) + ASL(gif_bytes%[gif_rposition+1], 8) + gif_bytes%[gif_rposition]
INC gif_rposition, 3

FUNCTION gif_resetFrame:
gif_lastDispose% = gif_dispose%
gif_lastRect%[0] = gif_ix%
gif_lastRect%[1] = gif_iy%
gif_lastRect%[2] = gif_iw%
gif_lastRect%[3] = gif_ih%

//lastImage = image
LOCAL dlug% = LEN(gif_image%[]), i1%
FOR i1% = 0 TO dlug%-1
gif_lastimage%[i1%] = gif_image%[i1%]
gif_islastimg% = 1

gif_lastbgcolor% = gif_bgcolor%
gif_dispose% = 0
gif_transparency% = 0
//gif_delay% = 0
gif_lct_size% = 0


example - load as sprite:
Code: (glbasic) [Select]
SETCURRENTDIR("Media") // go to media files
LOCAL t1%, t2%, t3%
Load_gif_file("some_animation.gif", 1, t1%, t2%, t3%)
SAVESPRITE "test.png", 1

example - load as animation:
Code: (glbasic) [Select]
SETCURRENTDIR("Media") // go to media files
LOCAL t1%, t2%, t3%, gif_cframe%, gif_frames%, done% = 1

Load_gif_as_anim("earth.gif", 3, gif_frames%, t2%, t3%)

CLEARSCREEN RGB(100, 50, 50)
WHILE done%
IF KEY(01); done% = 0; ENDIF
INC gif_cframe%
IF (gif_cframe% >= gif_frames%); gif_cframe% = 0; ENDIF
SLEEP gif_delay% //var from gif loading module
IF (gif_frames%>0); DRAWANIM 3, gif_cframe%, 10, 10; ENDIF


Edit: little update, fixed issue with not clearing image buffers..

GLBasic - en / Re: Quick request
« on: 2012-Jul-25 »
I'm from Poland, and I get German/Deutsch. Checked in Opera and Chrome, before and after deleting paypal/glbasic site cookies.
What more interesting, once, after login to paypal account and logout I have got that checkout page in Polisch, but next time again it was in German :D and still it is..

There is 'lc' parameter for setting user language:
Quote from: PayPal
The locale of the login or sign-up page, which may have the specific country's language available, depending on localization. If unspecified, PayPal determines the locale by using a cookie in the subscriber’s browser. If there is no PayPal cookie, the default locale is US.
but it isn't set on glBasic site so everyone should get his default language or at least US English.
Strange problem..

Maybe you should force some lc with info gathered from php user-agent or something like this..

But does it still consume so much cpu/gpu power on pc? First extensively test your code on pc, with all possible trick's then, check how much speed it gained on emulator/real devices. Use 'LimitFps -1' to unlock fps limiter, and see how many fps you will get on pc with particular changes.
'StrechSprite' shoudn't be used many times, specially on mobile devices. There can be also other small issues, for example float calculations # are of course slower than integer %, so they should be used only when necessary.
When it comes to drawing, you probably should use other commands than strechsprite for example:
Code: (glbasic) [Select]
1. draw all graphic at desired res (let say 320x480) to offscreen texture (UseScreen cmd)
2. render that texture (with all game graphic) to screen with one strechsprite/polyvector
Of course also mouse position should be recalculated also..
Or use some already made custom functions like these from 'Z Project' by Ampos -> LINK

That isn't problem of Android but more likely not properly written code. On my dual-core pc, controls are responsive but game takes 50% of cpu power, it shouldn't happen.
You should use at least Limitfps and Sleep commands:
Code: (glbasic) [Select]
sub play:
Limitfps 30
   while quit=0
       gosub checkinput
       gosub showgraphics
       sleep 25

Or your main loop can be more sophisticated:
Code: (glbasic) [Select]
sub play:
Limitfps 30
   while quit=0
curr_time# = GETTIMERALL()
IF (curr_time# - last_time# >= 33)
              gosub checkinput
              gosub showgraphics
   last_time# = curr_time#
       sleep 20

I don't have experience with current version of Android emulator, but add these changes and test how it will work.

Edit: Or maybe your drawing routines are messed up.. for example If your graphic covers whole screen don't use 'clearscreen' command, just draw new graphic over previous.

Pages: 1 ... 21 22 [23] 24