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

Pages: 1 2 [3]
Any special reason why you want to split it up instead of using DRAWANIM?

I suppose I could use grabsprite with drawanim. I need each individual tile from the image because they're tiles for a map, not just a single character animation.

this virtual screen doesn't have to fit to the resolution limits of a graphics card does it?

Also, I couldn't find any kind of delete sprite command. Once I've split the image up, I don't need to keep it loaded anymore so it'd be nice if I could free up the memory.

GLBasic - en / alternative to grabsprite???
« on: 2010-Sep-08 »
I have a function for grabbing individual tiles from a larger tileset image, function looks something like this:

loadsprite path$, 0
drawsprite 0,0,0
//routine for grabbing individual sprites

The problem I've noticed is that it can only grab what fits within the screen's resolution.  I suppose a work around could be offsetting the tileset sprite as I grab each tile.  Is there a way to read the image data directly from memory and rebuild each tile that way?

Code Snippets / fire routine
« on: 2010-Sep-08 »
My first GL program, a cool yet slow fire routine using a simple method I read about long ago.

Code: (glbasic) [Select]
// --------------------------------- //
// Project: untitled
// Start: Wednesday, December 31, 1969
// IDE Version: 8.078

// c = (a*16777216)+(b*65536)+(g*256)+r

SETSCREEN 640, 480, 0

GLOBAL flame = 4.14
GLOBAL fire[]

DIM fire[320][240]



FOR y = 0 TO 239
FOR x = 0 TO 319
fire[x][y] = newValue(x, y)
SETPIXEL x, y, fire[x][y]

FOR x = 0 TO 319
r = RND(255)
fire[x][238] = RGB(r,0,r)
SETPIXEL x, 238, fire[x][238]


UNTIL KEY(28) = 1

FUNCTION newValue:x, y
LOCAL r,g,b,c,c1,c2,c3,c4,r1,g1,b1,r2,g2,b2,r3,g3,b3,r4,g4,b4

c1 = getColor(x, y+1)
r1 = GetRValue(c1)
g1 = GetGValue(c1)
b1 = GetBValue(c1)
c2 = getColor(x-1, y+1)
r2 = GetRValue(c2)
g2 = GetGValue(c2)
b2 = GetBValue(c2)
c3 = getColor(x+1, y+1)
r3 = GetRValue(c3)
g3 = GetGValue(c3)
b3 = GetBValue(c3)
c4 = getColor(x, y+2)
r4 = GetRValue(c4)
g4 = GetGValue(c4)
b4 = GetBValue(c4)

r = (r1+r2+r3+r4)/4.14
g = (g1+g2+g3+g4)/4.14
b = (b1+b2+b3+b4)/4.14

c = RGB(r, g, b)


FUNCTION getColor:x, y
IF x >= 0 AND x < 320 AND y >= 0 AND y < 239 THEN RETURN fire[x][y]

FUNCTION GetRValue: Color
RETURN bAND(Color,255)

FUNCTION GetGValue: Color
RETURN (Color - (INTEGER(Color / 65536)*65536+bAND(Color,255))) / 256

FUNCTION GetBValue: Color
RETURN INTEGER(Color / 65536)

I did notice the functions supplied with the GLBasic examples for retrieving color components were incorrect. It appeared they assumed RGB but I guess it's store as BGR.

I'll try to jump in on this contest. My biggest challenge will be just learning the language.  I'll either do something simple like Super Mario or try zelda. But since I have to make the graphics myself, probably just mario as there's fewer to draw.

GLBasic - en / error when defining arrays
« on: 2010-Sep-01 »
I just downloaded GLBasic yesterday and thought I'd test it's speed by porting a fire routine over. However, I can't seem to define any arrays. Even copying code from the samples gives me the same error:

"untitled.gbas"(21) error : variable is not explicitly defined : fire

DIM fire[320][240]

So what's wrong? Isn't that statement defining the array variable?

Pages: 1 2 [3]