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

Pages: [1]
1
GLBasic - en / fractional part of a float
« on: 2012-Mar-29 »
Is this the proper way to get the fractional part of a floating point number in GLBasic or is there already a function to do this which might be faster?

frac_x = x - INTEGER(x)

 :-[

2
GLBasic - en / preprocessor command help
« on: 2012-Mar-14 »
Code: (glbasic) [Select]
?DEFINE compile_mode_testing TRUE

?IF compile_mode_testing = FALSE

player_lives = 3

?ELSE

player_lives = 99

?ENDIF

Please help.  My attempt at using preprocessor commands is giving me this precompiling error, "syntax error : ... true)=false".  What is the correct way to do this?

3
Thanks.  I also found that the 349 KB png is identical to the 349 KB bmp file, so I used FSViewer to save the bmp as a png which was only 17 KB.

4
When I used the Font Creator the created bitmap image has a background which is not all purple but has a black vertical stripe 8 pixels wide on the right side.

Thanks for any help.

Best wishes, Ralph.


[attachment deleted by admin]

5
GLBasic - en / X_LINE needed with 2 colours
« on: 2011-Oct-10 »
I need a function like X_LINE but with 2 colours so that the colour varies from  point 1 to point 2.  Thanx.

6
Bug Reports / Re: SAVESPRITE bug
« on: 2011-Oct-07 »
A png image using the transparent alpha of 0 instead of a transparent pink colour saves fine.

7
Bug Reports / SAVESPRITE bug
« on: 2011-Oct-06 »
LOADSPRITE "sprite_original.bmp", 100
SAVESPRITE "sprite_saved.bmp", 100

any pixel with an rgb of 255, 0,128 is saved as 128,0,255

9
I never noticed the slow down when I began to make games a few months ago using GLBasic because each game was simple and was run only a few minutes at a time each day.  This problem has been happening for a couple months and how long it takes before I need to reboot depends on how many times I close the game and make another change in the code and then do a recompile and run.  If I never start the GLBasic IDE but merely run the game which had been compiled earlier then it might take longer such as 45 minutes.  The more a game does between each SHOWSCREEN call, such as press the keys more, seems to be a factor which causes the intervals to get crazy.  The strange thing is that nothing else in the system is effected such as watching a movie while playing music and copying files to an external drive, but as soon as ANY GLBasic game which I have made is run the problem is seen exactly at the same level of effect as it was doing previously and continues to get worse the more that game is running.  It doesn't make a difference how much time passes between runs.  I can only make a wild guess as to what is happening but it seems there is some kind of system hook used for something by GLBasic which stays hooked so at the next run of any GLBasic program calling SHOWSCREEN the problem continues.

10
Bug Reports / bug - SHOWSCREEN & GETTIMERALL
« on: 2011-Jan-10 »
Running with Windows XP
SHOWSCREEN becomes increasingly less smooth as a program runs and
when a GLBasic program is run again the problem continues with the
same degraded display intervals which were occurring at the last run.
So over time a program is unplayable and the only solution is to reboot.
When running this test program I discovered that GETTIMERALL will
eventually report *** negative *** time between frames!!!

[attachment deleted by admin]

11
The posted code would not compile.
Does someone know if this attempt to fix line 142 is the proper code?

Code: (glbasic) [Select]
// --------------------------------- //
// Project: maze_gen_1
// Start: Tuesday, December 07, 2010
// IDE Version: 8.174


//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//
//                                                                      //
// Project: Random Maze Generator Function for GLBasic                  //
//                                                                      //
// (C)opyright PeeJay December 13th 2007      www.peejays-remakes.co.uk //
//              bugfix January 21st 2008                                //
//                                                                      //
// Code is free to use for FREEWARE projects only, though credit would  //
// still be welcomed if you decide to use it                            //
//                                                                      //
// Please contact me through my website for conditions on using this    //
// code in shareware, commercial, or other revenue generating projects  //
//                                                                      //
// This function will randomly generate a 2D map of practically any     //
// size very quickly, storing the result in an array for ease of use    //
//                                                                      //
// I have used this code in DarkBasic, BlitzBasic, and now I offer it   //
// to the GLBasic community. For the first time, I have reduced the     //
// code to fit in one function for maximum simplicity                   //
//                                                                      //
// Not surprisingly, the code is fairly complex - even more so by the   //
// fact I've not added comments! However, it is a self contained,       //
// robust, standalone function, so anyone should be able to use it      //
// without needing to understand the methodology behind it              //
//                                                                      //
// The code will produce either an exact maze, or one that is more      //
// open. An exact maze is defined as one where there is only one route  //
// from any point in the maze to any other point in the maze            //
//                                                                      //
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//

GLOBAL maze[]
GLOBAL pjcos[]
GLOBAL pjsin[]
DIM maze[0][0]
DIM pjcos[4]
DIM pjsin[4]

LOCAL loop,loop1,time1,time2

WHILE TRUE

   REDIM maze[0][0];REDIM maze[79][59]   // Reset maze

   time1=GETTIMERALL()
   MakeMaze(maze[],1) // Maze (maze[] must be DIMed), exact=1, not exact=0
   time2=GETTIMERALL()

   FOR loop=0 TO 78
      FOR loop1=0 TO 58
         IF maze[loop][loop1]=1
            DRAWRECT 4+(loop*8),4+(loop1*8),8,8,RGB(164,104,10)
            DRAWRECT 5+(loop*8),5+(loop1*8),6,6,RGB(196,148,10)
         ENDIF
      NEXT
   NEXT

   PRINT "Maze Generated in "+INTEGER(time2-time1)+" milliseconds",180,220

   SHOWSCREEN

   KEYWAIT
WEND
 
END

// -------------------------------------------------------------------- //

FUNCTION MakeMaze: pjmaze[], pjexact

   LOCAL pjmx = BOUNDS(pjmaze[],0)-1
   LOCAL pjmy = BOUNDS(pjmaze[],1)-1
   LOCAL pjfx,pjfy,pjloop,pjypos,pjxpos,pjfarx,pjfary,pjallx,pjally,pjalldir
   LOCAL pjgo,pjtemp,pjx,pjy,pjdir,pjresult,pjlop,pjx2,pjy2,pjtemp2

   pjcos[0]=1
   pjcos[2]=-1
   pjsin[1]=1
   pjsin[3]=-1

   FOR pjfx=0 TO pjmx
      pjmaze[pjfx][0]=1
      pjmaze[pjfx][pjmy]=1
   NEXT

   FOR pjfy=0 TO pjmy
      pjmaze[0][pjfy]=1
      pjmaze[pjmx][pjfy]=1
   NEXT
   
   FOR pjloop=1 TO pjmy/6
      pjypos=RND((pjmy-6)/2)*2
      pjxpos=RND(2)*2
      FOR pjfx=1 TO pjxpos
         pjmaze[pjfx][pjypos]=1
      NEXT
      pjypos=RND((pjmy-6)/2)*2
      pjxpos=pjmx-(RND(2)*2)
      FOR pjfx=pjmx TO pjxpos STEP -1
         pjmaze[pjfx][pjypos]=1
      NEXT
   NEXT
   FOR pjloop=1 TO pjmx/6
      pjxpos=4+RND((pjmx-8)/2)*2
      pjmaze[pjxpos][pjmy-1]=1
      pjmaze[pjxpos][pjmy-2]=1
   NEXT
   
   pjfarx=pjmx
   pjfary=pjmy
   pjallx=0
   pjally=0
   pjexact=pjexact+1

   WHILE TRUE
      WHILE TRUE

         pjallx=pjallx+pjcos[pjalldir]*pjexact
         pjally=pjally+pjsin[pjalldir]*pjexact
         pjgo=pjgo+pjexact

         IF pjgo>=pjfarx-pjexact AND (pjalldir=0 OR pjalldir=2)
            pjgo=0
            pjfarx=pjfarx-pjexact
            pjtemp=pjalldir+1
            pjalldir=pjtemp-4*(pjtemp>3)+4*(pjtemp<0)
         ENDIF
         IF pjgo>=pjfary-pjexact AND (pjalldir=1 OR pjalldir=3)
            pjgo=0
            pjfary=pjfary-pjexact
            pjtemp=pjalldir+1
            pjalldir=pjtemp-4*(pjtemp>3)+4*(pjtemp<0)
         ENDIF

         IF pjfarx<=0 OR pjfary<=0 THEN BREAK
         IF pjmaze[pjallx][pjally]=1 AND (pjallx>=pjfarx) THEN BREAK // ??

      WEND
     
      IF pjfarx<=0 OR pjfary<=0 THEN BREAK
      IF pjallx>=pjmx OR pjally>=pjmy THEN BREAK

      pjx=pjallx
      pjy=pjally
      pjdir=RND(3)

      WHILE TRUE

         FOR pjloop=0 TO 3
            pjresult=1
            FOR pjlop=1 TO pjexact+1
               pjx2=pjx+pjcos[pjloop]*pjlop
               pjy2=pjy+pjsin[pjloop]*pjlop
               IF pjx2<=0 OR pjy2<=0 OR pjx2>pjmx OR pjy2>pjmy THEN pjresult=0
               IF pjresult=1
                  IF pjmaze[pjx2][pjy2]=1 THEN pjresult=0
               ENDIF
               IF pjresult=1
                  pjtemp=pjloop+1
                  pjtemp2=pjtemp-4*(pjtemp>3)+4*(pjtemp<0)
                  IF pjmaze[pjx2+pjcos[pjtemp2]][pjy2+pjsin[pjtemp2]]=1 THEN pjresult=0
               ENDIF
               IF pjresult=1
                  pjtemp=pjloop-1
                  pjtemp2=pjtemp-4*(pjtemp>3)+4*(pjtemp<0)
                  IF pjmaze[pjx2+pjcos[pjtemp2]][pjy2+pjsin[pjtemp2]]=1 THEN pjresult=0
               ENDIF
            NEXT
            IF pjresult=1 THEN BREAK
         NEXT

         IF pjloop=4 THEN BREAK

         pjtemp=pjdir+1-RND(2)
         pjdir=pjtemp-4*(pjtemp>3)+4*(pjtemp<0)

         pjresult=1
         FOR pjlop=1 TO pjexact+1
            pjx2=pjx+pjcos[pjdir]*pjlop
            pjy2=pjy+pjsin[pjdir]*pjlop
            IF pjx2<=0 OR pjy2<=0 OR pjx2>pjmx OR pjy2>pjmy THEN pjresult=0
            IF pjresult=1
               IF pjmaze[pjx2][pjy2]=1 THEN pjresult=0
            ENDIF
            IF pjresult=1
               pjtemp=pjdir+1
               pjtemp2=pjtemp-4*(pjtemp>3)+4*(pjtemp<0)
               IF pjmaze[pjx2+pjcos[pjtemp2]][pjy2+pjsin[pjtemp2]]=1 THEN pjresult=0
            ENDIF
            IF pjresult=1
               pjtemp=pjdir-1
               pjtemp2=pjtemp-4*(pjtemp>3)+4*(pjtemp<0)
               IF pjmaze[pjx2+pjcos[pjtemp2]][pjy2+pjsin[pjtemp2]]=1 THEN pjresult=0
            ENDIF
         NEXT

         IF pjresult=1
            FOR pjloop=1 TO pjexact
               pjx=pjx+pjcos[pjdir]
               pjy=pjy+pjsin[pjdir]
               pjmaze[pjx][pjy]=1
            NEXT
         ENDIF
      WEND
   WEND

   IF pjexact=2
      FOR pjfx=2 TO pjmx-2 STEP 2
         IF pjmaze[pjfx][2]=0
            pjmaze[pjfx][2]=1 ; pjmaze[pjfx][1]=1
         ENDIF
         IF pjmaze[pjfx][pjmy-2]=0
            pjmaze[pjfx][pjmy-2]=1 ; pjmaze[pjfx][pjmy-1]=1
         ENDIF
      NEXT
      FOR pjfy=2 TO pjmy-2 STEP 2
         IF pjmaze[2][pjfy]=0
            pjmaze[2][pjfy]=1 ; pjmaze[1][pjfy]=1
         ENDIF
         IF pjmaze[pjmx-2][pjfy]=0
            pjmaze[pjmx-2][pjfy]=1 ; pjmaze[pjmx-1][pjfy]=1
         ENDIF
      NEXT
   ENDIF

ENDFUNCTION

Pages: [1]