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.

Topics - spathi

Pages: [1]
General coding questions / Spiral Copper?
« on: August 31, 2014 »
Wondering how "spiral copper" effects are done, where it will appear that several copper bars are twining together in a double or triple helix.  There are also a lot of other effects that use this, like square columns that seem to be twisting and untwisting, that sort of thing.

Here is an example of a crazy effect using this, starts at 14:50 or so: 

Obviously the individual columns of a bitmap are being shifted based on a sine wave to get the cylindrical effect, but how exactly?

Perhaps I am being foolish and it isn't really being mapped onto a cylinder...

General coding questions / Emulating COPR?
« on: February 17, 2014 »
Has anyone thought of doing partial or complete emulation of the Copper processors?  I write 2D games and I am fascinated by late 80s glitz.

Is that an insane idea that could be better accomplished by other means?

General chat / Copper Master
« on: October 01, 2013 »
I firmly believe that this is one of the highest points in the entire demoscene prior to good 3D hardware.  Even now it is a masterpiece of visual and music design, more so than a mere technical achievement which it may or may not have been at the time.

Are there some canonical algorithms for generating the smooth color lookup tables for copper, especially for the semi-metallic gradients on copperbars?  Do you simply move R, G, and B smoothly toward white and back on a sine function to give it the round gradation?

EDIT:  Well, I found this, which you most likely all know about:

I write retro games that need to run on phones so some of the ways of making things look flashy and good have become useful once again.  Everything is a circle.

General coding questions / Simple 3D transform?
« on: August 26, 2013 »
I am looking for a very simple method for coding 3D engines similar to those in early demos where things like spinning spheres made of pixels were featured.

Hidden line and surface elimination is not necessary, nor is rotation of the camera.

Something like this would be nice though pixels would satisfy, and shading is not necessary-- I can do that myself with surface normals on a lookup table.  (I do realize what vectorballs are.)

As Z moves away from the camera toward the horizon, how are X and Y transformed by Z?

General coding questions / Pixel Shader Question
« on: August 26, 2013 »

How difficult would it be to write a shader that does simple per-pixel coloring operations based on previous colors of that pixel?

Is that one of the things that borders on impossible for shaders to do?  Can pixels keep track of their states?

Does anyone have a function giving rotational impulse force from a collision of 2D vector objects?

This seems like it should be fairly simple to do on the basis of how many degrees object B is traversing with respect to some mass center of object a.  And the closer the traversing tangent line is to the mass center, the more momentum transfers into x/y velocity as opposed to angular velocity.

This doesn't has to be accurate, it only has to look OK.

Hey guys, quick question here.  How many pixels can be raytraced or raymarched per second on a mid-range CPU these days?

The application is this:  I want to do a game similar to 80s style games where there were a limited number of sprites active on screen at once.  The sprites will be depth sprites with a color map (texturemap), a normal map and a height map.  If the sprites were 64x64, how many of them would it be possible to raymarch per second?

Further, what if the raytracing was cached for a few frames?  EG. we raytrace four per frame, and we have a total of twelve onscreen at once, so the shading and hilighting only updates for each object once every three frames?  Are getpixel routines fast enough for this?

Furthermore, perhaps even tilemap tiles could receive some sort of dirtyrect treatment-- the initial picture of a tile would be raytraced, but tiles under the effect of a light or shadow (determined by quick and dirty methods) might also be raytraced.

What if the main light is coming from a standard direction, eg. 45 degrees?

Of course any rational person would use OpenGL.  But I am not a rational person.

Am I chasing my tail here?

Let's say we allowed ten to be raytraced per frame.  If they were 64x64, that ends up being 6400 pixels, or an 80x80 window.  Surely even midrange PCs could handle that, yes?

Projects / Crazy Clowns: My first commercial game
« on: July 11, 2012 »
Since Kiri posted his commercial game project, here's mine.  This is just a demo version and I'll be releasing a more fully featured product when I get another project finished.

I'm interested to know what people think of this and how I could improve it.  It's a kid's game but it's actually surprisingly difficult and fun.

It's on Slideme for free here.  They seem to like it quite well, I've had over a thousand downloads since I uploaded it two days ago.

Here is the Windows exe:

If the mods would like to host the HTML5 version right here in this post I can provide that.

Projects / Voronoi
« on: July 10, 2012 »
Voronoi diagrams are apparently a rather bonecrushing algorithm.  I forget the O notation but the best possible is pretty slow.  Adding recursion sped it up hugely.  I'm doing this for a reason but I thought it was interesting enough to share.

It seems like you could pretty easily cull the tree by running paths between different regions, bailing out on the second region, and building up a list, per centroid, of neighbors.  Probably the smart people already thought of this.

If you watch you'll see some very strange artifacts around some of the edges.  I'm not quite sure why they are in there, probably some sort of precision error.

Code: [Select]
Global WIDTH=1024
Global HEIGHT=768
Global mode# = 0

Type voronoipoint
Field x#,y#
Field r#,g#,b#
Field id#

' bounding box for region
Field ux#,uy#,lx#,ly#

Method randomize()
x = Rand(WIDTH)
y = Rand(HEIGHT)
ux = x
uy = y
lx = x
ly = y
End Method
End Type

Global vpointlist:TList = New TList

For Local i# = 1 To 32
Local tempvpoint:voronoipoint = New voronoipoint
tempvpoint.randomize() = i

Function closestvpoint:voronoipoint(x#, y#)  ' returns closest voronoi point for x and y
Local closestpoint:voronoipoint = New voronoipoint
Local closestdistance:Double = 10000
Local nextclosestdistance:Double = 10000
Local p:voronoipoint = New voronoipoint
For p = EachIn vpointlist
Local thisdistance:Float = Distance(x, y, p.x,p.y)
If thisdistance < closestdistance
nextclosestdistance = closestdistance
closestdistance = thisdistance
closestpoint = p
Return closestpoint
End Function

Function thesame(a#,b#,c#,d#)
If a=b And a=c And a=d
Return True
Return False
End Function

Global p1:voronoipoint = New voronoipoint
Global p2:voronoipoint = New voronoipoint
Global p3:voronoipoint = New voronoipoint
Global p4:voronoipoint = New voronoipoint
Global tempvor:voronoipoint = New voronoipoint

'Function voronoirecursive(ax, ay, bx, by, cx, cy, dx, dy)

Function voronoirecursive(ux, uy, lx, ly, recursions#)

If recursions < 5 And KeyDown(KEY_ESCAPE) recursions = 1000

If recursions < 12

' check all four points clockwise

If thesame(,,,
Local midpointx# = ux + ((lx-ux)/2)
Local midpointy# = uy + ((ly-uy)/2)

SetColor p1.r,p1.g,p1.b
DrawRect ux, uy, lx-ux, ly-uy
SetColor 0,0,0

' Increase extents of bounding box
If ux < p1.ux p1.ux = ux
If lx > p1.lx p1.lx = lx
If uy < = uy
If ly > = ly

If mode = 2 Or mode = 3 drawhollowrect(ux,uy,lx,ly)
If recursions < 7 Flip
Return True
midpointx# = ux + ((lx-ux)/2)
midpointy# = uy + ((ly-uy)/2)
voronoirecursive(ux, uy, midpointx, midpointy, recursions+1)
voronoirecursive(midpointx, midpointy, lx, ly, recursions+1)
voronoirecursive(ux, midpointy, midpointx, ly, recursions+1)
voronoirecursive(midpointx, uy, lx, midpointy, recursions+1)

EndIf  ' bailing out because recursions too high
End Function

Function lefthalf:Object(data:Object)
End Function

Function righthalf:Object(data:Object)
End Function

While Not KeyDown(KEY_ESCAPE)
Local p:voronoipoint = New voronoipoint
'Local thread1:TThread=CreateThread(lefthalf,"")
'Local thread2:TThread=CreateThread(righthalf,"")


'Local tv:voronoipoint = New voronoipoint
'For tv = EachIn vpointlist

Local tv:voronoipoint = New voronoipoint
For tv = EachIn vpointlist
SetColor 255,255,255
'drawhollowrect(tv.ux,, tv.lx,

Local ticks = 0

For tv = EachIn vpointlist
SetColor 255,255,255
If mode = 1 Or mode = 3 drawhollowrect(tv.ux,, tv.lx,
If mode = 5 Or mode = 3 DrawRect tv.x-2,tv.y-2, 5,5

ticks = ticks + 1

Until MouseDown(1) Or ticks > 200

For tv = EachIn vpointlist

mode = mode + 1
If mode > 5 mode = 0


'get 4 points
' if all the same, color according to closest and bail.
' else subdivide

Function drawhollowrect(ux, uy, lx, ly)
DrawLine ux, uy, lx, uy
DrawLine lx, uy, lx, ly
DrawLine lx, ly, ux, ly
DrawLine ux, ly, ux, uy
End Function

Function Distance(Point1X,Point1Y,Point2X,Point2Y)
  'calculate the x/y distances
  dX = Point1X - Point2X
  dY = Point1Y - Point2Y

  'calculate exact distance
  'Sqr() always returns an absolute value
  Return Sqr( (dx^2) + (dy^2) )
End Function

C / C++ /C# / Good Features for Sprite Library?
« on: March 29, 2012 »
Hey gents, I'm currently writing a small sprite library containing various animation functions.  I'm wondering if anyone has any ideas for functionality that I could include.

I have such things as fades, with function pointers to different ramping functions.

Ideally I would like all those ramps to be generic and usable for numerous different features, like smooth interpolation between color values.

There are also various types of bouncing and jiggling.

I'm just soliciting ideas so that I can put as much as possible into the library while I have the code fresh in my mind.

General coding questions / LISP?
« on: January 29, 2012 »
Any LISP coders?  I am new to the language and it seems exceedingly interesting and potentially very powerful despite 30 years of imperative programming making it rather a bit of a bear to understand.  There are a number of great lecture courses on Youtube about it, specifically "Structure and Interpretation of Computer Programs," both the MIT and Stanford versions.  I've tried cracking lisp before and gave up-- I am a little farther this time.

Challenges & Competitions / Game Competition?
« on: January 12, 2012 »
Anyone interested in a retro (or anything) game competition?

Really I am selfish, I just want new games to play.

General chat / Cash from Casual Games?
« on: January 04, 2012 »
Is there any point these days in writing casual games for the portals, et cetera?  Does anyone make any money on that anymore?  If you release numerous games in a few styles, is it possible that it could be viable?

Code: [Select]
'Blitzmax Font Stripper
' By SpayThee

' If you get this harmless error "D3DERR: Unable to lock render target surface" it means you are
' trying to draw a pixmap outside of the screen boundaries... the image needs to be large enough
' to accomodate the font strip it will make when generating the font image.

' These settings will work with this image:
' BUT!  You have to load it up in paint and save it as a bmp, because it won't like loading a gif...
' Save it in a ./media directory...


Global FONTSIZE:Int=16
Global FONTOUTPUTNAME:String = "fontstrip.png"
Local fontpixmap:TPixmap=LoadPixmap("media/062.bmp")  ' Font Name Goes Here
Local fontstrip:TImage=CreateImage(ORIGIMAGESIZEX*FONTSIZE,FONTSIZEY)  ' Create image the size of fontstrip
Global pixwindow:TPixmap
Global savepixmap:TPixmap

' The next string needs to contain the characters in the order they appear in the bitmap.
' This is used as a lookup string for fontprint()
Global characters:String="-.!0123456789:'(),? ABCDEFGHIJKLMNOPQRSTUVWXYZ"

'  This block of three FOR clauses chops up the bitmap and renders it all out as a strip.
'  It's three clauses because all of the bitmap fonts are different anyway so you have to jigger
'  this differently depending on how the font maker set his bitmap up.

For i = 0 To ORIGIMAGESIZEX Step 16  'Step expression must be constant!?
pixwindow = PixmapWindow(fontpixmap,i,0,FONTSIZE,FONTSIZE)
DrawPixmap pixwindow, i,0

For i = 0 To ORIGIMAGESIZEX Step 16
pixwindow = PixmapWindow(fontpixmap,i,FONTSIZE+1,FONTSIZE,FONTSIZE+1)
DrawPixmap pixwindow, i+320,0

For i = 0 To ORIGIMAGESIZEX Step 16
pixwindow = PixmapWindow(fontpixmap,i,FONTSIZE*2+2,FONTSIZE,FONTSIZE+2)
DrawPixmap pixwindow, i+640,0

' Save the stripfont so we don't need to go through all this rigamarole each time we want to load the font image.  Could also reorder
' the letters if you wanted to, if you had a bunch of fonts...  all these old demoscene fonts have all sorts of weird letter orders and fucked up
' conventions that they adhere to.

Local charmap:tmap=CreateMap()

'Driver, Test, Copper
Global ticks:Int=0

teststrip:TImage = CreateImage(480,fontsize,1,DYNAMICIMAGE|MASKEDIMAGE)

fontprint("COPPER TEXT... I MISS ROBOTRON",10,10)

'This chunk is to build the TImage for the copper.  Necessary because pixmaps won't
'allow you to draw in maskmode (that I know of)
'Major hackwork in order to allow you to get a mask image.

GrabImage teststrip,10,10 
SetColor 255,255,255
DrawRect 0,0,1024,480
SetColor 0,0,0
DrawImage teststrip,10,10
GrabImage teststrip,10,10

Local xorig:Int
Local yorig:Int
While Not KeyHit(KEY_ESCAPE)
SetColor 255,0,0
SetMaskColor 255,255,255
SetColor 1,0,0
DrawImage teststrip, 0+xorig,10+yorig
fontprint("-.!0123456789:'(),?", 10,10)
fontprint("JUST A LITTLE FONT DEMO", 10,46)
fontprint("NOT MUCH TO LOOK AT", 10,66)

' A very basic time-sliding copper
Function copperbar(ux:Int,uy:Int,lx:Int,ly:Int)
frequency = Sin(ticks)*25+50
For Local y:Int = uy To ly
SetColor 128*Sin(ticks *frequency +(y-uy)*50)+128,128*Cos(ticks *frequency +(y-uy)*50)+128,Rand(255)
DrawLine ux,y, lx,y
End Function

Function fontprint(stringtoprint:String,x:Int,y:Int)
' you will probably want to touppercase this string, otherwise it will not handle lowercase right
' unless the font is set up for that.  Or just type in all caps. 
For Local i:Int = 0 To stringtoprint.length-1
Local chartoprint:Int=characters.find(Chr(stringtoprint[i]))
If chartoprint = -1 chartoprint=13
DrawPixmap pixwindow, x+i*FONTSIZE,y
End Function

The image it uses is here...

General chat / Why are pixel reads so slow?
« on: December 22, 2011 »
Why do pixel read operations tend to be so slow?  Is it because they are attempting to read from vram?

Could things be sped up with custom draw routines that also blit to an array as well as drawing to vram?  Then your pixel read operation would read from the array, which would contain identical information.  Your draws might be somewhat slower but your reads faster?

General chat / Relative Size of Demoscene?
« on: December 21, 2011 »
You know, it strikes me that the demoscene hasn't necessarily shrunk that much since the Amiga days-- or it might even have grown!  It seems like it's smaller in relation to everything else, but aren't there just a ton of things posted to Pouet?  The whole cracktro thing seems to have become a thing of the past-- is it possible that we could do something about that?  Scene releases from eg. Razor would go a long way toward popularizing the scene to a new generation.

Blitz / Blitz Not Fast Enough?
« on: December 20, 2011 »
I've noticed a number of comments from users and admins here (Shockwave I think, specifically) on the thread about software renderers and elsewhere, indicating that Blitz just isn't fast enough for writing fast software renderers.

Is this the case with Blitzmax or does it apply only to the older versions (Plus, Blitzbasic and 3D?)

Is Blitzmax worthwhile to stick with, for a few games at least, or will it be necessary to move to something faster?  It seems that Blitzmax is more than fast enough for any sort of retro title I'd be likely to do, especially since it can do OpenGL.  Is this the case?  I do know C and C++, except for templates, but I am completely blown away by Blitz and I would like to bring a couple of products to market with it.

Blitz / File Creation Issue
« on: December 13, 2011 »
I'm running into a bug that I ran into before on Blitz.

It will not open a file for write if I do so based on user input using this code:

Code: [Select]
If tempchar>0 inputtext=inputtext+Chr(tempchar)


DOES NOT WORK: Local out:TStream=WriteStream(savedialog.typedtext) (this is just a string!)
WORKS:                   Local out:TStream=WriteStream("bluedemon")
CloseStream (out)


Is there something going on with newlines or something that I'm not aware of?  Is using KEY_ENTER to exit the loop stripping a newline off of the end of the file that should be there?

It doesn't error or anything, it just doesn't create any file.  The other file creation method using CreateFile does not work either which leads me to believe that it must be some sort of bug in my user input code that I am not aware of...

Since I know some people like screenshots, here is the titular blue demon:

This is for a voxel dungeonshooter/roguelike I am working on called Dungeonslayers.  The whole gui toolkit is written by me-- it doesn't look like much but it has control arrays, sliders, and radio buttons.

Blitz / Strange Issue with Arrays on Blitzmax
« on: November 18, 2011 »
I have a very peculiar issue that I'm running into.  This is, frankly, the most intractable bug I've run into for years.

The code here is VERY simple and fundamental, therefore it can't be a bug in Blitz.  It has to be something that I'm not seeing.

This is an 8x8x8 cubical array.  I am attempting to set each cell of the array with a different value.  However, when I later read the cells, they all come out the same as the last value that I fed in!  In other words, ALL THE CELLS ARE APPARENTLY OVERWRITTEN WITH THE SAME VALUE.

The strangest thing is that the error happened with Blitz's built-in multidimensional array functionality.  So I thought that it might be a bug with that, and I wrote my own array class using a 1d array, with aliasing to make it 3d thus:

Code: [Select]
Trouble is that the same error occurs!

I have done my best to pare away everything that is not necessary to isolate the bug, but I still can't see where the problem lies.  Might anyone have any idea?  I am afraid that there may be some sort of bug in the Blitzmax functionality for arrays of types....!?!?!

Initially things weren't packaged away in classes but were all procedural.  Imagine my horror after I wrote my own array class, packaged away in classes, and the same error occurred with different code!

Am I going insane?  Sure feels that way.

Code: [Select]

'jgrid is an 8x8x8 grid of Tcolor types.  For testing purposes, just looking at the r value-- same problem occurs with g and b so removed them.
Type Tcolor
Field r:Double
End Type

Type Jgrid
Field data_array:tcolor[512]
Field tempcolor:tcolor = New tcolor

Method set(x:Int,y:Int,z:Int,r:Float,g:Float,b:Float)
End Method

Method get:tcolor(x:Int,y:Int,z:Int)
Local returnvalue: Tcolor = New Tcolor
returnvalue = data_array[x+(8*y)+(64*z)]
Return returnvalue
End Method

Method randomize()
For Local x:Int = 0 To 7
For Local y:Int = 0 To 7
For Local z:Int = 0 To 7


End Method
End Type

' Here is the testing driver for the above classes.

Global testjgrid:jgrid=New jgrid
Local testcolor:tcolor = New tcolor

testcolor = testjgrid.get (3,3,3)

Print testcolor.r

testcolor = testjgrid.get (7,7,7)

Print testcolor.r

Pages: [1]