Hello Guest

Recent Posts

Pages: 1 [2] 3 4 ... 10
11
Help / Re: Multiple graphics in one Entity - location question
« Last post by badman on February 21, 2017, 07:58:37 AM »
spritemap.SetPosition(0f, image.Height);
12
Help / Multiple graphics in one Entity - location question
« Last post by bacek on February 20, 2017, 07:12:52 AM »
Hello.
At first, thank you for simple and fast library.
I've got a question about multiple graphics. I have a spaceship sprite and a flame animation. They are always together, so I decide to add both graphics into one entity.
How can I change the location of flame? AddGraphics have no x,y arguments. I could use 2 entities, but in that case I'll need to change coordinates of flame manually when ship moves.
Here's constructor of my object
Code: [Select]

public Player() : base(Game.Instance.HalfWidth, Game.Instance.HalfHeight)
        {
            var img = new Image("Resources/player.png");
            img.CenterOrigin();
            AddGraphics(img);

            Spritemap<Animation> spritemap;
            spritemap = new Spritemap<Animation>("Resources/flame.png", 32, 64);
            spritemap.Add(0, "0,1,2,3,4,5,6,7", 10);
            spritemap.CenterOrigin();
            spritemap.Play(Animation.fire, true);
            AddGraphics(spritemap);
        }

What I see and what I need:

Thank you.
13
General / MonoDevelop - Fedora 25 - mono 4.8.0
« Last post by mythcat on February 18, 2017, 10:46:52 AM »
I need help with Fedora 25 linux , mono version 4.8.0 with this source code:
Code: [Select]
using Otter;

namespace otter_001
{
class Player : Entity
{
public Player(float x, float y) : base(x, y)
{
this.AddGraphic(Image.CreateCircle(120, Color.Red));
}
}


class Program
{
static void Main(string[] args)
{
Game game = new Game();
game.Color = Color.White;

Scene scene = new Scene();

Entity entity1 = new Player(0,0);
scene.Add(entity1);

game.Start(scene);
}
}
}
using MonoDevelop with Otter package
the result is this:
Code: [Select]
Debug]$ mono otter_001.exe

Unhandled Exception:
System.DllNotFoundException: csfml-graphics-2
  at (wrapper managed-to-native) SFML.Graphics.VertexArray:sfVertexArray_create ()
  at SFML.Graphics.VertexArray..ctor (SFML.Graphics.PrimitiveType type) [0x00000] in <4627602695ae459198965b45eda5cf65>:0
  at Otter.Graphic..ctor () [0x00000] in <671bea10edbe4cdca82eebf0945869ac>:0
  at Otter.Image..ctor () [0x00000] in <671bea10edbe4cdca82eebf0945869ac>:0
  at Otter.Surface..ctor (System.Int32 width, System.Int32 height, Otter.Color color) [0x0001d] in <671bea10edbe4cdca82eebf0945869ac>:0
  at Otter.Surface..ctor (System.Int32 width, System.Int32 height) [0x00008] in <671bea10edbe4cdca82eebf0945869ac>:0
  at Otter.Game..ctor (System.String title, System.Int32 width, System.Int32 height, System.Int32 targetFramerate, System.Boolean fullscreen) [0x0030e] in <671bea10edbe4cdca82eebf0945869ac>:0
  at otter_001.Program.Main (System.String[] args) [0x00001] in <30890a970f3947e19de2283312e9da8c>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: csfml-graphics-2
  at (wrapper managed-to-native) SFML.Graphics.VertexArray:sfVertexArray_create ()
  at SFML.Graphics.VertexArray..ctor (SFML.Graphics.PrimitiveType type) [0x00000] in <4627602695ae459198965b45eda5cf65>:0
  at Otter.Graphic..ctor () [0x00000] in <671bea10edbe4cdca82eebf0945869ac>:0
  at Otter.Image..ctor () [0x00000] in <671bea10edbe4cdca82eebf0945869ac>:0
  at Otter.Surface..ctor (System.Int32 width, System.Int32 height, Otter.Color color) [0x0001d] in <671bea10edbe4cdca82eebf0945869ac>:0
  at Otter.Surface..ctor (System.Int32 width, System.Int32 height) [0x00008] in <671bea10edbe4cdca82eebf0945869ac>:0
  at Otter.Game..ctor (System.String title, System.Int32 width, System.Int32 height, System.Int32 targetFramerate, System.Boolean fullscreen) [0x0030e] in <671bea10edbe4cdca82eebf0945869ac>:0
  at otter_001.Program.Main (System.String[] args) [0x00001] in <30890a970f3947e19de2283312e9da8c>:0 
14
General / Re: Physics engine ?
« Last post by travismix1980 on January 29, 2017, 04:01:25 PM »
This may work for a physics system.  https://github.com/netonjm/ChipmunkSharp box2d also has c# bindings.
15
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
16
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. :-)
17
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
18
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.
19
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:

20
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.
Pages: 1 [2] 3 4 ... 10