Skip to main content

News

Topic: Surfaces (Read 3635 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
Surfaces
Quote from: DaVince
you can create a little Sphere game that draws the whole map to a Surface object, and then save that Surface out to an image file.

Any good tutorials for using surfaces with sphere 1.5?
  • Last Edit: August 23, 2017, 11:19:43 pm by Miscreant
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

  • Rhuan
  • [*][*][*][*]
Re: Surfaces
Reply #1
Not seen a tutorial but they're easy enough, key functions for getting started with them:
1. image_object.createSurface() turns an existing image into a surface
2. Or you can use CreateSurface(width, height, color) to make a new rectangular surface filled with a colour
3.  surface_object.blitSurface(surface, x, y) draws one surface onto another, (the surface passed as a parameter is the one drawn, the one the function is called as a property of is the target)
4. surface_object.save(filename) saves the surface as an image file, you should specify a type by giving it an extension (I'd normally use ".png".

Now if you want to draw the map onto a surface I think you'll also need:
1. GetTile(x, y, layer) - should return the index of the tile at x, y, layer
2.GetTileSurface(tile_index) - should return a surface object for a given tile index
3. GetNumTiles() - should tell you how many tiles there are (should enable you to limit how many times you call GetTileSurface)

Re: Surfaces
Reply #2
That should help me get started with the surfaces. The Original overworld map for ZeC I made using Gimp has alot of erronious data to it. I thought maybe I'd try @DaVince 's suggestion to try to eliminate the errors. Now, I have a clear description of how to begin.
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

Re: Surfaces
Reply #3
So much more professional looking than what I originally created with Gimp. Much appreciated @Rhuan
  • Last Edit: August 25, 2017, 02:04:41 am by Miscreant
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

  • Rhuan
  • [*][*][*][*]
Re: Surfaces
Reply #4
So much more professional looking then what I originally created with Gimp. Much appreciated @Rhuan
Glad I could help.

One other note, if you wanted to show an in game mini-map you could use the code you've written and couple it with:
surface_object.rescale(w, h) to scale it down.

You can then do surface_object.createImage() to return a normal image ready for drawing with .blit().

Re: Surfaces
Reply #5
That will be useful when I code the map function in dungeon levels.
"I am to misbehave." - Malcom Renyolds, Captain of Serenity