Hello Guest

Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
General / Saving and Loading
« Last post by travismix1980 on January 29, 2017, 03:59:20 PM »
So I was looking around and I am really interested in using Otter for my next project.  It has come down to Otter or Monogame and I must say that I really like the examples that I am seeing however I couldn't find any information on saving and loading game data.  Does anyone know if this has been covered for Otter and I am just not seeing it or if not can we get a tutorial on how to do that?

Thanks
22
General / Re: A level editor that's not garbage?
« Last post by Commanderstitch on December 29, 2016, 07:35:57 PM »
I've had no problems with multiple layers in tiledsharp. :-) works great with tiled and is fairly pretty fast. :-)
23
General / Re: A level editor that's not garbage?
« Last post by misthema on December 29, 2016, 02:29:51 AM »
Just to raise awareness, I made a minimalistic support for TileD: http://otter2d.com/forum/index.php/topic,120.msg710.html#msg710
24
Help / Re: Tile Pixel Manipulation
« Last post by misthema on December 29, 2016, 01:56:36 AM »
Thanks for the quick reply!

Hm is it possible to only color the grayscale part of the sprite? Coloring the whole tile wouldn't work because I have fixed colored parts that shouldn't be tinted and stay as they are.

Oh and yes I have requested a slack invite but havn't gotten any email yet (yes I checked the spam folder)
You could always separate your fixed-colored-parts and the greyscale images into 2 images, then use color tinting on the greyscale one. This might cause some problems if you're rotating your sprites/camera, unless you use the exact same (rounded) position and angle for both images. Doing this by manipulating pixels would be slow as hell if done in real-time. Pre-processing these wont cause any problems though.
25
Ideas / Re: Tiled Support
« Last post by misthema on December 28, 2016, 06:10:12 AM »
http://screencast.com/t/Z285dQwZVXm

 tiled sharp works. Floatvoid has a better understanding of it, however. My line only does a single layer. I have the other one on my machine somewhere that does the layers too.

How do you set your collisions? I only see setting tile IDs for your Tilemap and I'm so lost with collisions...

EDIT: Here's a quick and nasty (but working) solution for Tiled maps (uses TiledSharp):
Code: [Select]
using System;
using System.Collections.Generic;
using System.Linq;
using Otter;
using TiledSharp;

public class TiledMap : Entity
{
class _Tileset
{
public string Name;
public TmxTileset TmxTileset;
public ImageSet TilesetImage;
}

readonly string pathMap = string.Empty;

public TmxMap TmxMap;
public int FullWidth, FullHeight;

GridCollider _gc;
List<_Tileset> _tilesets;

public TiledMap(string path) : base()
{
pathMap = path;
_tilesets = new List<_Tileset>();
Load();
}

public void SetCollisionLayer(string layer, Enum tag, params Enum[] tags)
{
_gc = new GridCollider(FullWidth, FullHeight, TmxMap.TileWidth, TmxMap.TileHeight, tag, tags);
setupGridCollider(layer);
AddCollider(_gc);
}

public void SetCollisionLayer(string layer, params int[] tags)
{
_gc = new GridCollider(FullWidth, FullHeight, TmxMap.TileWidth, TmxMap.TileHeight, tags);
setupGridCollider(layer);
AddCollider(_gc);
}

void setupGridCollider(string layerName)
{
var layer = TmxMap.Layers.FirstOrDefault( x => x.Name.Equals(layerName) );

for( int y = 0; y < TmxMap.Height; y++ )
{
for( int x = 0; x < TmxMap.Width; x++ )
{
int tileID = y * TmxMap.Width + x;
_gc.SetTile(x, y, layer.Tiles[tileID].Gid > 0);
}
}
}

public void Load()
{
TmxMap = new TmxMap(pathMap);

if( TmxMap.Orientation != OrientationType.Orthogonal )
throw new FormatException("Tilemap Orientation invalid! Only [Orthogonal] supported.");

FullWidth = TmxMap.Width * TmxMap.TileWidth;
FullHeight = TmxMap.Height * TmxMap.TileHeight;

// Load tileset images
foreach( var tileset in TmxMap.Tilesets )
{
var imgSet = new ImageSet(
tileset.Image.Source,
tileset.TileWidth,
tileset.TileHeight
);

_tilesets.Add(
new _Tileset{
Name = tileset.Name,
TmxTileset = tileset,
TilesetImage = imgSet
}
);
}
}

public override void Render()
{
foreach( var tmxLayer in TmxMap.Layers )
{
// Render visible layers only!
if( !tmxLayer.Visible )
continue;

// Layer tiles
var tiles = tmxLayer.Tiles;

for( int y = 0; y < TmxMap.Height; y++ )
{
for( int x = 0; x < TmxMap.Width; x++ )
{
var i = y * TmxMap.Width + x;
var tileID = tiles[i].Gid;
var tileset = tilesetForGid(tileID); // get right tileset for this tile!

if( tileset == null )
continue;

var firstGid = tileset.TmxTileset.FirstGid;
var frame = tileID - firstGid;

tileset.TilesetImage.Frame = frame;

var tx = x * TmxMap.TileWidth;
var ty = y * TmxMap.TileHeight;

tileset.TilesetImage.Render(tx, ty);
}
}
}

_gc.Render();
}

_Tileset tilesetForGid(int gid)
{
foreach( var tileset in _tilesets )
{
var first = tileset.TmxTileset.FirstGid;
var last = first + tileset.TmxTileset.TileCount;

if( gid >= first && gid < last )
return tileset;
}

return null;
}
}


USAGE:
Code: [Select]
public class TestScene : Scene
{
public TestScene()
{
var tm = new TiledMap("path/to/your/map.tmx");
tm.SetCollisionLayer("Name of your Collision layer", YourCollisionTagEnumerator.Value);
Add(tm);

this.UseCameraBounds = true;
this.CameraBounds = new Rectangle(0,0, tm.FullWidth, tm.FullHeight);
}
}

Supports multi-tilesets too, but lacks all the other cool stuff you could have. It's very minimalistic.

...But it works:

26
Help / Re: Multipass shaders in Otter2d
« Last post by Kyle on November 02, 2016, 03:33:47 PM »
Hey!  I have time for a quick answer at the moment:  Surfaces actually have the "AddShader" method which allows them to automagically take care of each pass.  You can see how this is done around Surface.cs Line 561, and implement this yourself if you want, or if you're using a Surface already you should be able to just keep adding shaders to it and have it use all of them in the order they're added.
27
Help / Multipass shaders in Otter2d
« Last post by KrissLaCross on November 01, 2016, 03:15:13 PM »
Hi!

So I'm trying to implement a basic multipass shader using this tutorial: https://gamedevelopment.tutsplus.com/tutorials/how-to-write-a-smoke-shader--cms-25587
But I'm struggling with seting up the multipass system aka "The Frame Buffer Trick".
The simpel algorithm goes as follow:
  • Pass A through your shader, render onto B.
  • Render B to the screen.
  • Pass B through shader, render onto A.
  • Render A to your screen.
  • Repeat 1.

Where A and B are either two textures or two buffers. I decided too use two Surfaces, because that makes it easier to create some cool stuf later on.
But I'm struggling with step one, I'm just not really sure how too do this in Otter2d. I tried the following:
Code: [Select]
bufferA.Shader = shader;
bufferB.Draw(bufferA);
bufferB.Render();
tempBuffer = bufferA;
bufferA = bufferB;
bufferB = tempBuffer;

using the this simpel shader:
Code: [Select]
uniform sampler2D texture;

void main() {
vec4 color = texture2D(texture, gl_TexCoord[0].xy);
color.r += 0.01;
gl_FragColor = color;
}

But sadly it doesn't work and I don't know what I'm doing wrong.

I appreciate any help!
Thanks for your time!

~KrissLaCross
28
Help / Re: Tile Pixel Manipulation
« Last post by Lycake on October 22, 2016, 09:37:40 AM »
Thanks for the quick reply!

Hm is it possible to only color the grayscale part of the sprite? Coloring the whole tile wouldn't work because I have fixed colored parts that shouldn't be tinted and stay as they are.

Oh and yes I have requested a slack invite but havn't gotten any email yet (yes I checked the spam folder)
29
Help / Re: Tile Pixel Manipulation
« Last post by Commanderstitch on October 22, 2016, 09:23:52 AM »
I usually just white/greyscale my sprites/tiles and set them to whatever color i want at runtime. That's just what i do atm. I've never tried this pixel manipulation of individual pixels since c++. Good luck with your stuff! I'll see if i can't get others to read this on the forum and check it out. Most of us are in the otterslack. join up and have a chat. we'd love to see you.
:-)
30
Help / Tile Pixel Manipulation
« Last post by Lycake on October 22, 2016, 08:38:22 AM »
Hello!

I am using a tilemap similar to the principle of the game Dwarf Fortress. It works like this: You have transparency, gray pixels, and colored pixels on the tiles. Together with the tile number, you get a foreground and a background color. The the transparency defines the amount of background color on that pixel, the gray pixels the amount of foreground color and the colored pixels are unchanged.

This makes it so you can use the same tiles for different objects in your game - colored differently. For example you can have a bucket out of copper or iron (using a reddish or gray foreground color), while having pre-colored blue water with one single bucket tile.

Now my problem is, that I need to change the gray pixels in my tiles to the foreground color (or rather merge it, because I need various degrees of foreground color brightness, depending on the darkness of the gray pixel). I can't seem to find an approach that works. I couldn't find a way to change my tiles on a pixel per pixel basis manually and my other thought was using a shader, but shaders only work on the whole tilemap and not on individual tiles. Coloring the whole tile also changes the true colors in the tiles, which should stay unchanged.

I know this forum isn't very active anymore, but I really hope someone has an idea how to solve my problem. I really like otter so far and hope I can use it with this project of mine.

Thank you,
Lycake
Pages: 1 2 [3] 4 5 ... 10