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

Messages - metzzo

#61
Yes there are tons of news regarding GLBScript... but just wait until 11th may (that's the two years birthday of GLBScript). Then I'll make a big post in the english section!

I don't want to spoil too much but some highlights are: Working GOTO support, full filesystem API and much more :)

#63
Hey!

I just want to say that my game is finished. It's a 2.5D platformer!

Download!
#64
hey!

A short status report: Since last firefox update (version 11) the xmlhttprequests I'm using for getting data for OPENFILE doesn't work with local files anymore. Chrome and Safari does not support it anymore too. So I have to rewrite the whole File I/O system. The approach I am now using is simple: Just embed all data into the HTML file. This way it works in every browser. If you have a better idea, i would love to hear!

Further I just want to say, that I am absolutly in time about porting the GLBasic Compiler to the web! Some little problems (except the rewrite of the IO system) but I think I am able to fix them soon!

Changelog since last update:

Fixed: Repeat - Until now works properly
Fixed: Reference parameters (BYREF) are more robust (THAT was long bug hunting...)
Fixed: REDIM/DIMPUSH speed increased
Fixed: int/float casting handles "1" and "0" correctly
Fixed: >,<,<=,>=,and,or,=,<> was not converted from boolean to integer
Fixed: Recursion in combination with FOREACH had really strange behaviour
Fixed: Negate operator (-) had wrong operator priority

Added: Support for hex values
Added: GETFILELIST
Added: REVINSTR
Added: MOD
Added: READUBYTE

#65
I just want to say, that i'm  still working on GLBScript. But development is far slower than before. Currently I am porting the 2D engine of GLBasic to HTML5 and fixing tons of bugs.
I am trying, as already mentioned, to bootstrap the compiler to HTML5. The lexer and code analyser is already working properly, but the parser and code generator still crashes. I think in around two months we will have a GLBasic compiler running in every webbrowser!

Fixed bugs:
- TRIM/LTRIM/RTRIM: Now working properly
- REPLACE: Empty strings do not crash the script
- FOREACH: Now working with by ref variables (ALIAS/BYREF)
- DIMPUSH now working with ALIAS/BYREF
- Negative indices in arrays (array[-1]) works.
- Array bound checks are now performed.
- Some speed improvements.

But there is still a lot of work left...
#66
Alles Gute!
#67
hey!

yeah, I'm currently bootstrapping the compiler. That means, the compiler is compiling its own source code. After this process the compiler is running nativly in browsers. The problem is, there is still a lot work left (basically it is compiling, but the generated code is not executed properly)

But well, things I've done since last posting:
* DELETE
* GETTIMERALL
* DIMDEL
* BOUNDS
* INTEGER
* REPLACE
* TRIM
* ASC
* CHR
* fixed tons of bugs
* compiling multiple source files
* ...

Problems i've discovered while bootstrapping:
* i% = 100/i# = 100 does not work (%, # throws an error)
* line numbering is not working properly
* Codefolding modifies the source code in a strange way

#68
Hi!

Last days I was working on a simple XML reader (to open .gbap files), which works like the DOM model (so I don't have to store the whole xml in memory => very short code, it uses an event system using PROTOTYPE)
Then I tried to get this reader working with GLBasicScript, and now it works really fine! To do that I had to fix tons of compiler bugs, then I had to port some of the file functions of GLBasic (which also works fine now, I'm using xmlhttprequest2, so it works quite nice!). And finally had to fix some compiler bugs again!

New functions:
* MID
* LEFT
* RIGHT
* OPENFILE (not finished, it's only possible to read files)
* ENDOFFILE
* READLINE
* CLOSEFILE
* INC
* DEC
* DIMPUSH
* LEN
* GENFILE

This is the GLBasic code:
Code (glbasic) Select
// --------------------------------- //
// Project: GLBScript
// Start: Monday, November 14, 2011
// IDE Version: 10.159



FUNCTION MyEvent: Name$, Attributes[] AS xmlAttribute
STDOUT "Node: "+Name$+"\n"
FOREACH Att IN Attributes[]
STDOUT "\t"+Att.Name$+": '"+Att.Value$+"'\n"
NEXT
ENDFUNCTION

LOCAL xml AS XML
xml.ReadXML(LoadFile$("Media/GLBScript2.gbap"), MyEvent)


FUNCTION LoadFile$: Path$
LOCAL Text$
LOCAL File% = GENFILE()
IF OPENFILE(File,Path$,1)
WHILE ENDOFFILE(File)=FALSE
LOCAL Line$
READLINE File,Line$
Text$=Text$+Line$+"\n"
WEND
CLOSEFILE File
ELSE
STDOUT "Cannot find file: " + Path$ + "\n"
ENDIF

RETURN Text$
ENDFUNCTION

TYPE xmlAttribute
Name$
Value$
ENDTYPE

PROTOTYPE XMLEvent: Name$, Attributes[] AS xmlAttribute

TYPE XML
Text$; Event AS XMLEvent; Position%; DontCall% = FALSE

FUNCTION ReadXML: Text$, event AS XMLEvent
STDOUT "Parse XML: \n" + Text$

self.Event = event
self.Text$ = Text$
self.Position = 0

self.OverjumpWhitespaces()
//überspringe <? >
IF LEFT$(self.Text$, 2) = "<?"
WHILE self.Get$() <> ">"
INC self.Position
WEND
INC self.Position
ENDIF
self.OverjumpWhitespaces()

TRY
ParseNode()
CATCH Err$
STDOUT Err$
KEYWAIT
FINALLY
ENDFUNCTION

FUNCTION ParseLayer:
self.OverjumpWhitespaces()

WHILE self.Get$() = "<"
// ist es /?
LOCAL HasSlash% = FALSE
INC self.Position
self.OverjumpWhitespaces()
IF self.Get$() = "/"
HasSlash = TRUE
ENDIF
WHILE self.Get$() <> "<"
DEC self.Position
WEND
IF HasSlash THEN RETURN 0
self.ParseNode()
WEND

RETURN 1
ENDFUNCTION

FUNCTION ParseNode:
IF self.Get$() <> "<" THEN THROW "XML Error - Expecting '<'"
INC self.Position
self.OverjumpWhitespaces()

LOCAL Name$ = ParseIdentifier$()
LOCAL Attributes[] AS xmlAttribute

//Attribute holen
IF self.Get$() = " "
self.OverjumpWhitespaces()
WHILE self.Get$() <> "/" AND self.Get$() <> ">"
self.OverjumpWhitespaces()
LOCAL Att AS xmlAttribute

Att.Name$ = self.ParseIdentifier$()
self.OverjumpWhitespaces()

IF self.Get$() <> "=" THEN THROW "XML Error - Expecting '='"
INC self.Position

self.OverjumpWhitespaces()

IF self.Get$() <> "\"" THEN THROW "XML Error - Expecting '\"'"

INC self.Position
LOCAL Pos% = self.Position
WHILE self.Get$() <> "\""
INC self.Position
WEND
INC self.Position
Att.Value$ = MID$(self.Text$, Pos, self.Position - Pos - 1)
self.OverjumpWhitespaces()

DIMPUSH Attributes[], Att
WEND
ENDIF


self.Event(Name$, Attributes[]) //führe event aus

SELECT self.Get$()
CASE ">"
INC self.Position
self.OverjumpWhitespaces()

IF ParseLayer() THEN THROW "XML Error - Unexpected End of File, expecting </"+Name$+">"


self.OverjumpWhitespaces()
IF self.Get$() <> "<" THEN THROW "XML Error - Expecting '<'"
INC self.Position
self.OverjumpWhitespaces()
IF self.Get$() <> "/" THEN THROW "XML Error - Expecting '/'"
INC self.Position

IF Name$ <> self.ParseIdentifier$() THEN THROW "XML Error - Nodes do not match"
IF self.Get$() <> ">" THEN THROW "XML Error Expecting '>'"

INC self.Position
self.OverjumpWhitespaces()
CASE "/"
INC self.Position
IF self.Get$() <> ">" THEN THROW "XML Error - Expecting '>'"
INC self.Position
self.OverjumpWhitespaces()
DEFAULT
THROW "XML Error"
ENDSELECT
ENDFUNCTION

FUNCTION ParseIdentifier$:
LOCAL Pos% = self.Position
WHILE self.Get$() <> " " AND self.Get$() <> "/" AND self.Get$() <> ">" AND self.Get$() <> "="
INC self.Position
WEND
IF self.Position >= LEN(self.Text$) THEN THROW "XML Error"
RETURN MID$(self.Text$, Pos, self.Position - Pos)
ENDFUNCTION

FUNCTION Get$:
IF self.Position >= LEN(self.Text$)
THROW "XML Error - Unexpected End Of File"
ELSE
//DEBUG MID$(self.Text$, self.Position, 1)
RETURN MID$(self.Text$, self.Position, 1)
ENDIF
ENDFUNCTION

FUNCTION OverjumpWhitespaces:
WHILE self.Position < LEN(self.Text$) AND (self.Get$() = " " OR self.Get$() = "\n" OR self.Get$() = CHR$(13))
INC self.Position
WEND
ENDFUNCTION
ENDTYPE


Live Demo
#69
Hey!

New Features: FOREACH, Preprocessor and some kind of optimazation.

* FOREACH: Works as expected. I don't use javascript's foreach, because i don't know exactly its behaviour. At the moment FOREACH is a simple for with some assignments.

* Preprocessor: Wasn't too difficult to implement. The only command which was not as easy as expected was "?IF", but with little modification of the expression parser it ran perfectly.

* Optimization: Hardcoded terms like "1 + 1" are now replaced by "2". Not much but I think it was worth it.

Code like
Code (glbasic) Select
GLOBAL Players$[]

DIM Players$[2]
Players$[0] = "Player1"
Players$[1] = "Player2"
FOREACH P$ IN Players$
STDOUT "Hallo: "+P$
NEXT

STDOUT 100*9-8*(4-10/2)

?IF GLB_VERSION > 0
STDOUT "Oha nice GLB version!"
?ENDIF

?IF 100*5 > 10 AND 4-9 = -5
STDOUT "nice expression dude"
?ENDIF

?IFNDEF HTML5
//Compatibility!
GOSUB GLB_ON_INIT
WHILE TRUE
GOSUB GLB_ON_LOOP
WEND
?ENDIF

Gets now compiled into:
Code (glbasic) Select

//init globals, default value!!
var global11_Players_Str = GLBArray();
function main(){
   //line: 3
   DIM(global11_Players_Str, [2], [""]);
   //line: 4
   global11_Players_Str.values[0] = "Player1";
   //line: 5
   global11_Players_Str.values[1] = "Player2";
   //line: 8
   var forEachSaver1 = global11_Players_Str;
   for(forEachCounter1 = 0 ; forEachCounter1 < forEachSaver1.values.length; forEachCounter1++) {
      local5_P_Str = forEachSaver1.values[forEachCounter1];
      {
         //line: 7
         STDOUT("Hallo: " + local5_P_Str);
         
      }
      forEachSaver1.values[forEachCounter1] = local5_P_Str;
     
   };
   //line: 9
   STDOUT(CAST2STRING(908));
   //line: 10
   STDOUT("Oha nice GLB version!");
   //line: 11
   STDOUT("nice expression dude");
   
}
// set default statics:


#70
hey!

this weekend i got some freetime and of course i spent my time for GLBScript.

But what happened?
I implemented some new functions in HTML5:
* CREATESCREEN
* USESCREEN
* SHOWSCREEN now uses double buffering (slighly slower, but that's okay)
* GETSCREENSIZE
* GETDESKTOPSIZE
* GETSPRITESIZE
* BOXCOLL
* RND
* PRINT (does not use the GLB font system, yet)
* KEY (does not use hardware scancodes, yet)

I also programmed a simple Pong game in GLBS, and it works great! There were a few bugs, but i fixed them all. The source code:
Code (glbasic) Select
TYPE TPlayer
X;Y
VX
KLeft%; KRight%
Score%
FUNCTION Update:
LOCAL W, H
GETSCREENSIZE W, H
IF KEY(self.KLeft)
self.VX = self.VX - 2
ENDIF
IF KEY(self.KRight)
self.VX = self.VX + 2
ENDIF
SELECT self.VX
CASE >6
self.VX = 6
CASE <-6
self.VX = -6
ENDSELECT
SELECT self.X
CASE >W-100
self.X = W-100
CASE <0
self.X = 0
ENDSELECT
self.VX = self.VX*0.9


self.X = self.X + self.VX
ENDFUNCTION

FUNCTION Render:
DRAWRECT self.X, self.Y, 100,40, RGB(255,0,0)
ENDFUNCTION

FUNCTION Init: X, Y, KLeft, KRight
self.X = X
self.Y = Y
self.VX = 0
self.KLeft = KLeft
self.KRight = KRight
ENDFUNCTION
ENDTYPE

TYPE TBall
X;Y;VX;VY

FUNCTION Update:
LOCAL W, H
GETSCREENSIZE W, H
LOCAL OldX = self.X, OldY = self.Y

self.Y = self.Y + self.VY
IF self.AnyCollision()
self.VY = -self.VY
self.Y = OldY + self.VY
ENDIF
self.X = self.X + self.VX
IF self.AnyCollision()
self.VX = -self.VX
self.X = OldX + self.VX
ENDIF
IF self.X < 0 OR self.X > W - 20 THEN self.VX = -self.VX


IF self.Y < -20
self.Reset
Player1.Score = Player1.Score + 1
ENDIF
IF self.Y > H
self.Reset
Player2.Score = Player2.Score + 1
ENDIF

ENDFUNCTION

FUNCTION Render:
DRAWRECT self.X, self.Y, 20,20, RGB(0,255,0)
ENDFUNCTION

FUNCTION Init: X, Y, VX, VY
self.X = X
self.Y = Y
self.VX = VX
self.VY = VY
ENDFUNCTION

FUNCTION Reset:
LOCAL W, H
GETSCREENSIZE W, H
Ball.Init W/2 - 10, H/2 - 10, (RND(8) - 4)*2, (RND(8) - 4)*2
ENDFUNCTION

FUNCTION AnyCollision%:
IF BOXCOLL(self.X, self.Y, 20, 20, Player1.X, Player1.Y, 100, 40) OR BOXCOLL(self.X, self.Y, 20, 20, Player2.X, Player2.Y, 100, 40)
RETURN TRUE
ELSE
RETURN FALSE
ENDIF
ENDFUNCTION
ENDTYPE

GLOBAL Player1 AS TPlayer
GLOBAL Player2 AS TPlayer
GLOBAL Ball AS TBall

SUB GLB_ON_INIT:
LOCAL W, H
GETSCREENSIZE W, H

Player1.Init 10,10, 37,39 //left arrow, right arrow, there are no scancodes like in GLB :/
Player2.Init 10,H-50, 65, 68 //a, d
Ball.Reset
ENDSUB

SUB GLB_ON_LOOP:

Player1.Update
Player2.Update
Ball.Update

Player1.Render
Player2.Render
Ball.Render

PRINT "Score: "+Player1.Score+" : "+Player2.Score, 10, 10

SHOWSCREEN
ENDSUB

Live example
#71
sorry, since school started, i was not able to continue work on GLBS. I will continue work as soon as possible :)

#72
Hoi!

Da nun wieder Schule begann, komme ich kaum mehr daran an GLBScript weiterzuarbeiten.

* GOTO: Daran habe ich mir die Zähne ausgebissen. Dieses funktioniert zwar _grundsätzlich_ hat aber arge Probleme mit Verschachtelten Schleifen und so, deswegen ist es vorerst deaktiviert. Nebenbei ist sobald EIN goto verwendet wird im Code, der GESAMTE Code langsamer. Das muss leider sein, da der gesamte Code nachher mit einem ProgramCounter verwaltet wird und nachher mit dem über iteriert wird.

* 2D Library: Ja, erste Ergebnisse kann ich hier auch schon vorweisen! Einfache Funktionen sind bereits implementiert. Folgender Code wird perfekt ausgeführt und kompiliert:


Bereits umgesetzte Befehle:
* SHOWSCREEN
* DRAWLINE
* DRAWRECT
* DRAWSPRITE
* ROTOSPRITE
* ZOOMSPRITE
* STRETCHSPRITE
* ROTOZOOMSPRITE
* CLEARSCREEN
* BLACKSCREEN
* RGB
* SYSTEMPOINTER
* MOUSESTATE
* LOADSPRITE

MfG
#73
Off Topic / Re: HTML5
2011-Sep-02
Okay:
Milestone 1: Get Syntax working (done)
Milestone 2: Get 2D functions working (DRAWSPRITE/ROTOSPRITE/... already works)
Milestone 3: Get Input functions working
Milestone 4: Get Sound working
Milestone 5: Get Data IO working (that's difficult to do)
Milestone 6: Get X_ commands working

#74
Off Topic / Re: HTML5
2011-Sep-02
Yes!

I'm working on a complete rewrite of the GLBasic compiler, which produces fast and lightweight HTML5 code. The compiler itself is fully working and does a great job so far.

At the moment I'm porting the whole GLBasic engine to HTML5.

Port GLBasic applications to HTML5 is not as easy as the other platforms, because there is no mainloop (as Kitty said). You have to do all the job in the SUBs "GLB_ON_INIT" and "GLB_ON_LOOP". Networking will not be supported and GOTO also (JavaScript does not offer a keyword like this).

More informations (in german ;( ): http://www.glbasic.com/forum/index.php?topic=4524.msg53624#msg53624
#75
Ja, so ein Programm wäre nützlich (evtl auch für dich zum debuggen ob die neuen GLB Versionen mit den alten Kompatibel sind)

Auf die schnelle konnte ich folgendes zum schreiben in Dateien finden: http://dev.w3.org/2006/webapi/FileAPI/ ob das wirklich ausreichend ist weiß ich nicht.