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

#1
I know people around here like to hear about latest developments on the cutting edge of pixelart technology  =D, so here's some good news..

I've been using GrafX2 on and off in the past, but then I got ProMotion license and kind of forgot about grafx as it lacked quite a few features that ProMotion had. ProMotion is/was the cutting edge pixelart editor, but commercial and windows only.

Few days ago I decided to catch up on old grafx2 and... lo and behold, was I in for a pleasant surprise! :good:
That little piece of software has all grown up, received support for layers, animation, lua scripting, palette editing, tilemap editing, lots of grat, GREAT stuff!

I guess from these few hours trying it out, it probably has about 95% features of ProMotion with some improvements as well! Namely the interface, oh how much I love that DeluxePaint Amiga/DOS style interface! We really lost some of that sleeky-ness when we started using windows-based apps.

If you have even remote interest in pixel art, or just love retro inspired software, I urge you to try it out!
Did I mention it's open source and runs on any imaginable platform?
Go! NAOW! http://code.google.com/p/grafx2/
#2
Ok, I'm doing some test on a low res game with huge levels where I need pixel precision data. Actual screen is 256x192 but levels themselves can be huge and i want to have binary (true/false) info on every pixel.

So I tried with GLB arrays and when using int# the biggest (5000x5000) array is taking whopping  200mb ram! Which is a massive overkill for my needs. That array size is an overkill too tbh, but I just amped it up to test mem usage.

Is there a way to DIM the array as boolean only? I tried to inline a _bool type array but my inline jedi skills are pathetic to say the least.


Also, related to this, what is a proper procedure to save huge amounts of data? If I just loop through the array and SAVEBYTE each element, it takes ages to save it. It seems much longer than it usually takes to save a file of that size.
#3
I usually keep my code organized by putting all constants and global definitions in separate SUBs. It kind of makes sense to me to have all related global stuff in one place (in this example type definition and array declaration).

Code (glbasic) Select
GOSUB DefineConstants
GOSUB DefineGlobals

WHILE TRUE
MyFunction()
SHOWSCREEN
WEND


SUB DefineConstants:
CONSTANT ARRSIZE= 100
ENDSUB

SUB DefineGlobals:
TYPE TArray
x;y;z
ENDTYPE
GLOBAL gArr[] AS TArray
DIM gArr[ARRSIZE]
ENDSUB

FUNCTION MyFunction:
// do stuff
ENDFUNCTION


That way, once I'm done with that stuff I can collapse the subs in editor, or even move them to different file, cleaning up the main source file. And since I don't use subs for any other calls, it's very easy to get back to these definitions for modifications, etc.

But GLB compiler puts up a warning for every global variable that's defined in such way as "warning : variable already exists ".
It's not much of a big deal, but when there are lots of those warnings, it's possible to miss some other warning...
#4
I'm trying to wrap my head around this, but I'm kind of lost.
What's the proper way of adding an undo function to an app?

I'm trying to make a simple pixel editor and undo is one of the essential functions such an app should have. But how?
I guess putting all the commands/actions into an array is given. But then what? How do you actually do stuff "in reverse"?

For example, if you paint a white pixel black and then undo it: how do you know that pixel was white before you painted it black?
Or if you draw some complex shape over multiple pixels which can all be of different values...
#5
Off Topic / C64anabalt
2012-Jan-11
Well, indie game Canabalt was ported to C64 and is available as commercial boxed cartridge and as a free download.
Now, how cool is that!?  30 years on, the old C64 is still rocking. :good:


cart: http://www.rgcd.co.uk/2012/01/c64anabalt-cartridge-available-c64.html

downloads: http://www.rgcd.co.uk/2011/12/c64anabalt-c64-2011.html
#6
... 320x240.

What's yours?
#7
I've been playing lots of old-school adventures (again!) - Sierra's "quest"classics: Space, Police, King's Quest and LS Larry. You know, these games with 160x200 resolution and text input.

First thing I noticed is that these games are mostly tedious crap, gameplay-wise, besides Larry, who is still funny as sh!t.
Second thing I noticed is that I want to make a game exactly like this, only mine will be MUCH BETTER(TM).

So I am wondering, what is a proper way to implement text parser in game?

I guess I will use INSTR$ to search for "tokens" or "verbs" in user input. Then the "nouns". Then I'll probably need a list of synonyms to check against. Then it sends a final "command" to the game.

What I would like to know if there are resources online that go into more detail on this topic. Stuff like checking for errors in spelling, or "words inside words" - like "pick" is not the same as "pickaxe", or whatever else...

It would be nice to do this slightly more advanced than those old adventures, which gave annoying errors for almost any combination of words that's not exactly like the one authors envisioned. Something more "interactive-fiction" like. 
Something that will allow people to experiment more, like this....  =D




#8
Math / Point inside polygon
2011-Oct-09
Here's some code that finds whether a particular point is inside a polygon.
Actual routine is not mine, I've found the C code online (http://www.visibone.com/inpoly/inpoly.c) and translated it into GLB.

It's great for implementing various regions, zones, collision or whatever else into your programs.
Code is pure math, it has nothing to do with graphical polygons (no acceleration) but it supports all kinds of mad polygonal shapes.


Code (glbasic) Select
SYSTEMPOINTER TRUE

//create polygon
LOCAL poly[]
DIM poly[RND(3)+3][2]

FOR i = 0 TO BOUNDS(poly[], 0) - 1
poly[i][0] = RND(640)
poly[i][1] = RND(480)
NEXT


// main loop
WHILE TRUE

LOCAL mx,my,mba,mbb
MOUSESTATE mx, my, mba, mbb

drawPoly(poly[])

IF inPoly(poly[], mx, my)
PRINT "Inside!",0,0
ENDIF

SHOWSCREEN

WEND



FUNCTION inPoly: poly[], tx, ty

LOCAL newx, newy, oldx, oldy
LOCAL x1, y1, x2, y2
LOCAL inside

LOCAL npoints = BOUNDS(poly[], 0)

IF npoints < 3 THEN RETURN 0

oldx = poly[npoints - 1][0]
oldy = poly[npoints - 1][1]

FOR i = 0 TO npoints - 1

newx = poly[i][0]
newy = poly[i][1]

IF newx > oldx

x1 = oldx
x2 = newx
y1 = oldy
y2 = newy

ELSE

x1 = newx
x2 = oldx
y1 = newy
y2 = oldy

ENDIF


IF ((newx < tx) = (tx <= oldx) AND (ty-y1)*(x2-x1) < (y2-y1)*(tx-x1))

inside = NOT inside

ENDIF

oldx = newx
oldy = newy

NEXT

RETURN inside

ENDFUNCTION



FUNCTION drawPoly: poly[]

LOCAL npoints = BOUNDS(poly[], 0)

FOR i = 0 TO npoints-2
DRAWLINE poly[i][0],poly[i][1], poly[i+1][0],poly[i+1][1], RGB(200,200,200)
NEXT

DRAWLINE poly[-1][0],poly[-1][1], poly[0][0],poly[0][1], RGB(200,200,200)

ENDFUNCTION
#9
I'm not sure whether this is a bug, feature, or (most likely) I'm doing something wrong, but I have a problem with FINDPATH routine.

I'm trying to get a "character" to move across map towards target via the shortest possible route.
No matter what I do, I always get movement that is totally perpendicular.
For example, if I have a clear map without obstacles and with same movement cost for all fields, "character" will move first horizontally along x-axis and then descend down on y-axis towards the target in a perfect, L-shaped path (that's obviously not the shortest).
If I add some random blocks and terrain costs to the map, it still follows this same angular path, but it's kind of masked by the pathfinding heuristics.

Here's the code:
Code (glbasic) Select

// change these variables for different map layouts

LOCAL mapIsFlat = TRUE // true = all fields on map have same passage value
LOCAL heuristics = 0.0          // 0 = shortest route , 1 = cheapest route
LOCAL mapBlockValue = 0 // percentage of blocked map fields, 0 = clear map



GLOBAL walkpath[]
GLOBAL map[]


makeMap(300, 300, mapBlockValue, mapIsFlat)

calculatePath(heuristics)

WHILE TRUE

walk()

SLEEP 20
SHOWSCREEN

WEND


FUNCTION walk:

        // draw map
DRAWSPRITE 0,0,0

STATIC currentStep
LOCAL maxStep

STATIC currentx
STATIC currenty

PRINT "step: " + currentStep + "  x: " + currentx + "  y: " + currenty ,0,0

maxStep = BOUNDS(walkpath[], 0) - 1

currentx = walkpath[currentStep][0]
currenty = walkpath[currentStep][1]

// draw path
FOR i = 0 TO maxStep - 1
SETPIXEL walkpath[i][0], walkpath[i][1], RGB(0,0,90)
NEXT

// draw character
SETPIXEL currentx, currenty, RGB(0,255,0)

//draw target
SETPIXEL walkpath[-1][0], walkpath[-1][1], RGB(255,0,0)

INC currentStep, 1
IF currentStep = maxStep THEN currentStep = 0


ENDFUNCTION



FUNCTION calculatePath: heuristics


LOCAL startx, starty, targetx, targety

startx = 10
starty = 10
targetx = BOUNDS(map[], 0) - 20
targety = BOUNDS(map[], 1) - 20

LOCAL ok = FINDPATH(map[], walkpath[], heuristics, startx, starty, targetx, targety)

IF ok = FALSE

PRINT "Path NOT found!", 10,10
SHOWSCREEN
KEYWAIT
END

ENDIF


ENDFUNCTION


FUNCTION makeMap: x, y, blocked, mapIsFlat


DIM map[x][y]

FOR i = 0 TO x - 1
FOR j = 0 TO y -1

LOCAL r = RND(100) + 1

IF mapIsFlat = TRUE
IF r > blocked THEN map[i][j] = 1
ELSE
IF r > blocked THEN map[i][j] = RND(10) + 1
ENDIF
NEXT
NEXT


FOR i = 0 TO x - 1
FOR j = 0 TO y - 1
IF map[i][j] > 0.1
LOCAL col = 32 + (map[i][j])
SETPIXEL i, j, RGB(col,col,col)
ENDIF
NEXT
NEXT

GRABSPRITE 0, 0,0, x,y

ENDFUNCTION

#10
Sprite Something

http://www.youtube.com/v/4_ZBI7KSI0M

Finally, !!FINALLY!! a proper mobile pixel drawing app exists!  :happy:
Oh my, this changes my attitude towards iPad for 180 degrees. It's the definition of killer app as far as I'm concerned.

I have ProMotion license, but it's a 100% desktop app, with not-so-friendly interface (very 90s in philosophy).
Even if I had a touchscreen PC, desktops app generally suck on it.

And all the pixel apps I tried for iPhone are more or less useless. But this... this is just wonderful.
#11
I'm trying to make a framework for point'n'click adventure games, like the old classics from Lucas Arts. Just like Monkey Island, Indiana Jones, Day Of The Tentacle, etc.

Structure of these games revolves around "Rooms" (locations, what you walk around) and "Objects" (stuff you interact with, like items that you can pick up and characters you can talk to).
I'm wandering what is the best way to organize this?

My current plan is to use arrays that store all objects and all characters in the game. Let's call them "game arrays".
There really isn't much raw data to store in these anyway. Let's say that I could have up to 50 rooms with about 20 objects max. per room - that's array[1000]. Not that big.
These "game arrays" are useful as they provide instant game-save feature. Write them to file and you're done.

Code (glbasic) Select

TYPE TObject
roomNr
positionX
positionY
sprite[] as TSprite
sound[] as TSound
//..... other stuff
ENDTYPE

LOCAL gameObject[] as TObject
LOCAL gameCharacter[] as TCharacter

gameObject[34].roomNr = 12
gameCharacter[23].roomNr = 12


When the player enters certain room, all relevant "game" objects will be copied into "Room" array for easier handling, sorting and drawing. At this time, all graphics and sound is loaded as well. "Game array" just stores references to files, etc.

Code (glbasic) Select

LOCAL object[] AS TObject  // this is the "Room" array
FOREACH n IN gameObject[]
IF n.roomNr = currentRoom
DIMPUSH object[], n
ENDIF
NEXT

FOREACH n IN object[]
// load all sprites, sounds
// draw it on screen, do other exciting stuff
NEXT

Upon player exiting the Room, all data from local room array should be copied back to game array.
This is the tricky & untidy part - now I need another reference to know exactly *where* I should copy back the data.
Maybe I could use object "names" for reference:
Code (glbasic) Select

IF gameObject[j].name = object[i].name THEN gameObject[j] = object[i]


Or maybe I should store array index when copying from game to room array:
   
Code (glbasic) Select


gameObject[42].arrIndex = 42  // extreme potential for fcuk-up here!

DIMPUSH object[], gameObject[42]

FOREACH n IN object[]
gameObject[n.arrIndex] = n
NEXT


This method is faster, and seems to be more sensible.

I considered putting everything into multi-dimensional array but then I could have something like:
object[currentRoom][LAMP].sound[FIRE].volume = 12
Ouch! :)
And I don't need to have all of that in memory anyway - gameObject[] could be deleted before loading graphics and sounds to free some memory.

I also considered having all Rooms in their separate files. That would make run-time loading very easy, but would complicate save-game routines.

Then again, I'm sure I'm over-complicating stuff here. Twenty-some years ago these games came on a single floppy. There must be a quick & dirty solution to this.
#12
I am proud to announce something I've been working on for some time now:

Fashionable GLBasic-branded boxer shorts for self-concious indie developer!!!

Currently, I have few slightly worn-out prototypes that are available for immediate delivery for just $498.78 + postage.

Preorders for first batch of shorts start as of today, April 1st, 2011.
Estimated delivery is in two-months-from-nowTM.

Teaser image of the prototype model is enclosed.

Apply now!!!



[attachment deleted by admin]
#13
Take a look at this Youtube vid. It's a bit old, but I've just run into it.  :O



There's full description on Youtube page, but here's the short version.
Basically, the author is using pixel shaders and pre-rendered pixels to make a REAL 3D world on a 2D projection. Everything on screen is made of 2D cut-outs, but it acts like real 3D objects.Ever seen real-time lighting, HDR, bloom, daylight changes and weather effects in a 2D game?

It's kind of difficult to explain in words, but method is ingeniously simple, just watch the vid.
This is THE stuff I dream of. THE perfect 2D engine, as author himself rightfully calls it, "better than Baldur's Gate 2".

Gernot, streamline something like this into GLB and I'll wash your car for a year.
#14
GLBasic - en / Mac App Store
2010-Oct-20
Not iPhone, but full-size Mac store is starting soon. Might get interesting. Mac gaming is probably going to skyrocket in popularity.

http://www.apple.com/mac/app-store/

Oh, and one more thing: now we can finally make (and maybe even sell) games that use mouse and keyboard input! Yay!  :P

#15
I have switched to Mac as my main development machine and I would like to have GLB in a VirtualBox partition.
Installing full Win XP for a few programs seems like an overkill to me ( I already have Bootcamp XP partition for games etc.) so I was thinking about installing an old copy of Win98SE in VirtualBox and running GLB off that. Will it work?

I'm mainly concerned if VirtualBox supports file/network sharing between OSX and Win98.
#16
Hi,

I've been away from the webz for a few months (being father to a 10 mo. old is exhausting!) but I'm slowly getting back on my feet again.  I've occasionally lurked here and there, but I kind of lost track of the overall progress in the GLB world.


So, what's the current status, especially on the iPhone front?
Can someone give the quick summary: what's new, what's in, what's isn't, limitations, etc.

I've seen in other thread that Gernot managed to get GRABSPRITE to work and that there are some issues with multitasking on new iOS... that's the kind of info I want to know. So, hit me.
#17
Is there any difference in performance when using images/textures of lesser bit-depths?
I did some tests with both 32-bit and indexed 8-bit colour images and there seems to be no difference at all in memory usage and drawing speed. Obviously, 8-bit images loaded faster but that's just because the smaller file size.
#18
I've got my retro game in the works which uses low res graphics. On PC/Mac I draw everything at native low res and then grab/stretch it to bigger resolution.

Now, since iPhone doesn't support grabsprite, what would be the best way to do this? Would be nice if it worked on the Wiz as well.

1) Use STRETCHSPRITE  to scale each sprite as it is drawn to the screen. This would complicate my code a bit, and would probably degrade the performance.

OR

2) Resize graphics manually to iPhone resolution, and then draw normally. This could be faster, but requires separate graphics for iPhone.

OR

3) Something else?
#19
I have a few questions regarding 2D collision implementation.

Take a look at attached image.


Let's assume that brown splotch is a walkable area and white is not-walkable. There are those three sprite dudes trying to walk around.
I need the most efficient routine to implement collision detection.

Here's how I do it at the moment:

1) draw a huge full-screen "pixel" with non-walkable area filled and walkable area as transparent
2) draw small sprites (yellow lines) that serve as base-line for the players
3) check for SPRCOLL between 1) and 2) - that way I prevent things like blue dude from happening.
3) then draw actual background and actual characters, so those "helper" sprites are never seen by players
4) showscreen

Am I doing it right or is there a simpler way?



Another question:
Is it possible to check for collision between a box(start,x,y) and a sprite? And is it possible to check for collision between sprite and non-sprite objects? Like between line and sprite?
Something like collisions in 3D: sphere with object, ray with object, etc.



#20
I'm trying to use some of the advanced OpenGL features on Mac Mini G4 (OSX10.4 and Radeon 9200 card) and have lots of trouble with it.

This is the stuff that doesn't work:
- textures that aren't powers of two
- createscreen/usescreen and related commands
- fullscreen :blink:

I'm trying to develop a retro style game which runs in 320x200 and then stretches the whole screen to user-specified resolution and aspect ratio, using screen and stretchsprite commands.

What would be the minimum hardware configuration for those things to work?

This all works fine on my newer machines, including a netbook with Intel integrated card.