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

Pages: 1 ... 233 234 [235] 236 237 238
3511
Code Snippets / Re: OSJ - Part 1
« on: 2011-May-30 »
its not perfect onscreen and of course some thing need to been improvements...

- Joystick should not autos center itself when finger touched down and move joystick out of the edge. Its should first autocenter around 20-25% larger edge than the base its self.
- Output should of course been -1 to 1 and not from -60 to 60 (this due all normal Joystick commands does that and me think should do the same here). This could been easy done in UpdateX() and UpdateY().
- MouseState() should been first of the control() and not to last. When its below, there would been one frame delay, before something happens, and I dont like that. Its a easy fix :-D
- Scaling support and Multitouch of course.

The most major issue is really the first one about auto center, which would been much much better onscreen joystick when fixed.. But its still a great start to do a great analog onscreen joystick support. I have not coded such of one, because my secret game is not need that, but I more using angles rather than collosions boxes, even for digital joystick (2way, 4way and 8way).

3512
Code Snippets / Re: OSJ - Part 1
« on: 2011-May-29 »
apart from that, its does works very well, but did only tested with mouse :-D.

3513
Code Snippets / Re: OSJ - Part 1
« on: 2011-May-29 »
its can been pretty annoying if nothing happens becaues you a not precision pressed on the center (etc you came to release your finger). Then I actuelly prefer either its reposition its self on the touch (seen in some games, like Age of Zombies or Epic Citadal), or just point to the neast position where the finger is (when touched on base or near it).

3514
Code Snippets / Re: OSJ - Part 1
« on: 2011-May-29 »
You need to press on the center first where the joystick is, before you can move it. In the real time, that can been pretty annoyring and slowdown the control of the game.

The joystick should just pull into the nearst direction where I pressed in some sort of distance.

Also you putted this to the Code Snippets forum with no code......

3515
The IDE does not crash or anything like that, its just output about it in some cpp files and hence never run the app.

So I was thinking its was issue with the temporary files, which its was.

The app did all compiled completly fine and ran fine after I cleaned them.

So hence not sure its a bug, but really more a feature request in the IDE.

3516
Code Snippets / Re: Sprite Speed Tester
« on: 2011-May-29 »
sorry, I diddent see that. I should read the whole thread, but would been nice to edit the post to include the missing file too.

3517
Code Snippets / Re: Sprite Speed Tester
« on: 2011-May-29 »
I cant compile this, due missing TAppTime.Gbas and is not included. Remember to include anything, if you include source for it

3518
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.

3519
Beta Tests / Re: Glowing Sky
« on: 2011-May-29 »
Nice little app, and nice done. Would been fun to been able to create a longer "snake" when you draw around (etc set from options). Small think, not need to been do at all.

Its would works great on iPad, but not on the smaller screens like iPhone and iTouch, due the small touch areas in options?

PS. I think the hompage need to been updatede too, its look like early 90 style, hehe (dont take that as negative, I guess you know about it allready). Mine need to been updated too.

3520
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).

3521
GLBasic - en / Re: APPLE App Rejected :-(
« on: 2011-May-29 »
its could somewhere a loop or timeout issue. I read 4.3 is more strict about timeout under loading and such? make sure to do something feed back under loading me think?

3523
GLBasic - en / Re: Autorotate?
« on: 2011-May-27 »
Its not 100% correct, MOUSESTATE need to been manually flipped too, elsewise its would still read like its was not rotated and hence its would read mouse positions completly wrong.

Howver this could of course been done automatic too if the new command is added.

personally I allready coded some sort like that.  simply draw Images and Rect to a function, rather directly, something like a PaintImage(). Using with a function, its possible to manually rotate them, before acutelly paint them. You can do the same with the controls.

Also auto rotation is also required to been supported for iPad, since Apple might just reject the app, if the game is a Landscape game.



3524
Bug Reports / Re: INPUT$
« on: 2011-May-26 »
hm? why create your own? Personly I have never liked this kind type of commands (print here does make nice seance throught), because you have no control what user input, and also the length of them.

Instead I have allways create my own. But this one might do work for text advetures :-D

PS. And yes is a bug (Just like ViewPort), but would been nice to set a limit length in the next SDK.

3525
If viewport just clipped without any change to cords (etc x and y is allways as top left on the current USESCREEN), then it would been fine too.

I using screen 2 to draw a tiled map with alpha and more, but its placed wrong in all cords. Can't do that on back buffer at all.

PS. I forget a VIEWPORT 0,0,0,0 in the example (should placed just after the purple box), buts its does the same anyway.

Pages: 1 ... 233 234 [235] 236 237 238