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

#161
Its seen GlBasic does not load alpha infomation from png file correct and change the gray shadow very much. Its look like GlBasic MultiPly alpha info, where its should not.

And yes I have tried to set various values of ALPHAMODE as well SMOOTHSHADING without any luck.

Here is the image (Gl Basic is left, but its should look like right):


I'm are simply not sure what it happens, nor I cannot uploade a test sample, since I allready have tried all compos right (howoer I could do a later simple test app when needed).

EDIT: PS. I use ROTOZOOMSPRITE (and yes I do draw the tilemap using POLYVECTOR).
#162
Some things I came to write something like this:

FOR i=1 TO R:

Also colon istedet for underscore, where colon on a danish keyboard is just left for the _ key.

So when that happens, all variables which have r would been change to R, just directly after when wrote :... As you guess its cause a lots of compile errors.

But its pretty annoying you cannot undo that change, when happens... Editor simply not change it back again, which it should. So I need to manual find all the changes to revert it every time.

Also functions write after some commands should never cause editor to change any letter since its not valid anyway, or editor should first auto mark when you change line..... or something like that.
#163
Code (glbasic) Select

//LOCAL col AS Col_Data
LOCAL col=Map_Collision(32, 99)

TYPE Col_Data
x
y
l
tile
origtile
ENDTYPE

FUNCTION Map_Collision AS Col_Data: xpos, ypos //, sourceimage=-1, origtile=0
LOCAL col AS Col_Data
RETURN col
ENDFUNCTION


If I doing above I got a lots of annoyring FATAL ERROR rather to automatic either sport the error while comping or convert the object automatic when I used a local. This mean I cant use a function, that return a object to a IF directly, but need more lines due this.....

PS. If I remove the slashes its works. But since its not really a bug, but more a request, I post it in the request thread instead.

#164
Here is a little code snippit which some might have a nice use for using strings in a different way. I have used this kind of code in years, also in BlitzMax too. I did this because I have never liked number based images system, where I better prefer strings and names. They are easier to remember, but of course its somewhere slowere. But should not been that much, if you use more than one Base names.

I of course use in my next project (last one was a music project for Jungool), which is still secret, due its all using placeholder graphics and is so early. Thís code is nowhere secret.

I known the comments could been better, but hope its self explained.

Code (glbasic) Select

// --------------------------------- //
// Project: tVar Database by Space Fractal

TYPE TVar
Name$=""
Value$=""
ENDTYPE

TYPE TVarFile
File$
VAR[] AS TVar
ENDTYPE

GLOBAL MyVar[] AS TVarFile

// find a string
FUNCTION FindStr$: Search$, Base$
FOREACH item IN MyVar[]
IF item.File$=Base$
FOREACH item2 IN item.VAR[]
LOCAL Se$=LEFT$(item2.Name$, LEN(item2.Name$, Search$))
IF Search$=Se$ OR Search$="all"
RETURN item2.Name$
ENDIF
NEXT
ENDIF
NEXT
RETURN ""
ENDFUNCTION

// get a string
FUNCTION GetStr$: Name$, Base$="def"
IF Base$="" THEN RETURN ""
FOREACH item IN MyVar[]
IF item.File$=Base$
FOREACH item2 IN item.VAR[]
IF item2.Name$=Name$ THEN RETURN item2.Value$
NEXT
RETURN ""
ENDIF
NEXT
ENDFUNCTION

// remove a string, or use "all" on name, if you want to delete a String Base
FUNCTION RemoveStr: Name$, Base$="def"
LOCAL COUNT=0
IF Base$="" THEN RETURN ""
FOREACH item IN MyVar[]
IF item.File$=Base$
FOREACH item2 IN item.VAR[]
IF item2.Name$=Name$ OR Name$="all"
DELETE item2
IF Name$<>"ALL" THEN BREAK
ENDIF
NEXT
ENDIF
NEXT

FOREACH item IN MyVar[]
IF item.File$=Base$
IF LEN(item.VAR)=0
DELETE item
RETURN
ENDIF
ENDIF
NEXT
ENDFUNCTION

// set a string
FUNCTION SetStr: Name$, Base$, Value$
LOCAL i,m
IF Base$="" THEN RETURN ""
IF Name$="" THEN RETURN ""
FOREACH item IN MyVar[]
IF item.File$=Base$
FOREACH item2 IN item.VAR[]
IF item2.Name$=Name$
item2.Value$=Value$
RETURN ""
ENDIF
NEXT
ENDIF
NEXT
m=0
FOREACH item IN MyVar[]
IF item.File$=Base$
m=1
BREAK
ENDIF
NEXT
IF m=0
m=BOUNDS(MyVar[], 0)
REDIM MyVar[m+1]
MyVar[m].File$=Base$

ENDIF

FOREACH item IN MyVar[]
IF item.File$=Base$
m=BOUNDS(item.VAR[], 0)
REDIM item.VAR[m+1]
item.VAR[m].Name$=Name$
item.VAR[m].Value$=Value$
ENDIF
NEXT
ENDFUNCTION


// check if file exists and also the user did not have changed anything. Do this before you do LoadStr.
FUNCTION ChechfileIni: File$
LOCAL ok, st$,splits$[], count, hash=0

ok=OPENFILE(1, File$, 1)
IF ok=FALSE THEN RETURN FALSE

LOCAL number=3423
REPEAT
number=number+1
st$=LINEREAD$(1)
st$=TRIM$(st$)
IF TRIM$(st$)="" THEN BREAK
hash=0
IF LEFT$(st$, 1)="#"
LOCAL l$=StringField$(st$, 2, "#")
LOCAL r$=StringField$(st$, 3, "#")
IF HashString$(l$)<>r$
CLOSEFILE 1
RETURN FALSE
ENDIF
ELSE
IF hash=0 THEN RETURN
ok=SPLITSTR(st$,splits$[], "|")
IF ok<>3
CLOSEFILE 1
RETURN FALSE
ENDIF
ENDIF
UNTIL ENDOFFILE(1)
CLOSEFILE 1
RETURN 1
ENDFUNCTION

// load anyting from a ini like file.
FUNCTION LoadStr: File$, Base$
LOCAL ok, st$,splits$[], count, hash=0

ok=ChechfileIni(File$)
IF ok=0 THEN RETURN FALSE
ok=OPENFILE(1, File$, 1)
IF ok=FALSE THEN RETURN FALSE

FOREACH item IN MyVar[]
IF item.File$=Base$ OR Base$="all"
DELETE item
ENDIF
NEXT
LOCAL number=3423 // used for a number based key in crypting.
REPEAT
count=count+1
number=number+1
st$=LINEREAD$(1)
st$=TRIM$(st$)
IF TRIM$(st$)="" THEN BREAK
hash=0
IF LEFT$(st$, 1)="#"
LOCAL l$=StringField$(st$, 2, "#")
LOCAL r$=StringField$(st$, 3, "#")
IF HashString$(l$)=r$
hash=1
st$=TRIM$(DECRYPT$("C3&7vxdfFFr3)4"+number+"/&fddsfgsd", l$)) // make sure to change this key, as well in the SaveStr.
// ELSE
// hash=0
// CLOSEFILE 1
// RETURN
ENDIF
ENDIF
IF hash=1
ok=SPLITSTR(st$,splits$[], "|")
IF ok=3
IF splits$[1]="" OR splits$[0]="" OR splits$[2]="" THEN BREAK
IF splits$[1]=Base$ OR Base$="all"
SetStr(URLDECODE$(splits$[1]), URLDECODE$(splits$[0]), URLDECODE$(splits$[2]))
IF count>1024 THEN BREAK
ENDIF
ENDIF
ENDIF
UNTIL ENDOFFILE(1)
CLOSEFILE 1
RETURN TRUE
ENDFUNCTION

// save all strings to a database
FUNCTION SaveStr: File$
LOCAL ok, st$, sc$
ok=OPENFILE(1, File$, 0)
IF ok=FALSE THEN RETURN
LOCAL number=342347
FOREACH item IN MyVar[]
FOREACH item2 IN item.VAR[]
number=number+1
st$=URLENCODE$(item.File$)+"|"+URLENCODE$(item2.Name$)+"|"+URLENCODE$(item2.Value$)
sc$=st$
st$=TRIM$(ENCRYPT$("C3&7vxdfFFr3)4"+number+"/&fddsfgsd", st$)) // make sure to change this key, as well in the LoadStr.
LOCAL h$=TRIM$(HashString$(st$))
st$="#"+st$+"#"+h$
WRITESTR 1, st$+"\r\n"
NEXT
NEXT
CLOSEFILE 1
ENDFUNCTION


// Some Help commands (etc ReadString diddent work, due 1024 char limit)
FUNCTION LINEREAD$: FileNr
LOCAL chda$, L$=""
REPEAT
IF ENDOFFILE(FileNr) THEN BREAK
READSTR FileNr, chda$, 1
L$=L$+chda$
UNTIL ASC(chda$)=10
L$=TRIM$(L$)
RETURN L$
ENDFUNCTION

FUNCTION HashString$: Str$
STATIC a$, ch%
a$=""
ch=0
FOR i=1 TO LEN(Str$)
a$=MID$(Str$, i, 1)
ch=ch+ASC(a$)+i*453
NEXT
ch=ch*4
a$=ch
IF LEN(a$)>8 THEN a$=RIGHT$(a$, 8)
RETURN a$
ENDFUNCTION

FUNCTION StringField$: TXT$, index%, Delimeter$
LOCAL i, char$
LOCAL RESULT$=""
FOR i=0 TO LEN(TXT$)
LOCAL char$=MID$(TXT$, i, 1)
IF char$=Delimeter$ OR i=LEN(TXT$)
index%=index%-1
IF index%=0 AND i=LEN(TXT$)
RETURN RESULT$+char$
ENDIF
IF index%=0 THEN RETURN RESULT$
IF i=LEN(TXT$) THEN RETURN ""
RESULT$=""
ELSE
RESULT$=RESULT$+char$
ENDIF
NEXT
RETURN ""
ENDFUNCTION

// If you are tired to use number based images, then you can do something like below
FUNCTION imageGet: Name$
LOCAL img
img=GetStr$(Name$, "Sprites")
RETURN img
ENDFUNCTION

FUNCTION imageLoad: File$, Name$, animWidth=0, animHeight=0
LOCAL result, i,r, img, fil$
fil$=GetStr$(Name$, "Files")
IF fil$=File$ // if image is allready loaded, then dont load it again
RETURN
ENDIF

result=GETFILESIZE(File$)
IF result=0 THEN RETURN FALSE


img=GetStr$(Name$, "Sprites")
IF img<>0
LOADSPRITE "", img
result=img
ELSE
result=GENSPRITE()
ENDIF

IF animHeight=0
LOADSPRITE File$, result
ELSE
LOADANIM File$, result, animWidth, animHeight
SetStr(Name$+".w", "Anim", animWidth)
SetStr(Name$+".h", "Anim", animHeight)
ENDIF
GETSPRITESIZE result, i, r
IF i=0 OR r=0 THEN RETURN FALSE
SetStr(Name$, "Sprites", result)
SetStr(Name$, "Files", File$)
RETURN TRUE
ENDFUNCTION

FUNCTION imageRemove: Name$
LOCAL img, result
img=GetStr$(Name$, "Sprites")
LOADSPRITE "", img
RemoveStr(Name$, "Sprites")
RemoveStr(Name$, "Files")
ENDFUNCTION


You could also do a imageDraw function to draw the image, using names instead of variables.
#165
I have today have FATAL ERROR issues, that did not give any means at all, when I added the same variable in a new gbas file with the same name. Then I cleaned up the Windows temp folder and then its all works again, even with fast compiling after that.

Not sure a where the conflict was, but diddent gave any means. I did something like this (but in much larger scale):

Code (glbasic) Select

SUB One_gbas:
LOCAL A
ENDSUB

in another gbas file:

SUB Another_gbas:
LOCAL A
ENDSUB


The above DOES not allways got the error of course, so trying the above might works.

I gonna think if there is a FATAL ERROR issue, GlBasic should try to delete the whole temp folder and try again or alternative, if you recompile again after a FATAL ERROR, without user have change anything could do the same thing.

PS. Deleted its from beta, since its was more a bug or a feature request (so fell free to move it to IDE REQEST section).
#166
If I use offscreen screen, used with a "CREATESCREEN" command, then the cords is completly messed up and not working at all.

Here is the code I use for invoke the bug (a least on Windows):

Code (glbasic) Select

SETSCREEN 800, 600, 0
CREATESCREEN 2, 2, 200, 200

USESCREEN -1
DRAWRECT 0, 0, 200, 200, RGB(100, 0, 0)

USESCREEN 2 // view port dont like this screen and then messing the cords up completly.

//USESCREEN -1 <- doing this, VIEWPORT cords works, but... I can't use that in my case.
DRAWRECT 0, 0, 200, 200, RGB(200, 200, 200)
VIEWPORT 50, 50, 100, 100
DRAWRECT 0, 0, 100, 100, RGB(200, 0, 100) // this purple box, inside the gray box is gone, if USESCREEN 2 is used.
USESCREEN -1
DRAWSPRITE 2, 250, 250

SHOWSCREEN
KEYWAIT


The purple box is simply not draw at all, but should been drawed at the center of the gray box.
#167
I posted this into the request post, but I would like to see few new sound commands that would add awesome thing to the GlBasic, since you have not have very much control over its sound. Music is all really ok.

1. BALANCESOUND(channgel%, pan#, volume#) <- you can't do that with PLAYSOUND(), since its start from beginning every time.
2. LOOPSOUND(channel%, TRUE/FALSE) <- yes I are aware of SOUNDPLAYING(), but its not seamless.
3. PAUSESOUND(bPause&) <- same as with music, just for sound.
4. ADPCM Wav support for sound. Its a joke its not supported. But i DO found ok NOT to support ogg and mp3 here.

Then I can do 4-5 channels loop music in the same way I did for example in a Space Taxi game I wrote for ten years ago (in Java).

PS. Fell free to move it into the request an sorry if I posted in this general forum.
#168
I want to get the size of the tile of a anim, but have a problem.

If I use GETSPRITESIZE i got the whole image size, rather than tile size as I want.

So GETSPRITESIZE object, w, h is not a option at all when using anim.

This is due STRETCHANIM command want to known its size, rather than using procent like other commands does. That is really dumb, when the app dont known the size of it and then it would been fussy.

Also STRETCHANIM use current size rather than using procents, like other commands do.

I trying to just mirror a animated sprite (in one axis), using its current tile size.
#169
I tried this code:

Code (glbasic) Select

LOCAL tem, ok
ok=OPENFILE(1,"test.ini", 1)
WHILE ENDOFFILE(1) = FALSE
READBYTE 1, tem
WEND


but I just got compile error:
Code (glbasic) Select

_______________________________________
*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.7.861 SN:a001d9df - 3D, NET
Wordcount:5 commands
compiling:
C:\Users\SPACEF~1\AppData\Local\Temp\glbasic\gpc_temp0.cpp: In function `int __GLBASIC__::__MainGameSub_()':
C:\Users\SPACEF~1\AppData\Local\Temp\glbasic\gpc_temp0.cpp:41: error: invalid initialization of reference of type 'DGNat&' from expression of type 'DGInt'
D:/Programmer/GLBasic/Compiler/platform/Include/glb.h:1022: error: in passing argument 2 of `void __GLBASIC__::READBYTE(DGNat, DGNat&)'
*** FATAL ERROR - Please post this output in the forum
_______________________________________
*** Finished ***
Elapsed: 1.2 sec. Time: 19:40
Build: 0 succeeded.
*** 1 FAILED ***


Also why is the readline limit to around 1024 chars? This cause xml hard to do with (this cause XMLParser not wokring (code snippet found in this forum), and that about LEN LINE=1023 didden't work quite well.... And even harder when ReadByte diddent work at all.
#170
In the Options I set it to 60hz (which the graphics is locked too).

But if I set it to LimitFPS 60 in the code too, then the scroll is being skip a lots of frames, where its should been fluid (which look akward).

But in the other side, if I set it to LimitFPS -1, then its still set to 60fps limit (as I set that in the options), then its does it 100% fluid without framedrops or does that very very rare (all ok).

Also course that take a lots of cpu too (which is not a problem in a game my guess). Its might impact in a mobile phone thought, if I use LimitFPS -1 too?

Even If I set it to LimitFPS 30, its does jerky at time, but its not very noticable at all and complete playable.

So I dedicated to do 65 fps "update()" code (using system timer) and then do a separate "paint()". Something like this:

Code (glbasic) Select

FUNCTION Run:
Delay=update_Delay(65)
run:
IF Delay>0
Controls() // controls only need to been updated once per frame.
FOR i=1 TO Delay
Update()
NEXT
ENDIF

Paint()
CLEARSCREEN -1
SHOWSCREEN
Delay=update_Delay()
IF KEY(1)=1 THEN END
GOTO run
ENDFUNCTION

FUNCTION  update_Delay: displayUpdateFreq=0
STATIC Fps
STATIC Timer#=GETTIMERALL()

IF displayUpdateFreq=0 THEN displayUpdateFreq=Fps
Fps#=displayUpdateFreq
LOCAL frames#, currentTimer#
    LOCAL maxDelay# = 1000 / displayUpdateFreq
    currentTimer#=GETTIMERALL()
    frames=(currentTimer#-Timer#)/maxDelay#
    IF frames<1 THEN RETURN 0
Timer=currentTimer
    RETURN INTEGER(frames)
ENDFUNCTION  // UPDATE_DELAY


So with above code, the  gameplay run 65fps, regaardless what LimitFPS is set to (65fps is set to avoid eventuelly jerky too).

So in that way I did go workaround the LimitFPS issues, but I do not sure what it happens if Vsync is forced disabled (and using LimitFPS -1)? I still want double buffer, even it might draw insanly fast...
#171
I dont use clearscreen at all for the main drawings of the backgrounds.

But I doing drawing sprites using pngs with alpha, and I drawing them to a offscreen screen (USESCREEN 2). This is for avoid eventuelly seams artifact when scaled down.

This is not a option of course for the backbuffer, but its would been very neat to do that on offscreen screens aswell.

etc doing someting like CLEARSCREEN -2 for no color wipeout? (howover -1 could do that IF used other than screen 0).


I tried using CREATESCREEN in each frame, but is painfully slow....

Code (glbasic) Select

LOCAL frame, animframe, w, h
USESCREEN 2
frame=imageGet("Game")
GETSPRITESIZE frame, w, h
CREATESCREEN 2, frame, w, h
animframe=imageGet("tiles")
USESCREEN 2
DrawMap(animframe, scr_X, 40, 0, 0, w, h)

#172
I just for fun tried to plugin 2 mice into my computer for testing GETMOUSECOUNT() to work in Windows 7, but its still only found one? I think its just a litle limit, rather than a bug, since its not added currectly to Windws as stated in help file, but wrote about here to avoid forgetting it.

Also does Palm not support multitouch too and workable? if yes, the help file is somewhere unprecision.

I do seen multiply mices to work in other Windwos OS too, but Windows 7 is most important me think.

PS. Even older sysetems, MAME (A arcade emulator) could found more than one mices.
#173
After trying to math how to math a sprite, based on topleft, center or rightcenter hotsots after about 10-15 hours, then I gave up.

Is is possible to change the hotspot on zoomsprite as well other sprite commands to set on the top left, which would been LOTS easier to math the placement of them? Something a missing command?

Here is the funtion I try to create. The box draw perfect, but zoomsprite is the issue, its not setting on the box as it should:

Code (glbasic) Select

FUNCTION PaintImage: Name$, x#, y#, alpha#, zoom#, xspot, yspot, yy#
zoom#=0.5
x=0
y=0
xspot=1
yspot=-1
IF alpha#=0 THEN RETURN
IF alpha#>0
alpha#=0-alpha#
ELSE
alpha#=-alpha#
ENDIF
LOCAL h#, w#, z#
LOCAL img, hh#, ww#
IF alpha#<>0 THEN ALPHAMODE alpha#
IF Name$=0
img=GetStr$(Name$, "Sprites")
ELSE
img=Name$
ENDIF
GETSPRITESIZE img, w, h

// rect maths
IF xspot=-1 THEN PX=x#
IF xspot=0 THEN PX=ScreenWidth/2.0-(w#*zoom#/2.0)+x#
IF xspot=1 THEN PX=ScreenWidth-w#*zoom#-x#*zoom#

IF yspot=-1 THEN PY=y#
IF yspot=0 THEN PY=ScreenHeight/2.0-(h*zoom#/2.0)+y#
IF yspot=1 THEN PY=ScreenHeight-h#*zoom#-y#*zoom#
PW=w*zoom#
PH=h*zoom#

// ALPHAMODE 0.2
DRAWRECT PX, PY, PW, PH, RGB(255, 255, 255)


SELECT ROTATE
CASE 180
PX=ScreenWidth-PX-PW
PY=ScreenHeight-PY-PH
CASE 0
ZOOMSPRITE img, PX, PY, zoom#, zoom#
DEFAULT
ENDSELECT
ENDFUNCTION


I use this for scaling graphics for any resolutions.

PS. I use name rather than number for ease programmering, so you can coomand the getspr$ out without issue.

PPS. YY# does nothing at all, and is just a placeholder to been removed later.
#174
First at all, its common to use compressed format today and have been done that in years. Why does GlBasic still only use PCM-WAV? Its take a lots os hardrive space for a download game, when using many sfx.

for me even ADPCM-Wav format would been much better choice, which is a nice SFX format, even its a pretty old format. Its still a good SFX format, that dont use so much memory as PCM-WAV does.... And for systems, that cant play native that format, could jus uncrompress in load time.

That for is that I have used in years. Ogg would also been nice to been supported for systems that native support it for Music (patent crap), elsewise its should return a error (same with other music formats, like m4a). Howover its not a issue normallt for phones, since carriers allreadt have paid for that (as I aware at).

there is also a missing for a PAUSESOUND() and RESUMESOUND().

Also its would been nice to checkout where the music position is and also to play move the position in the music file, if possible.

I might came with more ideas for better sound commands, since they are really basic right now (but does works, which is important).
#175
how do I detect if a sprite exists or not, whithout the editor jump to that line on exists... which is pretty annoyring.

I use something like this:

GETSPRITESIZE t, XX, YY

And if XX is 0, I asume there is no sprite here and do some code here.

If a do its on a TRY command, the editor just annoyring jump there instead.

I hate when the editor jump to these commands on exists, so I need to scroll where I was code every time, when I known there is no bug here......

I need to find a with to detect if a sprite exists or not WITHOUT these annoyring jumps.

PS. It might have caused by LOADSPRITE when no file found, but I dont think that is a issue, but using DOESFILEEXIST now instead to avoid that editor jump.
#176
values between 0.0 and 1.0 works as it should, but values between -1.0 and 0 works very odd and can been very confuction to been used the right way.

By now -1 and 0 is the same, but -1 should been blank and not a value close to 0. Its simply seen the command do the other way as its should.

Normally 0 should been the middle point, so 0 is normal, -1 is completly off and 1 is lightest.

This would been much easier to understand.

PS. I known there is a workaround by creating a SETALPHAMODE function and do the math here, but for me its still a bug.