June 17, 2019, 08:56:16 AM

Author Topic: Creature Corp - Movie Game Contest Entry  (Read 5817 times)

Offline iWasAdam

  • Hero Member
  • *****
  • Posts: 1107
Re: Creature Corp - Movie Game Contest Entry
« Reply #60 on: April 17, 2018, 02:45:01 PM »
Linux Mint Sylvia 64 xfrce
Right I'll see if I can get it working....

linux mint -check
install -check
get monkey2 1.05 -check
do strange sudo installs - check
begin rebuildall from monkey2 - check.....!!!!!!!

Good Lard... It's compiling!!!!!!
I've tried 4 different linux configurations, and numerous forum posts and still couldn't get anything to work.
This is the first time I've got this far....!

HOLY CRAP!!!!!! IT WORKS


Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 1899
Re: Creature Corp - Movie Game Contest Entry
« Reply #61 on: April 17, 2018, 04:21:27 PM »
@ Qube
So I assume the whole thing is more or less a single file project (with "includes" rather than "imports") with all "objects" seeing each other? I think it is a bit of a pity that AGK does not over "lite OOP" like BlitzMax. Am not sure how complicate/troublesome/tricky bigger projects get without proper encapsulation. Regarding GUI: I am not talking about simple buttons. My GUI has accordeons,  dropdown/comboboxes, customizable tooltips, modal widgets, textareas, sliders, lists, versatile scrollbars, drag'n'drop, layers/limits, event system ... and uses nine patches, content padding, bitmap fonts (also talking about text wrapping, text-formatting support), ... Things can get pretty "complex" (or at least "heavy") once you need more and more features and widget kinds. But yes, Buttons, checkboxes, simple "state machines" (radio buttons, ...) are done pretty quick. Handling modal dialogues etc. can be done procedurally ("if gameMenuIsShown then...") but it would be nice if it was done at least semi-automatically.
If there is no much GUI/HUD-stuff to do then one could do it that way, but the more options you provide to the player, the more you benefit from "automatization".
Yes, you can split up your code and call it via includes ( or Insert as AGK calls it ). Coding big projects isn't an issue at all plus OOP is just another way of working to which I've never come across any game that couldn't be done without OOP. Neat code wins every time :)

I've written the more complex GUI's too, with Windows, buttons, sliders, radio buttons, list boxes, drop down menus, popup menus etc etc. I just find them incredibly boring to code :(

@ game
So gameplay would be single player or would you plan to have kind of "cities" consisting of multiple stores fighting for a limited amount of customers, stock supply ...? So no need to render the other stores - just synchronizing "numbers" and people "moods".
I aways envisaged it as a single player game and as far as the game is concerned there are no other stores. I think having other stores you are fighting with could work out but I would be hesitant to have that a a big side to the game.
Until the next time...

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 1899
Re: Creature Corp - Movie Game Contest Entry
« Reply #62 on: April 17, 2018, 04:22:52 PM »
Linux Mint Sylvia 64 xfrce
Right I'll see if I can get it working....

linux mint -check
install -check
get monkey2 1.05 -check
do strange sudo installs - check
begin rebuildall from monkey2 - check.....!!!!!!!

Good Lard... It's compiling!!!!!!
I've tried 4 different linux configurations, and numerous forum posts and still couldn't get anything to work.
This is the first time I've got this far....!

HOLY CRAP!!!!!! IT WORKS

AGK, download, install go - on Windows, Mac & Linux. Simples ;D - Why torture yourself :o

( thread derail over )
Until the next time...

Online Derron

  • Hero Member
  • *****
  • Posts: 2147
Re: Creature Corp - Movie Game Contest Entry
« Reply #63 on: April 17, 2018, 08:10:47 PM »
As Adam suggested some kind of "sketch" (ascii gfx):
How would you tackle to disconnect "units" from "persons". For now I have persons - which are non-graphical and contain properties like "nameFamily:string", "wage:int", "hiredTime:Long" and corresponding methods ("CalculateWage()", "GetWage()" ...)... These "persons" do know to which production device they are currently assigned to (via "productionDeviceGUID", so only a weak reference). I also store actions/tasks (going to spawn point, search new production device, working at a device, idling, ... finite state machine).

Then I have added some methods to these persons which are called by the game: onReachTarget(params), onAssigntoProductionDevice(params) ...

The visual representation is done by a "TileEntityUnit" class which holds a reference to the person (could be accessible via personGUID too...). It knows the target on the tile map - and does the movement and rendering. For now it also handles action/task updates when reaching positions/targets - or if "inbetween checks" show that a target is no longer valid (eg. someone else is using it now, or the target got sold/ path blocked). I know this could be done via events too (persons list if other persons use a device now and stop their task then).

The "person" class (and other "game objects") do not know about their tilemap representation - I try to encapsulate as much as possible to avoid circular dependencies (and potential memory leaks).


Ok, so the visual representation interfers with / controls behaviour of the person class - which is what I worry about. It feels like a "dirty hack".

So normally I would think that "person" should know where it goes to ("target position" or "target object") and how long the route will take (in "game time" - so it allows various game speeds, like I already added with keys 1-4). The "TTileEntityUnit" would just represent the visual state and should in no way be required to modify "person"-properties.

In other words: how to bring together "tilemap" (iso or top-down does not matter) and "non-tilemap-objects": in other words, how would you make it "client-less"/"head-less"?



bye
Ron

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 1899
Re: Creature Corp - Movie Game Contest Entry
« Reply #64 on: April 17, 2018, 08:51:07 PM »
It looks like you're overcomplicating things :o

Very roughly and cutdown, I'd just define things like so ( using wacky AGK code :P ) :

Code: [Select]
Type tPerson
id
name
wage
hiredTime
jobTitle
currentAction
xTile
yTile
EndType

Type tDevice
id
name
currentState
hasPerson
xTile
yTile
EndType

Then you can easily parse through each person to update them, see what they are doing etc and just as easily parse though devices to see what state they are in, if any person is at them.

I think going OO nuts is not the right or easiest approach.

Same with game speed. If you code it for a target frame rate of 60FPS and assume that is normal speed then it's easy to speed up the game based off deltaTime. The speed of characters walking, the time, time it takes for a task to complete can all be linked very easily.
Until the next time...

Online Derron

  • Hero Member
  • *****
  • Posts: 2147
Re: Creature Corp - Movie Game Contest Entry
« Reply #65 on: April 17, 2018, 09:27:32 PM »
BTW my person type looks like this for now:

Code: BlitzMax
  1. Type TPersonBase extends TEntityBase
  2.         Field lastName:String = ""
  3.         Field firstName:String = ""
  4.         Field nickName:String = ""
  5.         Field gender:int
  6.         Field countryCode:string = "US"
  7.  
  8.         'wage + modifier (more expensive at same skills)
  9.         Field wageMod:Float = 1.0
  10.         Field wageBase:int = 0
  11.         Field wage:int = 0
  12.         'paid for todays work?
  13.         Field wagePaid:int = False
  14.  
  15.         'reputation a company has to have before applying for a job
  16.         Field reputationMinimum:Int = 0
  17.  
  18.         'when born?
  19.         Field timeDOB:Long
  20.         'when hired?
  21.         Field timeHired:Long = -1
  22.         Field hired:int = False
  23.         'got fired meanwhile?
  24.         Field timeFired:Long = -1
  25.         Field fired:int = False
  26.         'individual skill values
  27.         Field skillLevels:int[]
  28.         'how many times a skill was used (for level ups)
  29.         Field skillsUsed:int[]
  30.  
  31.         'what skill was used for last production point
  32.         Field lastProductionPointSkillType:int
  33.         'when was the last skill point created?
  34.         Field lastProductionPointCreationTime:Long
  35.  
  36.         'influencing productivity of that person
  37.         Field productivityMod:Float = 1.0
  38.  
  39.         Field assignedProductionDevice:TProductionDevice
  40.         Field assignedProductionDeviceTime:Long
  41.         Field assignedProduction:TProduction
  42.         Field assignedProductionTime:Long
  43.  
  44.         Field actionState:int = 0
  45.         Field actionStateTime:Long = -1
  46.         Field actionStateWorldTime:Long = -1
  47.         Field nextActionStateWorldTime:Long = -1
  48.         Field currentTask:int = TPersonTasks.NONE
  49.         Field currentTaskTime:Long = -1
  50.         Field currentTaskWorldTime:Long = -1
  51.  
  52.         'energy
  53.         Field energyRecoverAt:Int = 50000
  54.         Field energyRecoverTo:Int = 60000
  55.         Field energyRecoverLevel:Int = 0
  56.         Field energy:Int = 100000
  57.         Field energyMax:Int = 100000
  58.         Field energyUseMod:Float = 1.0
  59.         Field energyRecoverMod:Float = 1.0
  60.         Field energyUpdateIntervalMod:Float = 1.0
  61.         Field lastEnergyUpdateTime:Long
  62.  
  63.         'working times
  64.         Field workStartHour:int = 8
  65.         Field workEndHour:int = 16
  66.         Field workHours:int = 9 'including break
  67.         Field workShift:int = 0 '0 early, 1 = mid, 2 = evening, 3 = night
  68.         Field workShiftsUnwanted:int[]
  69.         'ATTENTION: for now you can simply cheat employees into working more
  70.         '           by changing their shift :-)
  71.         'TODO: Save new SetShifts() into other variables and when
  72.         '      a current shift is planned to start this new shift values are
  73.         '      copied to the real used variables and time is checked again
  74.  
  75.         Global skillsUsedLevelUps:int[] = [10, 50, 100, 250, 500, 1000, 2500, 5000, 10000, 25000, 50000, 100000, 250000, 500000, 1000000]
  76.         Const energyRecoverLevelMax:Int = 3
  77. [...]
  78.  
(yes, getting fired is something else than setting "hired to false")


What you do is adding things like "tile position" to the person/device - something they normally should not know about (or even care about) - separation of concerns. But as "xTile" and "yTile" are simple integer values, I think that's "ok" to make things easier. And yes, I thought about that too (main idea is always to allow "separation" to avoid circular depencies - so no tileX=TTileobject but tileX=102)

Ok, so "TPerson" now is able to know where it is located on a map (xTile,yTile). Moving to another object would need to go about an object "controlling everything": "world.GoTo(person, xTile+10, yTile)" or so. Why? A person should be able to target items (but of course should not need to know that it is "on a map" - so it just needs to say: please go to the item). It also should not know about "TDevice" as "TDevice" knows about "TPerson" already - I normally create some base classes for that (TPersonBase, TDeviceBase) which could get used by the other classes. These base classes only contain "encapsulated" data or base data (int, float, string, list). As said, to avoid circular dependency. In the base class I could have things like "GetAssignedPersons:TList()" which returns nothing in the base class, but a real list of person(base) in the "TDevice" class. In C/C++ you would surely use "interfaces" for this, but BMX(vanilla) does not have this, so I am used to use these to keep vanilla compatibility.

I am aware that many problems are "self-made" as it over-complicates stuff. I could just have TPerson and TDevice in the same file and they could happily access each others properties. But for me this does not look "clean" - while of course it cuts down development time and eases a lot of pain. In AGK this will work that way as there are only "includes" (so they are "in one file" already - somehow). With "includes" the whole thing is a lot of easier to code but I am not sure how AGK (or others) do the Garbage Collection then.

I should really do not care much about "reusability" (I always think one could use a class in another scenario - so encapsulation makes this pretty easy).
Also I always try to think of objects using "natural thoughts". A person does say: "I want to go to the computer", it does not think "I want to go to the computer which is located at the left corner of my office". So the persons in the game should not care for tilemaps - they just need to know that the computer exists, and if they are at it or not - and that they could go to it, or not ("already occupied"). Maybe doing it that way is overcomplication - similar to having total "normalization" in Database schemes - sometimes having "dirty" DB-structures helps speeding up things (adding indices to remove some queries and so on). Hmm should really try to "keep my code dirty" :-).


Let's also check what Adam suggests - how he would tackle such things (he seems to be a "procedural guy" too - albeit using Monkey2).
 


@ Game
If you want to code something in your evenings: feel free to use the assets of my game as place holders so you do not need to stare at rectangles or such a thing.


also here is a simple iso-rectangle / iso-block code for prototyping - might save you 3-4 minutes of thinking about it:
Code: BlitzMax
  1.         Function DrawIsoRect(x:Float,y:Float,w:Float,h:float, filled:int = True)
  2.                 if filled
  3.                         DrawPoly([x, y + 0.5*h, x + 0.5*w, y, x + w, y + 0.5*h, x + 0.5*w, y + h])
  4.                 else
  5.                         DrawLine(x, y + 0.5*h, x + 0.5*w, y)
  6.                         DrawLine(x + 0.5*w, y, x + w, y + 0.5*h)
  7.                         DrawLine(x + w, y + 0.5*h, x + 0.5*w, y + h)
  8.                         DrawLine(x + 0.5*w, y + h, x, y + 0.5*h)
  9.                 endif
  10.         End Function
  11.  
  12.  
  13.         Function DrawDemoBlock(x:Float,y:Float, height:int, tileWidth:int, tileHeight:int)
  14.                 height :+ tileHeight
  15.                 if height > tileHeight
  16.                         local oldCol:TColor = new TColor.Get()
  17.        
  18.                         oldCol.Copy().AdjustBrightness(-0.2).SetRGB()
  19.                         DrawIsoRect(x,y, 2*tileWidth, tileHeight, True)
  20.                         DrawRect(x,y - height + 1.5*tileHeight, 2*tileWidth, height-tileHeight)
  21.  
  22.                         oldCol.SetRGB()
  23.                         DrawLine(x + tileWidth, y + 2*tileHeight - height, x + tileWidth, y + tileHeight-1)
  24.                         DrawIsoRect(x,y - (height-tileHeight), 2*tileWidth, tileHeight, True)
  25.                 else
  26.                         DrawIsoRect(x,y - (height-tileHeight), 2*tileWidth, tileHeight, True)
  27.                 endif
  28.         End Function
  29.  

bye
Ron

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 1899
Re: Creature Corp - Movie Game Contest Entry
« Reply #66 on: April 17, 2018, 10:44:55 PM »
Quote
I am aware that many problems are "self-made" as it over-complicates stuff. I could just have TPerson and TDevice in the same file and they could happily access each others properties. But for me this does not look "clean" - while of course it cuts down development time and eases a lot of pain. In AGK this will work that way as there are only "includes" (so they are "in one file" already - somehow). With "includes" the whole thing is a lot of easier to code but I am not sure how AGK (or others) do the Garbage Collection then.
I think the main thing is to code in the style you are most comfortable with. There is no right or wrong way, just the final result. No idea how garbage collection is handed in AGK, it's not anything I worry about.
Until the next time...

Online Derron

  • Hero Member
  • *****
  • Posts: 2147
Re: Creature Corp - Movie Game Contest Entry
« Reply #67 on: April 20, 2018, 12:58:51 PM »
Lunch break and I reorganized my blender files ... some "offsets" were not clear to me (only happening in the file linking to an asset) - I just parented that stuff to new empties so I rotate/position the "empty" then.



Also created some "target empties" so the script knows to where it has to move stuff - which allows adjustments without altering the script then.


bye
Ron

Offline iWasAdam

  • Hero Member
  • *****
  • Posts: 1107
Re: Creature Corp - Movie Game Contest Entry
« Reply #68 on: April 20, 2018, 03:22:43 PM »
very nice :)