Jump to content
  • Advertisement

KevinWang

Member
  • Content Count

    14
  • Joined

  • Last visited

Community Reputation

102 Neutral

About KevinWang

  • Rank
    Member
  1. Feds are pushing for SOPA and censorship, MegaUpload gets downed by the US Gov. for anti-piracy related reasons. Doesn't this worry you? Bounds are getting overstepped, and I am (for the first time ever) genuinely concerned about the direction of the US. The spirit of democracy lies on the principle "we are government", yet I see the people underrepresented and goddammitiwanttowatchmyanime #RIPMegaVideo T.T
  2. I'm looking for a great full-featured 2d/3d game engine (high-level rendering, physics, animations, etc.). So far, my progress with SFML and OGRE have been slow, and I'm looking to rewrite my application (an IDE) on top of a high level full-featured engine. XNA based seems very attractive, but is not a requirement. I would like as little red tape as possible (a very very permissive license, allowing users to create and distribute applications developed by my application. Not necessarily free, but free and open source usually satisfies the categories). The language of choice would be C#. Here are a couple that seem very attractive to me: Synapse SunBurn Engine (afraid of licensing issues) <- Most attractive Tomahawk (XNA based engine, no 4.0 support. 3D only, but probably could be used for some 2D rendering) Ox (Another XNA based engine. Outdated.) Any ideas?
  3. You could implement some sort of texture system and stretch textures based off of the skeleton of your character. Another alternative is going for a fake-2.5d type game and creating a 3d customizable model with 2d-like animations, no shading, and etc.
  4. Hey everyone, 3D Graphics for me has always been a large grey area that I've always wanted to explore. I know close to nothing about it, and through numerous attempts of learning have failed because the resources didn't fit my needs. Anyone have a recommendation for some GREAT references that can take me from a beginner level to moderate solidly? Thanks guys.
  5. I was watching this video: When it came to my mind what went into making all of these different patterns. Out of curiosity, what's the usual method of generating these patterns?
  6. I agree. It's all about breaking it down and building the small bits of it. I doubt you'll find an in-depth tutorial on how to make the game _______, but there are tons of tutorials that teach little bits of it. I would start by picking a language and an engine (for python, pyGame and panda3D are always good choices). Then I would start asking questions. For example, what goes into galaxyMage? You see a 2D menu system, drawing sprites in 3D space, a 3D tile-based map, lighting, and etc. Well there you go, already you have some google keywords to start you off.
  7. KevinWang

    Going online

    This is funny to me because years ago I went through a maplestory phase and after I quit, I decided to fill the void by making a clone of it, haha.
  8. KevinWang

    Melee Weapons in a 2D Top Down Shooter

    If you have projectile objects, why not make the melee attack a projectile as well? Just one, large, static projectile in front of the player that has a set fade-time.
  9. Thanks for the reply. I will keep that in mind. However, the problem isn't the need to tweak the code after generation, but it is that I don't know that I don't know, meaning if someone points out inefficiencies in my application I will learn more about it and tweak the generator to generate better code. Essentially, I am asking, am I doing it right? Thanks, Kevin.
  10. KevinWang

    Newbie Programming Help.

    If you don't know programming this is the route I would take: Python -> Java or C# -> C++ If you want to start out in python, there are tons of GREAT 2D game engines for you to use perfect for your adventure game. Here's a link to some: http://codeboje.de/2d-game-engines-python/
  11. [font=arial, verdana, tahoma, sans-serif][size=2]So I am essentially making software that writes code, and I feel like there are many improvements I can make to the engine. Here is an example of code that it generates, written in C#. I wanted to implement 2D and 3D (OGRE and SFML). Embarrassingly, I am not that familiar with the typical way of approaching this (creating an engine behind a game from scratch). One of the big things that I am concerned with is how the application is not fixed onto a certain FPS (which can be configured, but I am debating on the best way to do it). I am sure there are many other optimization to this code, but in order to maintain the general structure (as I have to keep it generic for any type of application), what are some of the major concerns or fix-ups you would recommend? /* * Code generated by Gravity Game Studio * ------------------------------------- * Blah Blah Blah cool */ using System; using SFML; using SFML.Audio; using SFML.Graphics; using SFML.Window; using Tao.OpenGl; using System.Data; using System.IO; using System.Linq; using System.Text; using System.Reflection; using System.Collections; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Mogre; using MOIS; [assembly: AssemblyTitle("Gravity Game Studio Game")] [assembly: AssemblyDescription("This is a description.")] [assembly: AssemblyCompany("Gravity Collective")] [assembly: AssemblyProduct("Gravity Game Studio Game")] [assembly: AssemblyCopyright("Copyright © 2010 Gravity Collective")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] namespace Gravity { class Game { [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)] public static extern bool FreeConsole(); public static Root mRoot; public static System.Random randomGenerator = new System.Random(); //public static RaySceneQuery mSceneRay; public static Mogre.RenderWindow OGREWin; public static tempClass currentEnviro = new tempClass(); public static List<tempClass> objList = new List<tempClass>(); public static List<Music> musicList = new List<Music>(); public static List<Sound> soundList = new List<Sound>(); public static List<System.Type> timeLine = new List<System.Type>() { }; public static Dictionary<string, object> globalVars = new Dictionary<string, object>(); public static SFML.Graphics.Vector2 cameraShift = new SFML.Graphics.Vector2(0, 0); public static Color bgcol = new Color(); public static int renderState = 0; //0-2D, 1-3D public static bool globalPressed = false; public static SFML.Graphics.RenderWindow SFMLWin; public static MOIS.InputManager inputManager; public static MOIS.Keyboard inputKeyboard; public static MOIS.Mouse inputMouse; public Game() { mRoot = new Root(); RenderSystem renderSystem = mRoot.GetRenderSystemByName("Direct3D9 Rendering Subsystem"); renderSystem.SetConfigOption("Full Screen", "No"); mRoot.RenderSystem = renderSystem; // Create Render Window if (mRoot != null) { mRoot.Initialise(false, "OGREWin"); NameValuePairList misc = new NameValuePairList(); //misc["externalWindowHandle"] = this.Handle.ToString(); misc["border"] = "fixed"; OGREWin = mRoot.CreateRenderWindow("Gravity Game Studio Game", 320, 320, false, misc); } MOIS.ParamList pl = new MOIS.ParamList(); pl.Insert("w32_mouse", "DISCL_NONEXCLUSIVE"); pl.Insert("w32_mouse", "DISCL_FOREGROUND"); IntPtr hwnd; OGREWin.GetCustomAttribute("WINDOW", out hwnd); pl.Insert("WINDOW", hwnd.ToString()); inputManager = MOIS.InputManager.CreateInputSystem(pl); inputKeyboard = (MOIS.Keyboard)inputManager.CreateInputObject(MOIS.Type.OISKeyboard, true); inputMouse = (MOIS.Mouse)inputManager.CreateInputObject(MOIS.Type.OISMouse, true); //mRoot.FrameStarted+=new FrameListener.FrameStartedHandler(MainDraw); if (inputKeyboard != null) { inputKeyboard.KeyPressed += new MOIS.KeyListener.KeyPressedHandler(OnKeyPressed); inputKeyboard.KeyReleased += new MOIS.KeyListener.KeyReleasedHandler(OnKeyReleased); } if (inputMouse != null) { inputMouse.MousePressed += new MOIS.MouseListener.MousePressedHandler(OnMousePressed); inputMouse.MouseReleased += new MOIS.MouseListener.MouseReleasedHandler(OnMouseReleased); inputMouse.MouseMoved += new MOIS.MouseListener.MouseMovedHandler(OnMouseMove); } SFMLWin = new SFML.Graphics.RenderWindow(hwnd); //SFMLWin = new SFML.Graphics.RenderWindow(new VideoMode(320,320),"Gravity Game"); SFMLWin.PreserveOpenGLStates(true); SFMLWin.Closed += new EventHandler(OnClosed); SFMLWin.Resized += new EventHandler<SizeEventArgs>(OnResized); //SFMLWin.UseVerticalSync(true); Gl.glEnable(Gl.GL_DEPTH_TEST); Gl.glDepthMask(Gl.GL_TRUE); Gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); Gl.glClearDepth(1.0F); Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glLoadIdentity(); Glu.gluPerspective(90.0F, 1.0F, 1.0F, 500.0F); objList.Add(new Base()); OGREWin.SetVisible(false); while (SFMLWin.IsOpened() && !OGREWin.IsClosed) { SFMLWin.DispatchEvents(); inputKeyboard.Capture(); inputMouse.Capture(); OnCollision(); OnKeyHold(); MainDraw(); WindowEventUtilities.MessagePump(); } } public static bool MainDraw() { if (Game.currentEnviro.is3D) { mRoot.RenderOneFrame(); } else { SFMLWin.Clear(bgcol); Gl.glViewport(0, 0, (int)SFMLWin.Width, (int)SFMLWin.Height); Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); SFMLWin.CurrentView.Move(cameraShift); cameraShift = new SFML.Graphics.Vector2(0, 0); currentEnviro.Draw(); for (int i = 0; i < objList.Count; i++) { if (objList.visible && objList.resources.ContainsKey("imgmain")) //if image in inside of window... { SFMLWin.Draw((Sprite)objList.resources["imgmain"]); } objList.Draw();//call the draw function of the object if it exists (if it does, it will be added to the list) } //SFMLWin.Draw(new String2D("asd")); SFMLWin.Display(); //Game.OGREWin.Update(); //System.Windows.Forms.DevExpress.XtraEditors.XtraMessageBox.Show("asdfgh"); } return true; } static void Main() { FreeConsole(); new Game(); } static void OnClosed(object sender, EventArgs e = null) { refClass.stopAllMusic(); refClass.stopAllSounds(); SFML.Graphics.RenderWindow window = (SFML.Graphics.RenderWindow)sender; window.Close(); } static bool OnMousePressed(MOIS.MouseEvent e, MOIS.MouseButtonID button) { IntRect bbox; Sprite mObj; for (int i = 0; i < objList.Count; i++) { if (objList.resources.ContainsKey("imgmain")) { mObj = ((Sprite)objList.resources["imgmain"]); bbox = new IntRect((int)mObj.Position.X, (int)mObj.Position.Y, (int)mObj.Position.X + (int)mObj.Width, (int)mObj.Position.Y + (int)mObj.Height); if (bbox.Contains(e.state.X.abs, e.state.Y.abs)) { objList.MousePress(e.state, button); } } } return true; } static bool OnMouseReleased(MOIS.MouseEvent e, MOIS.MouseButtonID button) { IntRect bbox; Sprite mObj; for (int i = 0; i < objList.Count; i++) { if (objList.resources.ContainsKey("imgmain")) { mObj = ((Sprite)objList.resources["imgmain"]); bbox = new IntRect((int)mObj.Position.X, (int)mObj.Position.Y, (int)mObj.Position.X + (int)mObj.Width, (int)mObj.Position.Y + (int)mObj.Height); if (bbox.Contains(e.state.X.abs, e.state.Y.abs)) { objList.MouseRelease(e.state, button); } } } return true; } static bool OnKeyPressed(MOIS.KeyEvent e) { for (int i = 0; i < objList.Count; i++) { objList.KeyPress(e.key); } return true; } static bool OnKeyHold() { for (int i = 0; i < objList.Count; i++) { foreach (MOIS.KeyCode key in Enum.GetValues(typeof(MOIS.KeyCode))) { if (inputKeyboard.IsKeyDown(key)) objList.KeyHold(key); } } return true; } static bool OnKeyReleased(MOIS.KeyEvent e) { for (int i = 0; i < objList.Count; i++) { objList.KeyRelease(e.key); } return true; } static bool OnMouseMove(MOIS.MouseEvent e) { return true; } static void OnResized(object sender, SizeEventArgs e) { Gl.glViewport(0, 0, (int)e.Width, (int)e.Height); SFMLWin.CurrentView.SetFromRect(new SFML.Graphics.FloatRect(0.0f, 0.0f, SFMLWin.Width, SFMLWin.Height)); } static bool OnCollision() { IntRect coll, ocoll; Sprite mObj, oObj; for (int i = 0; i < objList.Count; i++) { if (objList.resources.ContainsKey("imgmain")) { for (int q = 0; q < objList.Count; q++) { if (objList[q].resources.ContainsKey("imgmain")) { mObj = ((Sprite)objList.resources["imgmain"]); oObj = ((Sprite)objList[q].resources["imgmain"]); coll = new IntRect((int)mObj.Position.X, (int)mObj.Position.Y, (int)mObj.Position.X + (int)mObj.Width, (int)mObj.Position.Y + (int)mObj.Height); ocoll = new IntRect((int)oObj.Position.X, (int)oObj.Position.Y, (int)oObj.Position.X + (int)oObj.Width, (int)oObj.Position.Y + (int)oObj.Height); if (coll.Intersects(ocoll)) { objList.Collision(objList[q]); } } } } } return true; } } static class refClass { public static void newObject(string objectName, int x = 0, int y = 0, string functionName = "", string[] args = null) { /*Title: New Object Description: Creates a new instance of an object.*/ System.Type objType = System.Type.GetType("Gravity." + objectName.Trim()); if (objType != null) { tempClass newObj = (tempClass)Activator.CreateInstance(objType); newObj.X = x; newObj.Y = y; Game.objList.Add(newObj); if (objType.GetMethod(functionName) != null) { objType.InvokeMember(functionName, BindingFlags.Default | BindingFlags.InvokeMethod, null, newObj, args); } } } public static void setEnviro(string enviroName) { /*Title: Set Environment Description: Sets the current game environment.*/ } public static void drawString2D(string drawStr) { /*Title: Draw Text Description: Draws text to the screen.*/ String2D drawString = new String2D(drawStr); Game.SFMLWin.Draw(drawString); } public static void setImage(tempClass obj, string filepath) { /*Title: Set Image Description: Sets the display image of the object.*/ try { Sprite img = new Sprite(new SFML.Graphics.Image(Directory.GetCurrentDirectory() + @"\" + filepath)); //img.Center = new SFML.Graphics.Vector2(img.Width / 2, img.Height / 2); img.Image.Smooth = false; if (!obj.resources.ContainsKey("imgmain")) { obj.resources.Add("imgmain", img); } else { obj.resources["imgmain"] = img; } obj.bbox = new SFML.Graphics.FloatRect(img.Position.X, img.Position.Y, img.Position.X + img.Width, img.Position.Y + img.Height); } catch (Exception e) { e.ToString(); return; } } public static void moveToPoint(tempClass obj, float x, float y) { /*Title: Move to Point Description: Instantly moves object to a certain X, Y point.*/ obj.X = x; obj.Y = y; } public static void setWindowSize(uint width, uint height) { /*Title: Set Window Size Description: Sets the window size.*/ Game.OGREWin.SetVisible(true); Game.SFMLWin.SetSize(width, height); MOIS.MouseState_NativePtr mouseState = Game.inputMouse.MouseState; mouseState.width = (int)width; mouseState.height = (int)height; } public static void setVisible(tempClass obj, bool isVisible) { /*Title: Set Visible Description: Sets if the object is visible (true) or invisible (false).*/ obj.visible = isVisible; } public static void shiftCamera(float horizontal, float vertical) { /*Title: Shift Camera Description: Shifts camera by a certain horizontal and vertical factor.*/ Game.cameraShift = new SFML.Graphics.Vector2(horizontal, vertical); } public static void drawMapData(tempClass sourceObj, string mapData) { /*Title: Draw Map Data Description: Draws map from map data.*/ if (mapData != "") { string[] data = mapData.Split('); string[] tiles = data[4].Split('!'); int twidth = Convert.ToInt32(data[0]); int theight = Convert.ToInt32(data[1]); Sprite drawSpr = (Sprite)sourceObj.resources["imgmain"]; //drawSpr.Width = Convert.ToInt32(data[2]) * twidth; //drawSpr.Height = Convert.ToInt32(data[3]) * theight; drawSpr.Width = twidth; drawSpr.Height = theight; drawSpr.Scale = new SFML.Graphics.Vector2(1.0f, 1.0f); foreach (string tile in tiles) { string[] tileInfo = tile.Split('%'); if (!sourceObj.resources.ContainsKey(tileInfo[4])) { sourceObj.resources.Add(tileInfo[4], new Sprite(new SFML.Graphics.Image(tileInfo[4]))); } drawSpr = (Sprite)sourceObj.resources[tileInfo[4]]; drawSpr.Position = new SFML.Graphics.Vector2((float)Convert.ToInt32(tileInfo[0]) * (float)twidth, (float)Convert.ToInt32(tileInfo[1]) * (float)theight); drawSpr.SubRect = new IntRect((int)Convert.ToInt32(tileInfo[2]), (int)Convert.ToInt32(tileInfo[3]), (int)Convert.ToInt32(tileInfo[2]) + (int)twidth, (int)Convert.ToInt32(tileInfo[3]) + (int)theight); drawSpr.BlendMode = BlendMode.None; //drawSpr.SubRect = new IntRect(0, 0, 32, 32); drawSpr.Image.Smooth = false; Game.SFMLWin.Draw(drawSpr); } } } public static void setBackgroundColor(byte r = 255, byte g = 255, byte b = 255) { /*Title: Set Background Color Description: Sets the background color of the Application.*/ Game.bgcol.R = r; Game.bgcol.G = g; Game.bgcol.B = b; } public static void drawBackgroundImage(string bgImg, int bgtype = 0) { int parX = (int)Game.SFMLWin.CurrentView.GetRect().Left; int parY = (int)Game.SFMLWin.CurrentView.GetRect().Top; int parW = (int)Game.SFMLWin.Width; int parH = (int)Game.SFMLWin.Height; Sprite bgSpr = new SFML.Graphics.Sprite(); bgSpr.Image = new SFML.Graphics.Image(bgImg); bgSpr.Position = new SFML.Graphics.Vector2(parX, parY); switch (bgtype) { case 0: Game.SFMLWin.Draw(bgSpr); break; case 1: //repeat x for (int i = (int)System.Math.Floor(parX / bgSpr.Width); i < System.Math.Ceiling(parW / bgSpr.Width) + (int)System.Math.Ceiling(parX / bgSpr.Width); i++) { bgSpr.Position = new SFML.Graphics.Vector2(bgSpr.Width * i, 0); Game.SFMLWin.Draw(bgSpr); } break; case 2: //repeat y for (int i = (int)System.Math.Floor(parY / bgSpr.Height); i < System.Math.Ceiling(parH / bgSpr.Height) + (int)System.Math.Ceiling(parY / bgSpr.Height); i++) { bgSpr.Position = new SFML.Graphics.Vector2(0, bgSpr.Height * i); Game.SFMLWin.Draw(bgSpr); } break; case 3: //repeat xy for (int q = 0; q < System.Math.Ceiling(parH / bgSpr.Height); q++) { for (int i = 0; i < System.Math.Ceiling(parW / bgSpr.Width); i++) { bgSpr.Position = new SFML.Graphics.Vector2(bgSpr.Width * i, bgSpr.Height * q); Game.SFMLWin.Draw(bgSpr); } } break; case 4: //stretch bgSpr.Scale = new SFML.Graphics.Vector2(parW / bgSpr.Width, parH / bgSpr.Height); Game.SFMLWin.Draw(bgSpr); break; case 5: //scale float setScale = (parW > parH ? setScale = parW / bgSpr.Width : parH / bgSpr.Height); bgSpr.Scale = new SFML.Graphics.Vector2(setScale, setScale); Game.SFMLWin.Draw(bgSpr); break; } } public static void testMove(tempClass obj) { obj.X = 0; obj.Y = 0; } public static void moveLeft(tempClass obj, double amount) { obj.X -= (float)amount; } public static void moveRight(tempClass obj, double amount) { obj.X += (float)amount; } public static void playMusic(string filepath, int volume = 100, bool loop = true) { /*Title: Play Music Description: Play or loop audio at any volume.*/ Music ms = new Music(filepath); ms.Loop = loop; ms.Volume = volume; ms.Play(); Game.musicList.Add(ms); } public static void stopAllMusic() { /*Title: Stop All Music Description: Stops all ongoing music.*/ foreach (Music ms in Game.musicList) { ms.Stop(); } } public static void stopAllSounds() { /*Title: Stop All Sounds Description: Stops all ongoing sounds.*/ foreach (Sound ms in Game.soundList) { ms.Stop(); } } public static void defineLocalVariable(this tempClass obj, string varName, object value) { /*Title: Define Local Value Description: Defines a certain variable for later use (local to the object).*/ obj.variables.Add(varName, value); } public static void setLocalVariable(this tempClass obj, string varName, object value) { /*Title: Set Local Value Description: Sets a previously defined value (local to the object).*/ obj.variables[varName] = value; } public static void defineGlobalVariable(string varName, object value) { /*Title: Define Global Value Description: Sets a previously defined value (global).*/ Game.globalVars.Add(varName, value); } public static void setGlobalVariable(string varName, object value) { /*Title: Set Global Value Description: Sets a previously defined value (global).*/ Game.globalVars[varName] = value; } public static void setupBasicMechanics(this tempClass obj) { if (!obj.variables.ContainsKey("bm_setup")) { obj.variables.Add("bm_gravity", 0); obj.variables.Add("bm_angle", 0); obj.variables.Add("bm_hspeed", 0); obj.variables.Add("bm_vspeed", 0); obj.variables.Add("bm_setup", true); } } public static void bm_update(this tempClass obj) { if (obj.variables.ContainsKey("bm_setup")) { obj.variables["bm_vspeed"] = (int)obj.variables["bm_vspeed"] + (int)obj.variables["bm_gravity"]; } } public static void bm_moveDir(this tempClass obj, float angle, float amount) { /*Title: Move at Angle Description: Moves the object in the direction of an angle.*/ double radians = angle / (180 / System.Math.PI); obj.X += (float)(System.Math.Cos(radians) * amount * Game.SFMLWin.GetFrameTime()); obj.Y += (float)(System.Math.Sin(radians) * amount * Game.SFMLWin.GetFrameTime()); } public static void bm_moveUp(this tempClass obj, float amount) { /*Title: Move Up Description: Moves the object upwards an amount.*/ obj.Y -= amount; } public static void bm_moveDown(this tempClass obj, float amount) { /*Title: Move Down Description: Moves the object downwards an amount.*/ obj.Y += amount; } public static void bm_moveLeft(this tempClass obj, float amount) { /*Title: Move Left Description: Moves the object left an amount.*/ obj.X -= amount; } public static void bm_moveRight(this tempClass obj, float amount) { /*Title: Move Right Description: Moves the object right an amount.*/ obj.X += amount; } public static void bm_rotate(this tempClass obj, float angle) { /*Title: Rotate Description: Rotates the object a certain degrees counter-clockwise.*/ if (obj.resources.ContainsKey("imgmain")) { Sprite rotateObj = (Sprite)obj.resources["imgmain"]; rotateObj.Rotation += angle; } } public static void timeline_next() { /*Title: Next Environment Description: Advances to the next environment on the timeline.*/ if (Game.currentEnviro != null && Game.timeLine.Contains(Game.currentEnviro.GetType()) && Game.currentEnviro.GetType() != Game.timeLine.Last().GetType()) { int curIndex = Game.timeLine.IndexOf(Game.currentEnviro.GetType()); Game.currentEnviro.Dispose(true); foreach (tempClass g_inobj in Game.objList) { g_inobj.Dispose(true); //if object is not persistent Game.objList.Remove(g_inobj); } Game.currentEnviro = (tempClass)Activator.CreateInstance(Game.timeLine[curIndex + 1]); } } public static void timeline_prev() { /*Title: Previous Environment Description: Steps back to the previous environment on the timeline.*/ if (Game.currentEnviro != null && Game.timeLine.Contains(Game.currentEnviro.GetType()) && Game.currentEnviro.GetType() != Game.timeLine.First().GetType()) { int curIndex = Game.timeLine.IndexOf(Game.currentEnviro.GetType()); Game.currentEnviro.Dispose(true); foreach (tempClass g_inobj in Game.objList) { g_inobj.Dispose(true); //if object is not persistent Game.objList.Remove(g_inobj); } Game.currentEnviro = (tempClass)Activator.CreateInstance(Game.timeLine[curIndex - 1]); } } public static void drawImage() { } public static void drawLine() { } public static void drawPolygon() { } public static void drawCircle() { } } class tempClass { //instead of draw tile info, load tile info then draw later public Dictionary<string, object> variables = new Dictionary<string, object>(); public Dictionary<string, object> resources = new Dictionary<string, object>(); public bool visible = true; public bool is3D = false; public SFML.Graphics.FloatRect bbox = new SFML.Graphics.FloatRect(); public float x = 0.0f; private bool _disposed = false; public float y = 0.0f; public float X { get { return x; } set { x = value; updatePos(); } } public float Y { get { return y; } set { y = value; updatePos(); } } public virtual void Draw() { } public virtual void KeyPress(MOIS.KeyCode keyid) { } public virtual void KeyHold(MOIS.KeyCode keyid) { } public virtual void KeyRelease(MOIS.KeyCode keyid) { } public virtual void MousePress(MouseState_NativePtr mouse, MouseButtonID mid) { } public virtual void MouseRelease(MouseState_NativePtr mouse, MouseButtonID mid) { } public virtual void Collision(tempClass other) { } public virtual void Dispose(bool disposing) { this.Destroy(); if (!_disposed) { if (disposing) { if (variables != null) variables = null; if (resources != null) resources = null; visible = false; if (Game.objList.Contains(this)) Game.objList.Remove(this); if (Game.currentEnviro == this) Game.currentEnviro = null; } _disposed = true; } } public virtual void Destroy() { } private void updatePos() { if (this.resources.ContainsKey("imgmain")) { ((Sprite)this.resources["imgmain"]).Position = new SFML.Graphics.Vector2(x, y); this.bbox.Left = x; this.bbox.Top = y; } } } class Base : tempClass { public Base() { } } } Thanks GameDev, Kevin. Some info on the code: I use OGRE's window as the main window and pass its handle to SFML for 2D drawing. refClass is just a library of functions that the app uses (this is one of the non-changing structures that has to stay the way it is) tempClass is the base "template class" of all objects in the application. It's like the "object" of this app. variables are stored in dictionaries to preserve generic stuff (I'm not sure if this is such a good idea, perhaps due to speed and ease-of-access issues) Ignore FreeConsole() for now. That's just the remnants of old stuff that I haven't gotten rid of yet. The game runs through the main while loop, where events are dispatched along with drawing.[/font]
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!