Jump to content

  • Log In with Google      Sign In   
  • Create Account


Arhim

Member Since 04 Aug 2011
Offline Last Active Sep 29 2013 11:46 AM
-----

Posts I've Made

In Topic: Economics engine

08 May 2013 - 02:11 PM

Don't know how much this helps, but I played a game called Capitalism II,

 

it features a pretty extensive economy system with corporations that compete for certain goals (highest market share in electronics, etc.). You can mine resources, build factories to craft the resources into goods, build retails to sell the goods (you can also sell your competitions goods if they allow it). You can set prices on pretty much everything, buy shares of company, take over companies, etc.

 

This is just if you need some more inspiration ;), cheers


In Topic: Problem with understanding data access and responding to events in component...

07 May 2013 - 06:42 AM

Thanks again eveyone for your help,

 

great advice and I really like the idea behind ppodsiadly's code.

 

 

Have a nice day, Arhim


In Topic: Problem with understanding data access and responding to events in component...

07 May 2013 - 03:23 AM

Thank you eveyone for the replies, it cleared some things up about the definitions.

 

I am still interested in how a system like this would work:

 

there are different managers, let's say CollisionManager and HealthManager(more like a general gameplay object manager, just for the simplicity) and you have a object that inherits from 2 interfaces ICollidable and IHealth. This object subscribes to the managers to have its respective states updated each frame. Now, if a collision happens between 2 objects (that both inherit from ICollidable) how should the HealthManager be informed?

 

I was thinking that when I inform the respective objects of having a collision (by sending ICollidable* of the other object) I tryed to cast those pointers to IHealth and if that failed nothing would happen but if it was successful I update their health parts.

 

Or should the physics (like mentioned) be completely seperate from the gameplay part. Then where does the connection happen in that case? Does the HealthManager poll for collisions between objects and likewise all the other managers? I presume the CollisionManager would remember already caluclated collisions as to be faster.

 

Sorry if I am a bother, can you also point me to some articles or examples from which I could learn for myself.

 

Thank you all very much :)


In Topic: AS3 creating new objects.

03 April 2013 - 11:03 AM

I would make an array (or vector) of Bullet objects and have a var index:int that will tell me what the last used bullet in the array was.

 

So the implementation would go somewhat like this:

 

 

 

function spawnBullet():void
{
    //Pseudo code
    //Take the Bullet at position index and "activate it"(by activating I mean setting it's position and adding listeners)
    index = (index+1) % MaxNumberOfBullets;
}

// This next function I would call every few frames (it depends)
function cleanUp():void
{
    //Again pseudo code
    //Go through the array of bullets and check if they are ready for "deletion" (by deletion I mean removing the listeners and         
    //maybe making them invisible)
}
 

 

Now what this should do is it will allow you to always have a free bullet object that is hopefully destroyed (unless somehow you needed more bullets than the array could hold, in that case you increase the maximum size and add more bullets to the array) and it will make removing them not really taxing on the PC.

 

Ofcourse, the special case is when a bullet hits an enemy and it disapears but yout can solve that by implementing a function that will deactivate the bullet which you can, again, call in the cleanUp function instead of handling it manually.

 

Hope it helps you ;)


In Topic: Shooting in SFML

02 April 2013 - 02:55 PM

Actually, if you look at the code, the only place where the bullets position is updated is this:

 

 

bulletX += ((shot_XOffset*0.1)) ;
bulletY += ((shot_YOffset*0.1)) ;
 

 

but shot_XOffset and shot_YOffset are calculated like this:

 

 

shot_XOffset = mouseX -( bulletX );
shot_YOffset = mouseY -( bulletY );
 

This makes the bullet move 10% of the distance between the mouse pointer and the origin position, which means it is not constant if you change the mouse position (hence the faster and slower movement).


PARTNERS