Menu

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.

Show posts Menu

Topics - Crivens

#41
I've got an mp3 that plays fine on both Windows and my Palm Pre 2, and I load it with the command
Code (glbasic) Select
IF ISMUSICPLAYING()=0 THEN PLAYMUSIC "Media/music.mp3",TRUEHowever while the Palm Pre 2 starts repeating the music after it finishes, Windows does not. I'm using GLB 10.042.

Cheers
#42
Is there a way to use WebOS gestures in GLB? Specifically the back gesture.

Oh, and nice one on WebOS Gernot. I followed the instructions and wham my whole iOS app works perfectly on my new Palm Pre. Only downside is it seems more sensitive than the iPhone for the touch screen, so I need to adjust a couple of settings. No sweat though.

Cheers
#43
Bug Reports / IF THEN
2011-Jun-24
I guess this can be argued either way, but in a lot of basic languages I've used in the past then any commands after the THEN of a single line IF are part of the IF. So if you look at this code:-
Code (glbasic) Select
LOCAL a
a=0
IF a=1
PRINT "1",0,0
PRINT "2",0,10
PRINT "3",0,20
ENDIF

IF a=1 THEN PRINT "1",40,0;PRINT "2",40,10;PRINT "3",40,20

SHOWSCREEN
KEYWAIT

So only 2 and 3 are shown from the IF THEN line. Which is the same as saying:-
Code (glbasic) Select
IF a=1 THEN PRINT "1",40,0
PRINT "2",40,10
PRINT "3",40,20
But from what I've used in the past it shouldn't be. Basically nothing should show as anything on the same line as the IF THEN are part of the single IF statement. Basically ENDIF should be implied at the line feed and not at the end of the first command (ie. the semicolon).

Cheers
#44
Ok so on some feedback on my original iOS game (Rotaslider) I made a sequel of sorts swapping out kittens and puppies for women in bikinis. Much better idea I think everyone can agree :)

Anyway I just got it rejected (does it always take exactly a week pretty much to the hour?). Ok so it's no major surprise and they point to sexual images etc. Point is though that I did label it as 17+ (laughable when Kays catalogue is more sexy and it's nothing you don't see on a beach). And a bigger point is how come apps like the hooters calendar (where you wipe soap suds off women in bikinis) are allowed, also with a 17+ rating?

All they posted was an image of the level selection screen which to be honest is hardly grumble mag level material. I can post the complete thing if anyone is interested.

So, can anyone give me advise on what to answer with? At the end of the day it's not the end of the world as it wasn't that much work to change the original game, and I'll probably host it somewhere free for the pc if I can't get it on the iPhone. Just sucks a bit is all...

Cheers
#45
Ok, so you have designed everything to work on an iPhone 4 with retina display. However you want all the graphics to also work on an older iPhone (or any other device really) without having to have the program always load in the full sized graphics using up far more memory than it really needs to use.

So what this routine does is work out the ratio of your current device compared to the target device which you designed all your graphics for. It then (if the ratio is not 1-1) resizes everything to fit the current device and saves into a separate directory (iPhone cannot write to the MEDIA directory by the looks of things) to load forever after. You can get it to rescan everything by using a ver.txt file in the media directory that you load a new value into every time you have new graphics (so just update ver.txt when making an update to the app store and you have changed your graphics). It also uses sprite2mem so all the alpha values of semi transparent graphics can be kept (rather than just resizing and grabbing the sprite again).

That's about it really. I'm sure someone can improve on it (some kind of smoothing operation when it resizes would be good) or point out some bugs as I just knocked it up quickly. Note that jpgs seem to crash it, but I believe this is just a bug in GLB fullstop. The build in font system is also a bit glitchy, but I think it is because mucking about with the built in functionality. Use your own bitmap routine instead basically. Also note it will also scale up. ie. make graphics bigger if on a higher resolution than intended. On a PC you should be really using the target resolution, but if you want to test then keep changing the ver.txt value in media, or for a quicker method removing the ver.txt file from the secondary storage (it's in documents).

Code (glbasic) Select
// --------------------------------- //
// Project: AlphaTest
// Start: Friday, June 03, 2011
// IDE Version: 9.040


SETCURRENTDIR("Media") // Will use this directory if using target device

TYPE tMouse
x%
y%
active%
ENDTYPE
GLOBAL mouse[] AS tMouse
DIM mouse[5]
SYSTEMPOINTER TRUE

?IFDEF WIN32
SETSCREEN 320,480,0 //Pretend to be an older iPhone - Note should always be the same as target on a PC, but remove/change ver.txt to auto update graphics if choose to test resolutions
?ENDIF

GLOBAL dx#,dy#
GETSCREENSIZE dx#,dy#
GLOBAL targetx#=640 //Graphics originally made for
GLOBAL targety#=960 //Retina display iPhone 4
GLOBAL x#;x=dx/targetx //This works as one command with local, not with global however...
GLOBAL y#;y=dy/targety
GLOBAL docdir$;docdir$=PLATFORMINFO$("DOCUMENTS")+"/alphatest-bin" //Has to be different for iPhone as cannot update MEDIA directory
GOSUB remapall

TYPE stype
x%
y%
width%
height%
s%
text$
visible%
ENDTYPE
GLOBAL spr[] AS stype
DIM spr[0]
GLOBAL tspr AS stype

tspr.s=GENSPRITE()
LOADSPRITE "1.png",tspr.s
tspr.x=10;tspr.y=50;tspr.text$="1";tspr.visible=1
GETSPRITESIZE tspr.s,tspr.width,tspr.height;tspr.width=tspr.width/x;tspr.height=tspr.height/y
DIMPUSH spr[],tspr
tspr.s=GENSPRITE()
LOADSPRITE "2.png",tspr.s
tspr.x=400;tspr.y=700;tspr.text$="2";tspr.visible=1
GETSPRITESIZE tspr.s,tspr.width,tspr.height;tspr.width=tspr.width/x;tspr.height=tspr.height/y
DIMPUSH spr[],tspr

CLEARSCREEN
LOADBMP "background.png"
LOCAL myfont=GENFONT()
LOADFONT "myfont.png",myfont //Font's dont really work well. Resized ones need to be resaved in a paint package (eg. PSP8) to regain transparency but rarely still looks good. May have to use own routine for text, or just have a few different ones
LOCAL tprint$="0"
LOCAL oprint$=tprint$
LOCAL sloop%

//Remember to show anything using x/y ratios (see below)
WHILE 1=1
IF INKEY$()<>"" THEN BREAK
ALPHAMODE -1
updateMice()
tprint$=oprint$
FOR sloop=0 TO BOUNDS(spr[],0)-1
IF spr[sloop].visible
DRAWSPRITE spr[sloop].s,x*spr[sloop].x,y*spr[sloop].y
IF mouse[0].active=1 //Click (and hold) on a sprite to see its text
IF mouse[0].x>=spr[sloop].x AND mouse[0].x<=spr[sloop].x+spr[sloop].width AND mouse[0].y>=spr[sloop].y AND mouse[0].y<=spr[sloop].y+spr[sloop].height
tprint$=spr[sloop].text$
ENDIF
ENDIF
ENDIF
NEXT
PRINT tprint$,x*10,y*10,10
SHOWSCREEN
WEND
END

SUB remapall: //Takes all pictures and resizes them for the device being used
IF x<>1 AND y<>1 //If exactly the same then you are using the device made for
CREATEDIR(docdir$)
LOCAL needresize=1
IF DOESFILEEXIST(docdir$+"/ver.txt") //Must exist in target directory
IF DOESFILEEXIST("ver.txt") //And in media directory
LOCAL file1=GENFILE()
OPENFILE(file1,docdir$+"/ver.txt",TRUE)
LOCAL file2=GENFILE()
OPENFILE(file2,"ver.txt",TRUE)
LOCAL file1line$,file2line$
READLINE file1,file1line$
READLINE file2,file2line$
IF file1line$=file2line$ THEN needresize=0
CLOSEFILE file1
CLOSEFILE file2
ENDIF
ENDIF
IF needresize=1
LOCAL file$[],num,i
num=GETFILELIST("*.*",file$[])
IF num>0
FOR i=0 TO BOUNDS(file$[],0)-1
remapimage(file$[i])
NEXT
ENDIF
COPYFILE "ver.txt",docdir$+"/ver.txt"
ENDIF
SETCURRENTDIR(docdir$)
ENDIF
ENDSUB

FUNCTION remapimage:file$ //Takes a picture and resizes it for the device being used
IF DOESFILEEXIST(file$)
LOCAL rightf$=UCASE$(RIGHT$(file$,3))
IF rightf$="PNG" OR rightf$="BMP" OR rightf$="JPG" //I know it says it can but JPG just doesn't work. Wrong colours and crashes a lot. Use PNG!
LOCAL width,height
LOCAL usesprite=GENSPRITE()
LOADSPRITE file$,usesprite
GETSPRITESIZE usesprite,width,height
LOCAL pix%[]
LOCAL ok%=SPRITE2MEM(pix[],usesprite)
LOCAL pix2%[]
LOCAL xwidth%=width*x
IF INTEGER(xwidth)<>xwidth THEN xwidth=INTEGER(xwidth)+1
LOCAL xheight%=height*y
IF INTEGER(xheight)<>xheight THEN xheight=INTEGER(xheight)+1
DIM pix2%[xwidth*xheight]
LOCAL xl
LOCAL bx,by
FOR xl=0 TO BOUNDS(pix2[],0)-1
bx=INTEGER(MOD(xl,xwidth)/x)
by=INTEGER(INTEGER(xl/xwidth)/y)
pix2[xl]=pix[bx+by*width]
NEXT
LOCAL usesprite2=GENSPRITE()
MEM2SPRITE(pix2[], usesprite2, xwidth, xheight)
SAVESPRITE docdir$+"/"+file$,usesprite2
LOADSPRITE "",usesprite
LOADSPRITE "",usesprite2
ENDIF
ENDIF
ENDFUNCTION

FUNCTION debug_out: in$
LOCAL out$
out$="[APP] "+MID$(PLATFORMINFO$("TIME"),11,8) + ": "+ in$+"\n"
?IFDEF IPHONE
STDOUT out$
?ELSE
DEBUG out$
?ENDIF
ENDFUNCTION

FUNCTION updateMice:
LOCAL imouse%,mx%, my%, b1%, b2%
FOR imouse% = 0 TO MIN(GETMOUSECOUNT()-1,4)
SETACTIVEMOUSE imouse%
MOUSESTATE mx%, my%, b1%, b2%
mouse[imouse].x=mx/x
mouse[imouse].y=my/y
mouse[imouse].active=b1
NEXT
ENDFUNCTION


Cheers

[attachment deleted by admin]
#46
Sometimes a routine or a function is very long and you forget where you are (or if you search for something and are now in another routine when you think you are in the routine you first searched from), so it would be nice to be able to see somewhere which function or sub you are inside. Either that or highlight it in the jumps list.

Cheers
#47
Bug Reports / IDE jumps
2011-Mar-25
I've only just noticed that sometimes the jumps aren't working at all. I'm not sure exactly when it happened but I upgraded to 9.040 today and I've noticed it all morning. At first I thought it was just jumping to the routine above the one I wanted, but I am getting it go completely wrong now and put me in the middle of a totally random routine! One example I have is two routines away (the one I'm after doesn't even start until at least 20 lines below the bottom of the screen).

Cheers
#48
GLBasic - en / Project name
2011-Mar-23
Ok so I'm making a free version of my game, and I copied the project directory to a different name. I also then changed the project name in the project options. However when I load up GLB and it shows the list of projects both the free and full version have the same name (the one from the full version). What am I missing?

Cheers
#49
I've written a small routine to automatically load iOS retina sized graphics and resize to the screen size you are actually using (eg. 3GS res). It then saves these using savesprite to a png file so next time it will load faster (and more importantly use less memory) on the non-retina devices (using a version file). This nicely works apart from one thing. Basically anything with transparency I have as pink (255,0,128) and even make sure it is set to pink just incase at the start of the routine. I then fill the screen with pink to make sure if the transparency channel of the png is being used rather than pink then it will make those pixels pink (forget partial transparency for now, even if GLB supports it). I then paste it resized, use grabsprite, and then savesprite.

All this works very well. I have no issues. Apart from transparency. I have a png file that resizes correctly, and keeps the pink that was in the original as pink. They are exactly the same except the resized one is 4 times smaller obviously. However using the resized sprite keeps the pink on the screen, whereas the original is transparent. Interestingly using Paint Shop Pro 8 if I load the resized sprite and then immediately save over itself, then GLB shows the pink as transparent, which leads me to believe that possibly the savesprite command doesn't work correctly with the transparent channel.

I've included the 3 files for comparison. Basically retina.png is the original large sprite. resized.png is what GLB automatically created (on a PC, I haven't tried yet on iOS) which shows transparent instead of pink. And psp8.png is the same resized.png that I just loaded into psp8, saved immediately, and then ran the exact same GLB code again to find it worked with transparency.

Cheers



[attachment deleted by admin]
#50
I posted this elsewhere but thought here would be better.

This code on the iPhone keeps building up used memory until it eventually crashes:-
Code (glbasic) Select
ttime=GETTIMERALL()
ttotal=0
tsprite=GENSPRITE()
WHILE 1=1
IF GETTIMERALL()-ttime>100 
LOADSPRITE "Media/1-1.png",tsprite
INC ttotal
ttime=GETTIMERALL()
ENDIF
PRINT ttotal,0,0,10
SHOWSCREEN
WEND


If I use a loadsprite "",tsprite directly after the loadsprite command it makes no difference. From the graph in XCode you can see it gives back a little memory when loading the sprite again (seen by spikes in graph), but nowhere near enough.

Cheers

[attachment deleted by admin]
#51
Ok so I've got an image I use with LOADANIM (see attached youwin.png) that is basically an animated "You win". It works perfectly in Windows, and on a 3GS iPhone (4.2.1), but a 2nd gen iPod Touch (4.1) shows the animation incorrectly. Everything else is identical between the 3GS and the iPod. The animgated image looks a little offset. I've included the main file, a screenshot from the 3GS, and a screenshot from the iPod.

The loading code I use is this:-
Code (glbasic) Select
GLOBAL youwinid=100
GLOBAL youwinwidth=220
GLOBAL youwinheight=120
LOADANIM "Media/youwin.png",youwinid,youwinwidth,youwinheight


and the drawing code is this:-
Code (glbasic) Select
SUB youwon:
ALPHAMODE 1
DRAWANIM youwinid,frameno,gamescreenx/2-(youwinwidth/2),gamescreeny/2-(youwinheight)
ALPHAMODE 0
SETFONT 1
LOCAL scorestr$="Score:"+score
PRINT scorestr$,gamescreenx/2-(LEN(scorestr$,kern)/2),youwinheight+(gamescreeny/2)-(fonty/2)-fonty,kern
IF showcontinue=1
scorestr$="Continue"
PRINT scorestr$,gamescreenx/2-(LEN(scorestr$,kern)/2),screeny-fonty,kern
ENDIF
SETFONT 0
scorestr$="Moves:"+moves
PRINT scorestr$,gamescreenx/2-(LEN(scorestr$,kern)/2),youwinheight+(gamescreeny/2)-(fonty/2),kern
SETFONT 3
scorestr$="High:"+oldhigh
IF score>oldhigh THEN scorestr$="Old "+scorestr$
PRINT scorestr$,gamescreenx/2-(LEN(scorestr$,kern)/2),bottombar,kern2
IF GETTIMERALL()-lasttimer>100
INC frameno
IF frameno>5 THEN frameno=0
lasttimer=GETTIMERALL()
ENDIF
ENDSUB


Cheers

[attachment deleted by admin]
#52
IDE/Syntax / Toolbar move
2011-Feb-27
Ok, so I have GLB v9 on my desktop and my laptop. They are both widescreen but the laptop is a higher resolution at 1920x1200. I copy the same projects between the 2 main machines depending where I am. Anyway, I've noticed that the toolbar that has the macro icons always moves to below the main toolbar when using the laptop. This every time I restart GLB. There is about half the width of the screen left to put the macro toolbar to the right of the main toolbar, and in fact more width than the desktop has. I can move the macro toolbar to the right of the main toolbar and all is fine, but I have to do this everytime I start GLB on the laptop. As I said, the desktop is absolutely fine and the macro toolbar always appears to the right of the main toolbar on GLB startup.

Cheers 
#53
Ok so it would be brilliant to write an AR (augmented reality) app or game for the iPhone. Obviously this would require access to the camera and be able to interact with that constantly updating image. So not just a plugin to allow access to the camera and then bring a photo back to GLB but to have the view from the camera on screen with full control to GLB so we can overlay it with graphics and the like.

So anyone know how to go about it?

Cheers
#54
Bug Reports / V9 print bug
2011-Feb-13
I've found a strange bug with text since installing v9. Basically the following code used to work fine in v8 but now with V9 only the second print command works, with the first one completely missing (GAMENAME text). I've put in debugging and it gets to the line with the correct parameters.
Code (glbasic) Select
IF youhavewon=0
SETFONT 1
textstr$="GAMENAME"
PRINT textstr$,screenx/2-(LEN(textstr$,kern)/2),screeny-fonty+5,kern
IF lastbatt=-1 OR GETTIMERALL()-lastbatt>10000
lastbatt=GETTIMERALL()
//mybatt%=MIN(100,MAX(0,INTEGER(PLATFORMINFO$("BATTERY")))) //Doesn't seem to work on iPhone currently (get 3% lower or so)
mytime$=PLATFORMINFO$("TIME")
mytime$=MID$(mytime$,11,2)+":"+MID$(mytime$,14,2)
ENDIF
SETFONT 2
//textstr$=mybatt%+"%"
//PRINT textstr$,screenx-LEN(textstr$,kern2),screeny-fonty2,kern2
textstr$=mytime$
PRINT textstr$,0,screeny-fonty2,kern2
IF multiplayer=1 THEN PRINT moveinfo$,0,0
ENDIF


Now the stranger bit. I noticed that if I moved the GAMENAME 3 lines of code (SETFONT to the PRINT line) to after the IF then it prints that, but not the text inside the IF (ie. the time).

And an even stranger bit. If I take the "PRINT textstr$,screenx/2-(LEN(textstr$,kern)/2),screeny-fonty+5,kern" line, that is for the "GAMENAME" text, and copy it immediately below the existing command (ie. two identical PRINT commands one line after the other), then it works just fine, with both text appearing. So perhaps a new bug that means the first print in a subroutine (this is in a subroutine in a separate gbas file) does not print? Something is up that's for sure.

Cheers
#55
So Grabsprite allows a portion of the backbuffer to be grabbed, which serves me fine, but I was wondering if there was a way to grab the front buffer (ie. the screen) apart from the really slow getpixel? Either that or copy the frontbuffer to the backbuffer would be fine.

Cheers