0
\$\begingroup\$

I want to create something like a game but I am going to use Direct2D and GDI for drawing API.My problem is that I want to separate drawing code from objects. For example lets say I have conduit objects and pumps.Each one might have different color and vector shape. I mean problem here is that drawing a pipe wont be a texure but a series of commands like drawline , drawrectangle etc.The only way I can think of having a Renderer class that would have drawing logic for each one.But in case I want it to be extendable from another developer then in order to add a new object they should extend renderer. My question is since I am not going to use classic game things like sprites,textures etc how can drawing complex vector objects be abstracted? And how can I make it extendable ?

\$\endgroup\$
5
  • 1
    \$\begingroup\$ You could try to make it scriptable. For instance, the drawing routine reads 'commands' from a file and draws based on those. This way, it is extendable and your actual program will be compact. Plus, your scripting language won't need to be complex at all, just r 100 100 500 500 to draw a rect, etc. \$\endgroup\$
    – toby
    Commented Feb 19, 2015 at 12:36
  • \$\begingroup\$ Indeed.However since Direct2d and GDI use different stuff I need a way to cache things \$\endgroup\$
    – GorillaApe
    Commented Feb 19, 2015 at 12:40
  • \$\begingroup\$ An alternative would be to have the scripts in a header, like arrays of UINTs or something, so they compile along with the program. This way, they're faster than being read from a file. However, this assumes that the developer who's extending has access to the source code. I'm doing a free Geometry Wars clone and I've done just this for the enemies, ships, particles, etc. \$\endgroup\$
    – toby
    Commented Feb 19, 2015 at 12:48
  • \$\begingroup\$ nice. However some are dynamic. For example a conduit which is a line should connect two nodes that might move \$\endgroup\$
    – GorillaApe
    Commented Feb 19, 2015 at 13:02
  • 1
    \$\begingroup\$ If you want to have complex, programmer controlled geometry you'll need to keep your parts inside plugins (lots of resources online for plugin architecture) and provide an API that wraps your drawing and anchor placement methods. \$\endgroup\$
    – jzx
    Commented Feb 19, 2015 at 18:45

0

You must log in to answer this question.

Browse other questions tagged .