Jump to content

  • Log In with Google      Sign In   
  • Create Account

The Communist Duck

Member Since 11 Jul 2009
Offline Last Active Feb 04 2012 03:31 AM

Topics I've Started

Yet another entity/component system

20 May 2011 - 04:18 AM

Hi. I've fiddled around, and I thought of a decent component design with XNA. I've tried to avoid the built in GameComponent for the most part.

There are Components such as PhysicsComponent and RenderComponent which derive from Component. Each Entity contains a list of components (I don't see myself needing to query for a PhysicsComponent; I could just send it a message). Each Component may register to some system - e.g. the PhysicsSystem, or the graphicsSystem (I think these would be static; comment?)

The World derives from DrawableGameComponent, and calls Update on each entity (which calls it on each Component) and Render on the GraphicsSystem (which has the list of RenderComponents).

I don't see myself needing a hugely complex one.

Feedback on it?

XNA or SlimDX?

22 April 2011 - 04:31 AM

This is probably another one of those questions, but I have not found anything recent on it. That is, addressing XNA 4.0 and SlimDX March '11.

I am learning C# for some fun, and want to go into 3D. I originally planned to go for XNA, but the MSDN site scared me a little. It seemed very much to say 'XNA is for Windows Phone and XBOX!'. I know it does Windows too, but still.

I also remember hearing about SlimDX. It seems good, and the comparitive table seemed to slant in favour of SlimDX over XNA.

However, I am not a fan of writing very low level code.

Is there a decent, up to date comparison of the two, not just feature wise?
And if I want to make a 3D game just for Windows, should I prefer one over the other?

Code exceptionally slow - is this just Python's limit?

18 April 2011 - 02:35 AM

I don't mean to start a flame war, and I am pretty sure it is fault of mine not of Python for being a high level language.

I am making a tile based RPG. Needless to say, I have tiles.
For display, I have a 2D list of 60*40 pyglet sprites. Each frame (currently I'm running on a wait-for-user-input system, simply to try and get it working) I will iterate through a list of tiles that I can see, and set each tile on the screen to the same type. Obviously this is going to be slow.

I can't think of a better way. Here is some code:

 def Update(self):
    	for t, x, y in self.camera.GetView(self.width, self.height):
        	t = tile.DebugTile1() if random.randint(0,1) == 1 else tile.DebugTile2() #this is just so I can see the results.
        	self.window.SetTile(x, y, t)

 def SetTile(self, x, y, tile):
    	self.spriteList[y][x].image = self.GetTileTexture(tile) #spritelist is a list of sprites, and GetTileTexture is a caching function that stores tile textures

I also tried just changing the sprite texture instead of the whole sprite, but that was actually slower.

Here are the important parts of the profiling:
15085326 function calls (15085306 primitive calls) in 32.166 seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000   32.168   32.168 <string>:1(<module>)

       99    0.743    0.008   20.531    0.207 engine.py:58(Update)

   237600    0.796    0.000   11.995    0.000 sprite.py:349(_set_texture)
   120121    0.677    0.000    9.062    0.000 sprite.py:365(_create_vertex_list)
   357721    1.487    0.000    3.478    0.000 sprite.py:377(_update_position)

   420767    0.786    0.000    2.054    0.000 vertexbuffer.py:421(get_region)
   715442    0.859    0.000    1.280    0.000 vertexbuffer.py:467(invalidate)

        1    9.674    9.674   32.168   32.168 win32.py:46(run)
      180    0.007    0.000    1.771    0.010 win32.py:83(_timer_func)

   237600    0.416    0.000   17.069    0.000 window.py:60(SetTile)
   237600    0.646    0.000    2.174    0.000 window.py:72(GetTileTexture)
I am no good at reading these, but it seems a lot of time was spent in the update loop - so I doubt it's a drawing issue. To get these, I just hit the keyboard somewhat to force it to update, so there are times of idle and times of quick updating.

Almost all the time in Update was in SetTile, so I assume my method of keeping things on the screen was a bad idea. I doubt blitting images is going to be any faster than a sprite batch.

Any ideas? (Python/pyglet, I do not want to go to Pygame)

When should I learn a new language?

16 April 2011 - 12:38 PM

I apologise if this post is rather vague or doesn't have an obvious point to it. Hopefully I can tl;dr it.

I've been learning/using C++ for about 1 1/2 years, and Python for 6 months. I'm finding myself a great fan of Python, due to its simplicity compared to C++'s general bloated-ish feeling.
Recently I've been working on an RPG type game in Python. It's another one of the projects I start for a month or so, then just abandon. I don't want to abandon it, and I've documented it and stuff to try and keep myself going. It's not that it doesn't interest me, just other ideas have crept up. Same with my programming language I was writing.

I now want to fiddle around with 3D stuff. My assumption is that Python would not be optimal for this, namely due to the speed issues. I could go back to C++, but the small amount I've fiddled with it recently, it feels horrible to write in, to put it bluntly.

I was considering using this opportunity to maybe pick up another language like C# (which I dabbled in a few years back). I don't think there would be a downside to it: it would help me have a wider understanding of programming, wouldn't hurt any uni/career chances (I am still a..high school? student. I don't know how UK maps to the US), and would allow me to still have lots of fun programming. However, I start to wonder if I'm following the same trend as my projects: pick them up, play around for a bit, and abandon without finishing them (or in this case, using the language for a long time). Or I could be swatting at hot air.

tl;dr Is there a downside to learning new languages quickly (i.e. <1 year apart)? As a minor point, how can I stop myself giving up on projects for 'that new idea'?

EDIT: For the record, I plan on only really developing for myself and maybe releasing games I make to friends. So Windows development is my primary concern.

How can I arrange my repository/version control on a hobby project for the best ease of...

23 March 2011 - 02:37 PM

Hi. I've started a hobby project somewhat more seriously: documented, using github for hosting, etc.

I haven't really touched on version control before. I don't think git was a good idea to start with, but it feels nice to use. :)
I was wondering about how to organise branches and the repository in general. (This is a hobby engine, which I will develop along with/for the game I have planned out. It may be released as an engine/library later.)
Whilst generally talking to people about how to use git, I learnt that I should have a master branch, where code always compiles/runs; and then a development branch for more nightly usage; storage, pretty much. They also started talking about feature branches, milestone branches, and the like. These confused me.

Would two branches, one for finalised code, and one for development, work simply enough? Or could I make do with just the one?