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

#21
Off Topic / Had to laugh
2012-Nov-23
You have just got to chuckle sometimes at the naivety & innocence of non techie people.

Having just bought a 4gb DDR3 stick for my laptop for a not bad price of £10 my partner came out with the following (& I quote)
QuoteYou paid £10 for 4gb, I payed £9 for a 32gb USB thingy last week & you're meant to be the computer expert

Needless to say that all attempts to explain there are different types of memory fell on deaf ears lol.

Lee

Sent from my GT-I5700 using Tapatalk 2
#22
Done more as a exercise than anything else  :D

I get 29fps @ 640x480 which is higher than I expected on my core 2 duo 2.13ghz & crappy gfx card, considering the amount of array modifying & MEM2SPRITE calls. There is probably a far better way of doing it but this is the only way that has popped into my head at the moment.

Do not change the MAX_ITERATION% variable as I have not got round to scaling the fractal data to a 0-255 colour range as yet. Also the MinY & MaxY coords are reversed when they are read into the type due to the image was flipped compared to winfracts output, so I assume winfract treats Y=0 as the bottom of the window & not top.

keys are as follows (although are commented in the code)

F1 = Start colour cycling
F2 = Stop colour cycling
F3 = Previous Fractal point (4 available)
F4 = Next Fractal point (4 available)
Cursor Up = cycle colours up
Cursor Down = cycle colours down
Cursor Left = previous palette
Cursor Right = next palette
Spacebar = Reload the pallette back to defaults (after cycling)

Have fun

Lee

Code (glbasic) Select

TYPE Tpalette
red%[256]
green%[256]
blue%[256]
memcolour[256] // MEM2SPRITE friendly values :)
total%
name$

FUNCTION cycle_memcolours: dir

LOCAL loop%,temp%

SELECT dir

CASE 1

temp%=self.memcolour%[0]
FOR loop = 1 TO 255
self.memcolour%[loop%-1]=self.memcolour%[loop%]
NEXT
self.memcolour%[255]=temp

CASE 0

temp%=self.memcolour%[255]
FOR loop = 255 TO 1 STEP -1
self.memcolour%[loop%]=self.memcolour%[loop%-1]
NEXT
self.memcolour%[0]=temp
ENDSELECT

ENDFUNCTION

ENDTYPE

TYPE Tfrac_coords
MinX#
MaxX#
MinY#
MaxY#
ENDTYPE

CONSTANT up_cursor%=200
CONSTANT down_cursor%=208
CONSTANT left_cursor%=203
CONSTANT right_cursor%=205
CONSTANT F1%=59
CONSTANT F2%=60
CONSTANT F3%=61
CONSTANT F4%=62
CONSTANT SPC%=57

GLOBAL palette[] AS Tpalette
GLOBAL frac_coords[] AS Tfrac_coords
GLOBAL Width%=640,Height%=480
GLOBAL screencolours%[]
GLOBAL screen%[]
GLOBAL currpal%=0
GLOBAL fracount%

LOCAL starttime,endtime,totaltime,fx%,fy%
LOCAL cyclestate%=0,cycledir%=0,curfract%=0

DIM screencolours%[Width%*Height%]
DIM screen%[Width%*Height%]

SETSCREEN Width%,Height%,0
SETCURRENTDIR("Media") // go to media files
LOADFONT "font.png",0
GETFONTSIZE fx%,fy%

loadpalette("palettedata.dat")
readfractcoords()
//draw initial set

calc_mandel(frac_coords[curfract%].MinX#,frac_coords[curfract%].MaxX#,frac_coords[curfract%].MinY#,frac_coords[curfract%].MaxY#)


WHILE NOT KEY(1)

starttime=GETTIMERALL()

IF KEY(up_cursor) THEN cycledir%=1 // UP cursor = cycle colours up
IF KEY(down_cursor) THEN cycledir%=0 // Down cursor = cycle colours down

IF KEY(right_cursor) AND currpal%<palette[0].total%-1 // Right cursor = next palette
INC currpal%,1
refresh_sprite()
SLEEP 200
ENDIF

IF KEY(left_cursor) AND currpal%>0 // Left cursor = previous palette
DEC currpal%,1
refresh_sprite()
SLEEP 200
ENDIF

IF KEY(F1) THEN cyclestate%=1 // F1 = Start Cycle colours
IF KEY(F2) THEN cyclestate%=0 // F2 = Stop Cycle colours

IF KEY(F3) AND curfract%>0 // F3 = Previous fractal
DEC curfract%,1
calc_mandel(frac_coords[curfract%].MinX#,frac_coords[curfract%].MaxX#,frac_coords[curfract%].MinY#,frac_coords[curfract%].MaxY#)
ENDIF

IF KEY(F4) AND curfract%<fracount%-1 // F4 = Next fractal
INC curfract%,1
calc_mandel(frac_coords[curfract%].MinX#,frac_coords[curfract%].MaxX#,frac_coords[curfract%].MinY#,frac_coords[curfract%].MaxY#)
ENDIF

IF KEY(SPC)        // Press space to reload default palette
loadpalette("palettedata.dat")
refresh_sprite()
ENDIF

IF cyclestate%=1
palette[currpal%].cycle_memcolours(cycledir%)
refresh_sprite()
ENDIF

DRAWSPRITE 10,0,0
totaltime=1000/(GETTIMERALL()-starttime)
PRINT "FPS="+INTEGER(totaltime),0,0,1
PRINT "Current palette="+currpal%,0,fx%,1
PRINT "Palette Name="+palette[currpal%].name$,0,fx%*2,1

SHOWSCREEN

WEND

KEYWAIT

FUNCTION calc_mandel: MinX#,MaxX#,MinY#,MaxY#

LOCAL dx#,dy#,x%,y%

dx=(MaxX-MinX)/Width%
dy=(MaxY-MinY)/Height%

FOR y=0 TO Height%-1

FOR x=0 TO Width%-1
screencolours%[x+(y*Width%)]=calc_pixel(MinX+x*dx,MinY+y*dy)
screen%[x+(y*Width%)]=palette%[currpal%].memcolour[screencolours%[x+(y*Width%)]]
NEXT

NEXT

MEM2SPRITE(screen%[],10,Width%,Height%)

ENDFUNCTION

FUNCTION calc_pixel: CA#,CBi#

LOCAL MAX_ITERATION%=255
LOCAL OLD_A#
LOCAL ITERATION%
LOCAL A#,Bi#
LOCAL LENGTH_Z#

A=0
Bi=0

ITERATION=0

REPEAT

OLD_A=A

A=A*A-Bi*Bi+CA
Bi=2*OLD_A*Bi+CBi

LENGTH_Z=A*A+Bi*Bi

IF ITERATION > MAX_ITERATION THEN RETURN MAX_ITERATION
INC ITERATION
UNTIL LENGTH_Z > 4

RETURN ITERATION-1

ENDFUNCTION

FUNCTION refresh_sprite:

LOCAL x%,y%

FOR y=0 TO Height%-1
FOR x=0 TO Width%-1
screen%[x+(y*Width%)]=palette%[currpal%].memcolour[screencolours%[x+(y*Width%)]]
NEXT
NEXT
MEM2SPRITE(screen%[],10,Width%,Height%)
ENDFUNCTION

FUNCTION loadpalette: filename$

LOCAL palcount%,namesize%,palname$,r%,g%,b%,pal_loop%,col_loop%

OPENFILE (1,filename$,TRUE)
READUBYTE 1,palcount
DIM palette[palcount]

palette[0].total%=palcount

FOR pal_loop=0 TO palcount-1

READUBYTE 1,namesize
READSTR 1,palname$,namesize
palette[pal_loop].name$=palname$

FOR col_loop=0 TO 255
READUBYTE 1,r%
palette[pal_loop].red%[col_loop]=r
READUBYTE 1,g%
palette[pal_loop].green%[col_loop]=g
READUBYTE 1,b%
palette[pal_loop].blue%[col_loop]=b
palette[pal_loop].memcolour[col_loop]=RGB(r,g,b)+INTEGER(0xff000000)
NEXT

NEXT

CLOSEFILE 1

ENDFUNCTION

FUNCTION drawpalette: id%

LOCAL x%,y%,r%,g%,b%,cur_colour%

PRINT palette[id].name$,0,10

FOR y=0 TO 15
FOR x=0 TO 15
r=palette[id].red%[cur_colour%]
g=palette[id].green%[cur_colour%]
b=palette[id].blue%[cur_colour%]

DRAWRECT x*16,(y*16)+20,15,15,RGB(r,g,b)

INC cur_colour%,1
NEXT
NEXT

ENDFUNCTION

FUNCTION readfractcoords:

LOCAL amount%,loop%,value#

RESTORE fracdata
READ amount%
fracount%=amount%
DIM frac_coords[amount%]

FOR loop%=0 TO amount%-1
READ value#
frac_coords[loop%].MinX#=value#
READ value#
frac_coords[loop%].MaxX#=value#
READ value#
frac_coords[loop%].MaxY#=value#
READ value#
frac_coords[loop%].MinY#=value#
DEBUG frac_coords[loop%].MinX#+"\n"
DEBUG frac_coords[loop%].MaxX#+"\n"
DEBUG frac_coords[loop%].MinY#+"\n"
DEBUG frac_coords[loop%].MaxY#+"\n"
NEXT
ENDFUNCTION


STARTDATA fracdata:
DATA 4
DATA -2.500000000000,1.499999660000,-1.499999730000,1.500000000000
DATA -1.611111110000,-0.985133316000,0.194154827000,0.663883090000
DATA -1.204480370000,-1.190686790000,0.309634963000,0.319990810000
DATA -0.655607441000,-0.649605315000,0.492290244000,0.496800002000
ENDDATA



[attachment deleted by admin]
#23
No idea what site the algorithm came from but found it as a text file on my HD, all I do know was it was a very long time ago so I just converted the pseudo code into a GLB function using types & MEM2SPRITE etc.

I made it so it can be used for floodfills on a whole screen or just a sprite & even on my lowly system its very very quick (millsecs rather than seconds  =D )

Lee

Code (glbasic) Select

// --------------------------------- //
// Project: fastfloodfill
// Start: Wednesday, October 31, 2012
// IDE Version: 10.283


// FREE-VERSION:
// Need Premium for Features:
// 3D Graphics
// Network Commands
// INLINE C/C+++ code

SETCURRENTDIR("Media") // go to media files
SETSCREEN 800,600,0
SYSTEMPOINTER TRUE
SEEDRND GETTIMERALL()

TYPE Fillpixel
x%
y%
ENDTYPE

GLOBAL pixels%[]

LOCAL mx%,my%,b1%,b2%,col%,sx%,sy%

GETSCREENSIZE sx,sy

LOADSPRITE "grab.png",0 // Load an image as CBA to write a filled circle function at present to test non-square borders ;)
//GRABSPRITE 0,0,0,sx,sy
REPEAT
MOUSESTATE mx, my, b1, b2
IF MOUSEAXIS(3)
col = RGB(255,255,255)
FillFast(mx,my,sx,sy,col,0)
ENDIF
DRAWSPRITE 0,0,0
SHOWSCREEN
UNTIL KEY(57)
END


FUNCTION FillFast: startx%,starty%,width%,height%,fillcol%,id%

LOCAL i[]  AS Fillpixel
LOCAL newi AS Fillpixel
LOCAL newx%,newy%,dir%
LOCAL fillover%,fillcolour%
LOCAL fillmap%[]
LOCAL red%,green%,blue%,alpha%

IF startx<0 OR starty<0 OR startx>=width% OR starty>=height
DEBUG "Out of area."
RETURN
        ENDIF

SPRITE2MEM (pixels[],id)

// Convert the fill colour to SPRITEMEM format.
fillcolour=bOR(fillcol, ASL(255, 24))

// Get the colour that will be filled over.
red=bAND(pixels[startx+starty*width%], 0xff)
green=bAND(ASR(pixels[startx+starty*width%],8), 0xff)
blue=bAND(ASR(pixels[startx+starty*width%],16), 0xff)
alpha=bAND(ASR(pixels[startx+starty*width%],24), 0xff)
fillover=bOR(RGB(red,green,blue), ASL(alpha, 24))

// If the fill pixel is same colour as then abort.
IF fillover=fillcolour THEN RETURN

// Set the start position.
newi.x=startx
newi.y=starty
pixels[startx+starty*width%]=fillcolour
DIMPUSH i[],newi

// Reset the fill check map.
DIM fillmap[width%][height]
fillmap[startx][starty]=1

FOREACH pixel IN i[]

// New test position based on the direction.
FOR dir=0 TO 3

SELECT dir

CASE 0 // Right
newx=pixel.x+1
newy=pixel.y
CASE 1 // Down
newx=pixel.x
newy=pixel.y+1
CASE 2 // Left
newx=pixel.x-1
newy=pixel.y
CASE 3 // Up
newx=pixel.x
newy=pixel.y-1
ENDSELECT


IF newx>=0 AND newy>=0 AND newx<width% AND newy<height // Make sure the new position is in the boundaries of the screen/sprite.
IF fillmap[newx][newy]=0 // If not already checked continue
fillmap[newx][newy]=1 // Flag this pixel as now checked
IF pixels[newx+newy*width%]=fillover // Check pixel colour is the correct fill over colour.
pixels[newx+newy*width%]=fillcolour // Fill and make a new pixel.
newi.x=newx
newi.y=newy
DIMPUSH i[],newi
ENDIF
ENDIF
ENDIF
NEXT
DELETE pixel // Remove pixel from list
NEXT

MEM2SPRITE (pixels[],id,width%,height)

DIM fillmap[0][0]
ENDFUNCTION
   

[attachment deleted by admin]
#24
Hi all, I am currently writing a simple file requester for a program I'm working on (keyboard controlled at the moment but will progress to graphical at some point) & have hit a stumbling block.
I need to be able to access different drives including optical ones but as yet not found a way to select them other than the root directory of the current drive.

There is 2 reasons why I am not using the inbuilt command. First it's windows only & I will be using the final program on occasion in Linux, second it crashes everytime I call it when in debug mode which is every run so far till the program is complete :-).

Any help/ideas would be great.

Cheers

Lee


Sent from my GT-I5700 using Tapatalk 2
#25
I came across these a few months ago & kept meaning to post them here for others. I basically took them off a 17-Bit PD Amiga disk & converted them to 3DS format so you can load them in Blender/AC3D  etc or the built in DDD converter.

I cannot vouch for the copyright status of these objects other than to say they did come from a PD library. You may find them useful as placeholders until you create your own models & as they came from the Amiga nearly all have a low poly count. I have checked some random ones to see if the conversion was successful & all seemed fine but there may be some which went wrong, couldn't be bothered to check all 180 of them  :D

These are the contents

Code (glbasic) Select

A-Wing.grp.3ds
A1000.scene.silver.3ds
a2000.iob.3ds
A3000-CPU.obj.3ds
A3000-Keyboard.obj.3ds
alien8door.iob.3ds
android.iob.3ds
Antenna.obj.3ds
Apple.iob.3ds
apple2.iob.3ds
archeddoor.iob.3ds
archeddoor2.iob.3ds
AT-AT.3ds
Audio-Old.3ds
aust.3ds
ballon.iob.3ds
Balloon.iob.3ds
banana.iob.3ds
BatWing.iob.3ds
beamdoor.iob.3ds
Bed.3ds
BELL_X-1.silver.3ds
bkacheln.iob.3ds
blockh.iob.3ds
book.iob.3ds
Bookshelf.iob.3ds
bottle.iob.3ds
bottle1.iob.3ds
brickwork.iob.3ds
Building1.3ds
Building2.3ds
BulletinBoard.iob.3ds
Callipers.iob.3ds
Chair.3ds
champagne.iob.3ds
cirarch1.iob.3ds
cirarch2.iob.3ds
cirarch3.iob.3ds
clock.iob.3ds
cobra.iob.3ds
column1.iob.3ds
column2.iob.3ds
column5.iob.3ds
Couch.3ds
cow3.new.3ds
crypt.iob.3ds
cryptship.3ds
CUPBOARD-1.3ds
DALEK.TEX.3ds
dancer.iob.3ds
dart.iob.3ds
Delta Fighter.3ds
desklamp.iob.3ds
diskbox.iob.3ds
diskbox2.iob.3ds
doppeld.iob.3ds
DOS2.3ds
DRESSER.TEX.3ds
drillbit.iob.3ds
DSTAR.3ds
eggcup.iob.3ds
enterprise.iob.3ds
eschersx.iob.3ds
expresso.iob.3ds
f15.iob.3ds
F15e.iob.3ds
fahrrad.iob.3ds
Fan.3ds
Fan.blades.3ds
fishtank.iob.3ds
flower.iob.3ds
fly.obj.3ds
Froggy.scene.silver.3ds
glass1.iob.3ds
glass2.iob.3ds
glass3.iob.3ds
glass4.iob.3ds
glass6.iob.3ds
glasses.iob.3ds
Glass_Bowl.dec.3ds
goblet.iob.3ds
gotharc4.iob.3ds
ground.3ds
Gun.3ds
gun.iob.3ds
hang.iob.3ds
HotAirBalloon.scene.silver.3ds
Hubble_Telescope.3ds
human-object.3ds
Im-A-Wing fighter.3ds
IM-B-Wing fighter.3ds
IM-Tie Fighter.3ds
IM-Tie Interceptor.3ds
ImperialShuttle.grp.3ds
jeep.iob.3ds
joystick.iob.3ds
Lamp.silver.3ds
lamp1.iob.3ds
Laser.3ds
Lightsabre.iob.3ds
light_lamp.3ds
Magic_Marker.3ds
man.iob.3ds
match.iob.3ds
matchbo2.iob.3ds
matchbox.iob.3ds
MECH.3ds
mensch.iob.3ds
Mil-Falcon.obj.3ds
monitor.iob.3ds
Movie_Light.3ds
Movie_Light_Stand.3ds
mushroom.iob.3ds
NCC-1701D.3ds
outlet.iob.3ds
Outlet.obj.3ds
pararch1.iob.3ds
pear.iob.3ds
PHILIPS.TEX.3ds
phone1.iob.3ds
pinwand.iob.3ds
plug.iob.3ds
potplant.iob.3ds
pushpin.iob.3ds
rennboot.iob.3ds
RoboHand.iob.3ds
Scout-Walker.obj.3ds
Scout-Walker.silver.3ds
ScoutWalkerGREY.obj.3ds
sektscha.iob.3ds
shades.iob.3ds
shelarch.iob.3ds
shuttle.iob.3ds
sideboard.TEX.3ds
Snowspeed.iob.3ds
Snowspeeder.grp.3ds
socbal.iob.3ds
SONIC_SCREWDRIVER.TEX.3ds
SOPWITH_CAMEL.silver.3ds
soul-hunter_ship.3ds
sp-book.iob.3ds
Spaceship.total.new.3ds
SpellBook.iob.3ds
spring.iob.3ds
Stapler.silver.3ds
StarTrekInsignia-4.iob.3ds
STLOUIS.silver.3ds
surfbord.iob.3ds
T-16.iob.3ds
T-17SpaceFighter.3ds
tank4.iob.3ds
tank5.iob.3ds
tank6.iob.3ds
tank7.iob.3ds
tank8.iob.3ds
TARDIS.TEX.3ds
TIE-Fighter.obj.3ds
Tie-Fighter.silver.3ds
TIE-Interceptor.obj.3ds
Tie.Interceptor.3ds
Tiefighter3.silver.3ds
tommygun.iob.3ds
tyranid.3ds
Videocam.obj.3ds
violcase.iob.3ds
Vorlon1.3ds
Voyager.iob.3ds
Walker.3ds
Walker.angle.3ds
Walker.iob.3ds
WarBird.3ds
watch.iob.3ds
X-15.silver.3ds
X-Wing.iob.3ds
X-Wing.silver.3ds
X-wingO.obj.3ds
x29.iob.3ds
Y-wing.obj.3ds
Y-Wing.silver.3ds
Zenith_Star_Laser.3ds



Lee

[attachment deleted by admin]
#26
Has anyone in their travels come across any sites with tutorials or even programs for creating Nebula like backdrops. Not to bothered if the tutorials are for programs I do not have as long as the description of how they created it is followable (does the previous word exist lol).

Seems my google skills have gone backwards as cannot seem to find anything semi-decent or get sent to pages that will not load.

Lee
#27
After spending the weekend round my partners I ended up playing with LEGO as she had got her daughter her 1st set (well technically was a load of sets given to her by her cousin who's kid stopped playing with it). Hours of fun ensued as well as many fond memories of my childhood playing with LEGO  =D.

When I got back home I searched the net for LEGO 3D models etc & came across this site http://www.ldraw.org/ which has also wasted quite a few hours playing with it. The download comes with various LEGO orientated tools like a CAD program, viewer etc as well as around 5k of different LEGO brick & parts. One thing you can do is export your model as a 3DS, POVRAY, HTML or Wavefront OBJ file to further spruce up your model or to produce a high quality render of it, something I have yet to do as have been busy trawling through the huge parts list remembering what I used to have  :D.

This example is a POV render from a site linked from the above page.



Be warned, you could end up losing hours playing with this if not careful  :blink:

Lee
#28
After searching on Google for the answer to this & getting mixed answers I thought I would ask here seeing as there are a lot of knowledgeable folk here ;D

My phone has a little 1gb micro SD & I want to replace it with a larger one. Seeing as I have apps etc stored on it can I just plug the old card into my PC & copy all the files across & then onto the new card or is there some hidden files that will not copy via that method.

Like I said, very much a noob question :-[

Lee

Sent from my GT-I5700 using Tapatalk 2
#29
Am probably shooting myself in the foot with this question but here goes.

As a lot of you know there are a lot of code snippets and algorithms on the net in C or C++, some of which are well documented and others just the code. With regards to the core features of the 2 languages like loops, decision making etc is there much difference?.

Basically I just want to learn enough to get a rough idea of what's going on in the code so I can implement the algorithm in GLB. Would learning a small bit of C be best or just skip to C++?.

It is not a major thing for me but I sometimes see an effect or an example with some sample code but little or no description on how they done it. Also it would help me when I get a bit more adventurous and start playing with inline code ;D

Lee

Sent from my GT-I5700 using Tapatalk 2
#30
Off Topic / Android phone
2012-Mar-25
I have finally managed to get an Android phone. A friend of mine had one sitting in his cupboard unused that he got as a free upgrade but stuck with his iPhone. It is a Samsung Galaxy GT-I5700, also known as a Spica or Portal depending on where you live.

Sadly it is running android 2.1 so rules out any possibility of playing with GLB on it  :( & that is the latest update from Samsungs website.

Has anyone else here had this phone & managed to upgrade it to 2.2 or higher & if so how well did the upgrade go as in everything working as it should. I have unlocked & reflashed Sony Ericsson's in the past but have no idea of where to start on an Android phone.

Lee
#31
http://www.bbc.co.uk/news/business-17434328

They had to wait till they had $97.6bn in cash before doing though  :D

Lee
#32
Is there a command to change the X & Y handles of a sprite. From what I have made out DRAWSPRITE uses the top left corner (0,0) of the sprite for it's drawing whereas ROTOSPRITE uses the centre of the sprite. Basically I want to rotate around a certain point & not the middle of the image.

If it means me making a routine using polyvectors then that's not a problem but I thought I would check before re-inventing the wheel so to speak  :D

Lee
#33
I have finally got round to playing with the POLYVECTOR command and have a couple of questions. Here is a snippet of my current code
Code (glbasic) Select

// csz=character size in pixels, pchar=the character to plot, colour[]= array of colours
FOR y=0 TO 24
FOR x=0 TO 39

STARTPOLY 0
  POLYVECTOR   (x*csz)*2,       (y*csz)*2,       pchar*csz,      0,   colour[2]
  POLYVECTOR   (x*csz)*2,      ((y*csz)+csz)*2,  pchar*csz,      csz, colour[2]
  POLYVECTOR  ((x*csz)+csz)*2, ((y*csz)+csz)*2, (pchar*csz)+csz, csz, colour[2]
  POLYVECTOR  ((x*csz)+csz)*2,  (y*csz)*2,      (pchar*csz)+csz, 0,   colour[2]
ENDPOLY

NEXT
NEXT


Imagine a text display of 40x25 chars setup as an array DISPLAY[40][25] (ignoring the fact that the above code will just print the same char at the moment). The characters are stored as an image strip 2048px x 8px & the colours are stored in the colour array as I wanted different coloured text without having to create a bitmap font for each colour. After I got my head around the texture co-ords to find the right char the above code works fine, now for the questions  :D


  • Is the above method the best/right way to do it with polyvectors, i.e using polymode 0
  • If not would using mode 2 (strip) be a better way of doing it & if so can POLYNEWSTRIP be used in a loop otherwise I would end up with 40 blocks of polyvector code per line  :D
[li]
[/li][/list]

Lee
#34
Was meant to post this ages ago but kept forgetting. If like me you have a large collection of samples this program helps you find them & play them quickly. Just left click to play it or right click to copy the path or open up the containing folder with it selected. You can set which directories to search as well as assign categories to help finding the sample you are after. The latter is basically a filter that rely's on the keywords being in the file name.

It may not be the most powerful sample management program but it is free, quick & easy to use also very handy if like me you have 100's/1000's of sound samples.

Lee

http://sourceforge.net/projects/auralprobe/



#35
Hopefully I will explain this correctly  :D

I am nearly at the stage where I feel comfortable with GLB to actually get my arse in gear & write a game (more than likely a remake to start with), just need to play around more with polyvectors really.

Even though I only have the main Win/OsX/Linux targets & none of the mobile ones I think it would be best to code to one resolution then scale the graphics judging by the various posts in the forum. My question is this, What would be a good resolution to use as a base?. For example would it be best to design/layout the game as 1024x768 then scale down for lower resolutions, or something like 800x600 & scale up or down from that. Of course there may be games where scaling fails or specifically targeting a platform, but will cross that bridge when it happens.

Any feedback on what resolution you design your project in would be appreciated.

Lee
#36
Just a simple change needed to the online help. While trying out this command from the example in the help I kept getting compile errors & after a bit of head scratching figured out the problem.
Code (glbasic) Select

LOCAL w%, h%, pix%[]
IF LOADSPRITEMEM("test.png", w%, h%, pix%[])
   MEM2SPRITE(0, w%, h%, pix%[])
   DRAWSPRITE 0,0,0
ENDIF
SHOWSCREEN
MOUSEWAIT


Just swap the "MEM2SPRITE(0, w%, h%, pix%[])" with "MEM2SPRITE(pix%[],0, w%, h%)" will fix it, might have been a simple typo or the array may have been the last parameter in an older version of GLB.

Lee
#37
Code Snippets / DotBall
2012-Feb-29
Here is my attempt at making an oldschool dot ball, the rotation code I found laying around in an old word document of mine (along with other snippets) so I cannot say with total honesty if I wrote that part or not  :O

I mainly wrote this as an exercise of using functions in types which is slowly beginning to sink in at last & is probably far from the best example. Any suggestions of improvements or if/where I have failed would be welcomed

Code (glbasic) Select

// --------------------------------- //
// Project: dotball
// Start: Tuesday, February 28, 2012
// IDE Version: 10.244


// FREE-VERSION:
// Need Premium for Features:
// 3D Graphics
// Network Commands
// INLINE C/C+++ code

// SETCURRENTDIR("Media") // go to media files
GLOBAL DB AS dotball, scx, scy

GETSCREENSIZE scx, scy

TYPE point
x
y
z
ENDTYPE

TYPE dotball
xrot
yrot
zrot

ballpoints[] AS point

FUNCTION createball: pointcount

LOCAL theta, phi, loop

DIM self.ballpoints[pointcount]

FOREACH loop IN self.ballpoints[]

theta = RND (180)-90
phi = RND (359)
loop.x = (COS(theta) * 10) * (COS(phi) * 10)
loop.y = (COS(theta) * 10) * (SIN(phi) * 10)
loop.z = SIN(theta) * 100

NEXT

ENDFUNCTION

FUNCTION drawball: sx,sy,sz

LOCAL tmpx, tmpy, tmpz, px, loop, persp, x%, y%, colour%

persp = 400

FOREACH loop IN self.ballpoints[]


tmpy = ((loop.y * COS(self.xrot)) - (loop.z * SIN(self.xrot)))
tmpz = ((loop.y * SIN(self.xrot)) + (loop.z * COS(self.xrot)))
tmpx = ((loop.x * COS(self.yrot)) - (tmpz * SIN(self.yrot)))
tmpz = ((loop.x * SIN(self.yrot)) + (tmpz * COS(self.yrot)))
px = tmpx
tmpx = ((tmpx * COS(self.zrot)) - (tmpy * SIN(self.zrot)))
tmpy = ((px * SIN(self.zrot)) + (tmpy * COS(self.zrot)))
x  = (512 * (tmpx) / (persp - (tmpz))) + (scx/2)
y  = (scy/2) - (512 * tmpy) / (persp - (tmpz))

colour = tmpz + 155

DRAWRECT x,y,2,2,RGB(colour,colour,colour)

NEXT

INC self.xrot , sx
INC self.yrot , sy
INC self.zrot , sz

ENDFUNCTION


ENDTYPE


DB.createball(500)


WHILE TRUE

DB.drawball(1,0.75,0.5)

SHOWSCREEN

WEND




Lee
#38
GLBasic - en / Array speeds
2012-Feb-26
While reading an old programming book (2003 so not uber old) I got onto a section about memory access, cache access etc & found something I thought was interesting so decided to test it in GLB. The book is about game coding & the code is in C++ but it's the concepts I was reading it for. Most will prob not find it interesting or any use for it but I found it of interest  :whistle:

Basically (no pun intended) it was saying about how accessing arrays in the wrong order can have an effect on speed & cache hits. His results had more dramatic differences then mine but that was probably down the the cpu's of the time & their respective cache sizes, however I did witness noticeable differences with my translated version of the code.

Code (glbasic) Select

LOCAL n%,n2%, i%, j%, k%, TimeStart, TimeEnd, TimeTaken, DummyVar
n=250
n2=10000
DIM TestData3d[n][n][n]




PRINT "Writing Data to the 3d array",0,0

// Fill 3d array in Column order
TimeStart = GETTIMERALL()
FOR k=0 TO n-1
FOR j=0 TO n-1
FOR i=0 TO n-1
TestData3d[i][j][k]=0
NEXT
NEXT
NEXT
TimeEnd = GETTIMERALL()
TimeTaken = TimeEnd - TimeStart
PRINT "Column order took = "+TimeTaken,0,10

// Fill 3d array in Row order
TimeStart = GETTIMERALL()
FOR i=0 TO n-1
FOR j=0 TO n-1
FOR k=0 TO n-1
TestData3d[i][j][k]=0
NEXT
NEXT
NEXT
TimeEnd = GETTIMERALL()
TimeTaken = TimeEnd - TimeStart
PRINT "Row order took = "+TimeTaken,0,20

SHOWSCREEN

MOUSEWAIT

PRINT "Reading Data from the 3d array",0,0

// Read 3d array in Column order
TimeStart = GETTIMERALL()
FOR k=0 TO n-1
FOR j=0 TO n-1
FOR i=0 TO n-1
DummyVar=TestData3d[i][j][k]
NEXT
NEXT
NEXT
TimeEnd = GETTIMERALL()
TimeTaken = TimeEnd - TimeStart
PRINT "Column order took = "+TimeTaken,0,10

// Read 3d array in Row order
TimeStart = GETTIMERALL()
FOR i=0 TO n-1
FOR j=0 TO n-1
FOR k=0 TO n-1
DummyVar=TestData3d[i][j][k]
NEXT
NEXT
NEXT
TimeEnd = GETTIMERALL()
TimeTaken = TimeEnd - TimeStart
PRINT "Row order took = "+TimeTaken,0,20

SHOWSCREEN

MOUSEWAIT

// Clear 3d array from mem & create 2d one
DIM TestData3d[0][0][0]
DIM TestData2d[n2][n2]

PRINT "Writing Data to the 2d array",0,0

// Fill 2d array in Column order
TimeStart = GETTIMERALL()
FOR j=0 TO n2-1
FOR i=0 TO n2-1
TestData2d[i][j]=0
NEXT
NEXT

TimeEnd = GETTIMERALL()
TimeTaken = TimeEnd - TimeStart
PRINT "Column order took = "+TimeTaken,0,10

// Fill 2d array IN Row order
TimeStart = GETTIMERALL()
FOR i=0 TO n2-1
FOR j=0 TO n2-1
TestData2d[i][j]=0
NEXT
NEXT

TimeEnd = GETTIMERALL()
TimeTaken = TimeEnd - TimeStart
PRINT "Row order took = "+TimeTaken,0,20

SHOWSCREEN

MOUSEWAIT

PRINT "Reading Data from the 2d array",0,0

// Read 2d array in Column order
TimeStart = GETTIMERALL()
FOR j=0 TO n2-1
FOR i=0 TO n2-1
DummyVar=TestData2d[i][j]
NEXT
NEXT

TimeEnd = GETTIMERALL()
TimeTaken = TimeEnd - TimeStart
PRINT "Column order took = "+TimeTaken,0,10

// Read 2d array in Row order
TimeStart = GETTIMERALL()
FOR i=0 TO n2-1
FOR j=0 TO n2-1
DummyVar=TestData2d[i][j]
NEXT
NEXT

TimeEnd = GETTIMERALL()
TimeTaken = TimeEnd - TimeStart
PRINT "Row order took = "+TimeTaken,0,20

SHOWSCREEN

MOUSEWAIT


BTW originally they where separate tests I wrote but then lumped them into one prog & the results where still the same, also trying ints rather than floats produced the same results.

On my system filling the 3d array was on average twice as fast in column order then row order, while reading there was little in it but row order was slightly quicker. The difference does scale with the the size of the array for example the 2d fill with 10000x10000 elements was 3.5 times quicker in column order whereas with 5000x5000 elements around 2 times quicker.

How different the results would be on other platforms like iPhone etc I do not know as not having any of the other platforms I'm unable to test.

If you are filling any large arrays in your project during runtime (except at the initial start) it might be an idea to run this test on the device to see what works quicker if at all. Who knows you may gain a few millisecs that could be used elsewhere or give a boost to updates  :D

Lee
#39
Am having problems with the inbuilt help in that if I use the Search function then click on List topics it comes up with "No topics found". While I am not 100% certain that it did work before I feel quite confident it did.

I have done all the checks like making sure the help DLL's are registered etc & even tested other .chm help files from other apps & they work fine.

Even searching for commands I know exist comes up with the same problem.

Cheers

Lee
#40
I might have a use for this command coming up shortly but have a query regarding the help file stating the following

Warning: READ/DATA might probably not read that large negative numbers.

Is that platform specific, a warning from older version of GLB thats not been removed from the help file or something else?

It may happen that I do not need to store the info in data statements but It would be handy to know if there is indeed a limit as to what can be stored in data statements so I can keep it in mind for future.

Lee