Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

829 Good

About Enselic

  • Rank
  1. Quote:Original post by MrMark Quote:Original post by Jaiminho Not really... Ogre is full of singletons. Yes...and ? Singletons are a very useful design pattern when dealing with manager like classes. Singletons might be useful, but that does not make them good. The problem with Singletons is that a singleton module is reachable from everywhere else. If your sound system was a singleton then your map-loading code could play sound. That's obviously a bad design choice since the map loading code should not be able to play sound as that breaks modularity and code isolation.
  2. Enselic

    Linux on laptops

    Quote:Original post by Valderman How is Linux power management on laptops? Last I heard, Windows had Linux completely beaten in this aspect, though that was more than a year ago. I'm using the latest Ubuntu 6.10 (Edgy Eft) on a Intel 915GM based laptop, and power management works perfectly. The only thing I have troubles with is getting the infrared port and the built in card-readers (SD cards etc) to work. The brand is scandinavian, more specifically its a Zepto Znote 4015.
  3. Enselic

    References vs Pointers

    I like this rule: Avoid pointers in the public interface of a class.
  4. Enselic

    GDI C# Help

    If you want me to clarify or elaborate my hasty written post, feel free to ask.
  5. Enselic

    GDI C# Help

    You probably don't want to use GDI directly if you use C#. For C# (in Windows) you should go with the System.Drawing namespace. - How to make maps To make a map, you need a way of representing the map in code. For instance, if we want our maps to consist of a simple grid (for a simple Snake game for example) we could represent a map with a grid of numbers, where 0 represents "not a wall" and 1 represents "a wall". Something like public class SnakeMap { private int width; private int heightM private int mapData[][]; public SnakeMap(int width, int height) { this.width = width; this.height = height; mapData = new int[width][height]; } punlic void CreateMap( /* Pass map data */ ) { // Use the passed mape data to initialize the map arrray } } - How to move a picture box with image or bitmap file Well, if you want to make a somewhat serious attempt at a game, you should try to render the graphics onto a single device (which is much more similar to the way you do rendering in DirectX or OpenGL), instead of creating lots of instances of Bitmaps and moving those around. Refer to the documentation of System.Drawing and you will find how to do this. - To move on a grid and not be able to walk through walls on that grid You could for example have a method on your map class that tests for collions. For a simple Snake game, we could add a method to the SnakeMap that would look something like public bool IsWall(int x, int y) { return mapData[x][y] == 1; } and then use this method when we update the snake, to see if it has collided with a wall.
  6. I have finally realized that I will not have time to finish my C#/MDX game I started almost two years ago in the next few years, therefore I have decided to release it as-is (thought it is very playable as it is now). The game offers neat physics and a separate game and game engine, both written in C#/MDX. Feel free to play around with the code; it should compile out of the box if you have Microsoft Visual C# 2005 Express Edition and MDX/.NET 2.0 SDK:s installed. The engine is based on superpig's Kernel architecture in the Enginyity series. My current code uses a naive static class approach, but I still think the code might be useful for some. Get it from or directly: Here a sample source file (Kernel.cs) // +---------------------------------------------------------------------------+ // // Copyright © 2006 Martin Nordholts. All rights reserved. // Website: // // // File: Kernel.cs // Created: 2005-10-23 // // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // +---------------------------------------------------------------------------+ using System; using System.Collections.Generic; namespace Chrocodile { /// <remarks> /// The Kernel is the heart of the engine. /// As long as the taskList contains tasks, it will continue to /// call Update() on these tasks. It automaticly removes tasks /// which have the CanKill property set to true. /// </remarks> public static class Kernel { /// <summary> /// Kicks off the main loop, /// which is run until there are no tasks left to Update() /// </summary> static public void Execute() { while (taskList.Count > 0) { for (LinkedListNode<AbstractTask> taskListNode = taskList.First; taskListNode != null; taskListNode = taskListNode.Next) { if (!taskListNode.Value.CanKill) { taskListNode.Value.Update(); } } for (LinkedListNode<AbstractTask> taskListNode = taskList.First; taskListNode != null; taskListNode = taskListNode.Next) { if (taskListNode.Value.CanKill) { taskListNode.Value.Stop(); taskList.Remove(taskListNode); } } } } /// <summary> /// Adds a given task to the Kernel's taskList. Before a task is added, /// its Start()-method is called. /// </summary> /// <param name="taskToAdd">Task to add</param> /// <returns>Returns true if the task could be added to the taskList, false otherwise</returns> static public bool AddTask(AbstractTask taskToAdd) { if (!taskToAdd.Start()) return false; LinkedListNode<AbstractTask> node; for (node = taskList.First; node != null; node = node.Next) { AbstractTask task = node.Value; if (taskToAdd.Priority < task.Priority) { taskList.AddBefore(node, taskToAdd); return true; } } taskList.AddLast(taskToAdd); return true; } /// <summary> /// Suspends a given task. When a task is suspended, its /// OnSuspend()-method is called. /// </summary> /// <param name="taskToSuspend">Task to suspend</param> static public void SuspendTask(AbstractTask taskToSuspend) { if (taskList.Contains(taskToSuspend)) { taskToSuspend.OnSuspend(); taskList.Remove(taskToSuspend); suspendedTaskList.AddLast(taskToSuspend); } } /// <summary> /// Resumes a given task (which has been suspended). /// When a task is resumed, its OnResume()-method is called. /// </summary> /// <param name="taskToResume">Task to resume</param> static public void ResumeTask(AbstractTask taskToResume) { if (suspendedTaskList.Contains(taskToResume)) { taskToResume.OnResume(); suspendedTaskList.Remove(taskToResume); LinkedListNode<AbstractTask> node; for (node = taskList.First; node != null; node = node.Next) { AbstractTask task = node.Value; if (taskToResume.Priority < task.Priority) { taskList.AddBefore(node, taskToResume); return; } } taskList.AddLast(taskToResume); return; } } /// <summary> /// Removes a given task from the taskList /// </summary> /// <param name="taskToKill">Task to remove</param> static public void KillTask(AbstractTask taskToKill) { if (taskList.Contains(taskToKill)) { taskToKill.CanKill = true; } } /// <summary> /// Removes all tasks form the taskList. This method is typically /// called whenever the game should exit. /// </summary> static public void KillAllTasks() { foreach (AbstractTask task in taskList) { task.CanKill = true; } } static private LinkedList<AbstractTask> taskList = new LinkedList<AbstractTask>(); static private LinkedList<AbstractTask> suspendedTaskList = new LinkedList<AbstractTask>(); } } Have fun! [Edited by - Enselic on October 31, 2006 5:50:02 PM]
  7. Enselic

    A few hours left

    And there it goes
  8. Enselic

    A few hours left

    My GDNet+ membership expires in a few hours, and I thought I'd make a last (and among the first :P) journal update, only because I still can. Umm.. so.. well.. Ah yes, I've got my first programming job, I hope it turns out well and that I will still have time to finnish my studies at LTH. Btw, I wonder if the images at my GDNet webspace will be wasted?
  9. Enselic

    2D Pool Ball Collisions

    I suggest another method for solving the stickiness problem, it is a bit more advanced, but yeilds a more correct behaviour. Without it, balls may go "through" each other when they in a real game would touch each other. Instead of checking the velocities of the balls when they are intersecting, and skip collision calculations if they are moving away from each other already, you should revert the simulation to the time when they are just about to en begin intersecting each other, and then calculate the new velocities at that time. If two balls are intersecting, there always exists a time when the balls are moving into each other (because otherwise the intersection would not occur in the first place). The tricky part involves calculating the negative deltaTime that corresponds to the time when the balls are just about to intersect, but I belive I have read such an article on gamasutra once, so it might be worth checking out.
  10. Let's say you want to solve for x in ex = a. Use ln on both sides of the equation and you get ln ex = ln a. Since ln ex is equal to x (ln ex is the number you should raise e with to get ex, i.e. x) you get x = ln a. Your calculator probably have a ln function, so now you can at least solve eqations like the one above.
  11. Enselic

    class design and interaction

    The ability to design, say, the Unreal Engine 3.0, comes with experience. The guys behind that engine have designed probably around a dozens other engines before it. And the ability to "see" when a thing should be represented by a class, also comes from experience. As with math, once you begin to think in the right way, the solutions to these kinds of problems will come much more naturally. Start out simple, probably not even with an engine, but just a game with simple classes for Player, etc etc. As time goes by, and you start to think object oriented, and as you study the source of other engines, you will begin to think "Hey wait, I can do it this way instead!".
  12. Enselic

    Fourth dimension anyone?

    To anyone trying to run it with java Mazewithout success, try java -cp . Maze(to tell java to search for classes in the current directory) Cool idea, I tried to get any sense out of the stereoscopic 3D projection of the 4D world, but I failed [sad]
  13. Enselic

    Program line counter

    Quote:Original post by Ravuya Semi-derail: I've been trying to find a good line counter for Windows without first installing Cygwin. I use sloccount on OS X. Semi-ad: I wrote one quite a while ago to get some C#/.NET experience. Back then I hadn't yet decided upon a clean coding style, so the code is somewhat messy. I also have a lot of features I would like to add to it when I get time (like auto-scanning directories for source files and support for more project files), but it still counts lines pretty well. You will find the line counter at my downloads page.
  14. Enselic

    Rubik's cubes

    Quote:Original post by SuperNerd Hey everybody. I wan't to know how many of you do the cube. What your average and fastest times are, my fastest was 50 seconds but I average about 70 seconds. If you have cool way of solving them or anything like that post that too. I am working on being able to solve two at the same time by having one in each hand. Examining the algorithms at, it seems that for speedcubing, memory is more important than logical skills. Would you consider yourself a good memorizer? Also, one of the most boring things to do while I was practicing speedcubing, was to shuffle the cube. I found it to be hard to shuffle it randomly. Do you have any tip?
  15. Enselic

    Image question

    After you have loaded the bitmaps, you simply merge the data. If you want to combine #2 below #1, just add the actual bitmap data at the end. To put #2 to the right of #1, you "mix" the actual bitmap data by inserting every row n from #2 after row n of #1. After the merging, you write the data to a file.
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!