kylepulver / otter Goto Github PK
View Code? Open in Web Editor NEW2d game making framework built on top of SFML.Net
License: MIT License
2d game making framework built on top of SFML.Net
License: MIT License
Hi. I keep getting this error in the cache whenever I try to run the code below:
`using Otter;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PlayerSessions
{
class PlayerSessions
{
static void Main(string[] args)
{
// Create a game
var game = new Game("Player Sessions");
// Name the game folder for exporting session data.
game.GameFolder = "PlayerSessionDemo";
// Add a new session to the game for Player 1.
var session = game.AddSession("TestPlayer1");
// Import any data. If no data found, none will be loaded.
session.Data.Import();
// Load data, or set default values.
// Using strings for keys here, but you can also use Enums!
session.Data.GetIntOrDefault("LevelsUnlocked", 0);
session.Data.GetStringOrDefault("LeaderboardName", "Player");
session.Data.GetBoolOrDefault("InvertedControls", false);
session.Data.GetStringOrDefault("PlayerColor", "FF0000");
session.Data.GetFloatOrDefault("StartPosition", 0.25f);
// Export the data to a semi-encrypted file.
session.Data.Export();
// Configure the Controller for the player session.
// Add a "Left" button
session.Controller.AddButton("Left");
// Set the button to respond to the A key.
session.Controller.Button("Left").AddKey(Key.A);
// Add a "Right" button
session.Controller.AddButton("Right");
// Set the button to respond to the D key.
session.Controller.Button("Right").AddKey(Key.D);
// Add a new session to the game for Player 2.
session = game.AddSession("TestPlayer2");
// Import any data. If no data found, none will be loaded.
session.Data.Import();
// Load data, or set default values.
// Using strings for keys here, but you can also use Enums!
session.Data.GetIntOrDefault("LevelsUnlocked", 0);
session.Data.GetStringOrDefault("LeaderboardName", "Player");
session.Data.GetBoolOrDefault("InvertedControls", false);
session.Data.GetStringOrDefault("PlayerColor", "0000FF");
session.Data.GetFloatOrDefault("StartPosition", 0.75f);
// Export the data to a semi-encrypted file.
session.Data.Export();
// Configure the Controller for the player session.
// Add a "Left" button
session.Controller.AddButton("Left");
// Set the button to respond to the Left key.
session.Controller.Button("Left").AddKey(Key.Left);
// Add a "Right" button
session.Controller.AddButton("Right");
// Set the button to respond to the Right key.
session.Controller.Button("Right").AddKey(Key.Right);
// Create a Scene.
var scene = new Scene();
// Add a Player Entity for each session.
scene.Add(new Player(game.Session("TestPlayer1")));
scene.Add(new Player(game.Session("TestPlayer2")));
// Start the Game.
game.Start(scene);
}
}
class Player : Entity
{
// Create a test image.
Image image = Image.CreateRectangle(40, Color.White);
// The Session that this Entity will reference.
Session session;
public Player(Session session) : base()
{
// Keep track of the Session passed in by the constructor.
this.session = session;
// Set the starting position.
// Using Game.Instance here because the Entity doesn't have a reference to the Game yet.
X = Game.Instance.HalfWidth;
Y = Game.Instance.Height * session.Data.GetFloat("StartPosition");
// Add the image.
AddGraphic(image);
// Center the origin of the image.
image.CenterOrigin();
// Set the image color from the Session data.
// Using a string for the key, but you can also use Enum!
image.Color = new Color(session.Data.GetString("PlayerColor"));
}
public override void Update()
{
base.Update();
// Use the Session controller to control the movement.
// Using a string for the key, but you can also use Enum!
if (session.Controller.Button("Left").Down)
{
X -= 3;
}
if (session.Controller.Button("Right").Down)
{
X += 3;
}
}
}
}`
I've noticed one of the project goals is to make this cross-platform. A great way to achieve your goal is to target .Net Core and target the 2.5 version NuGet package of SFML.Net to get rid of the messy dlls. I've started a branch, hoping to get a pull request done by the end of the weekend.
The Otter code should be, at least, logically namespaced based on the folders. I.e., Otter.OgmoPlayer() should be Otter.Utility.OgmorPlayer(). Would make things easier in the future to avoid code collision. Also, it would avoid some of the possible code collisions with SFML's namespaces. For example, Otter.Shader and SFML.Graphics.Shader.
Any idea to see SFML 2.5 supported and make Otter2d a NuGet package as well?
Since you are no longer working on Otter, why don't you archive it? You have no notice on the GitHub page, but you do on the website.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.