Home
Community
Manuals
Login or Signup

Blitz community Game Project built in modules on a flowchart

Community Forums/Common Room/Blitz community Game Project built in modules on a flowchart

Mainsworthy1 week ago #1
I was thinking about a community game built by all of us in a single project. we provide details for each module needed eg: a functions inputs and a functions outputs,

eg input X,Y module to check Left right keys output X,Y

that's a simple example but it shows what I mean. it means we all need to build a flowchart and decide on modules on the flowchart then we choose what module to do.

would you guys be interested in this?


Mainsworthy1 week ago #2
there would not need to be collaboration, just design a module in the flowchart, not time table, and you could work alone, theretically hot swapping different modules for the same flowchart module, so people could improve a module or change it for someone elses


Derron1 week ago #3
Therefor you need to know in advance which kind of game it should become.

module "unit movement" with input "x,y" and output "x,y" would not help that much for a tile which is not moving at all.



Then there is something like a "music"-module. Is it supposed to automatically play something or does it need triggers from a "scene-management"-module ?


While "components" could be swapped before running a game it needs a certain "common foundation/idea" to build everything on it.



Your idea works best if you design everything of a game - eg. a game with two AIs battling each other. Then you could ask others to build the best AI - by having functions you call ("onYourTurn", "onUnitDestroyed" ...) and functions the AI is able to call ("MoveUnit(u,x,y)", "GetUnitArmor(u)") ...




bye
Ron


Mainsworthy1 week ago #4
you would have things like a display module, its inputs would be tile array, x,y of player and px,py positions on the tiles. what I'm suggesting is classic software design, I believe its called Jackson structured programing(JSP)

it dosnt need an A.I. an app can be made just to respond to your actions

I thought we could community decide the game, its a project everyone could contribute to with no time constraints and each module could be redone by anyone.


Derron1 week ago #5
The "AI" was just an example in which components or similar things would work.


@ tile array
Ok, then add a z-component which your original "input/output"-design did not catch. Or maybe something needs holding a certain key-combination ...

I agree that an output state could get defined, but the inputs are based on the game(play) you decided before.


@ JSP
Even there you need to know in advance what the "flow" of your programme will be.
Yes, you could modularize things like "player figure control" (input -> output) but therefor you need in advance if you have just one figure, or if the game is something like SimCity, which does not need player units.


So once you decided for a game(play) you could of course split that into modules - which could be done by various coders.


bye
Ron


Mainsworthy1 week ago #6
a module named update globals could be made, you feed it with new set of data and it updates globals like x,y,

you would have another module fetch globals,

you may be used to locals, but globals is what could used


skidracer1 week ago #7
You could start with a uml style editor with network features and use that to design a click'n play game construction kit. I made an attempt at a monkey node editor a few years back inspired by derivative touch designer but didn't get that far.

IMHO It would be way cool if it looks anything like Adam Strange's chip synth.


Mainsworthy1 week ago #8
maybe do a text adventure first to testout the process?


Mainsworthy1 week ago #9




If people are interested in a community game project, I'm prepared to provide my game Rogue3 and source code to be a start point , so this first project would be just to improve a game? would anybody be interested in this?

The first step would be better text in the game rather than what I wrote, then add more events that could happen with each move, then better artwork,

is this worth me giving the community my game code? I need more than one person to show interest in this?


Derron1 week ago #10
Text replacement could happen once the design of the game (HUD and so on) is done.
Else you end up doing things twice.

So design first:
- are options/actions limited or of avariable length (list versus eg. 5 properly layouted action buttons versus <- button button button ->)
- is undo/redo possible (go back in time...)
- is "playfield size" limited or dynamically resizeable
...

All these things (and way more) define how things could be presented. I am not talking about artwork but just general layout - to keep things structured, nice and tidy.

Of course above is just able to get designed once the gameplay is fixed. I am not sure if that is done as you wanted "that could happen" events. These events are limited by how you present things (or ... you present things according to the possibilities events have).


Dunno how to describe it properly, but imho it needs a certain "scenario/limit/design" for a collaboration between multiple people.
Maybe someone else will jump in and write what he/she things should be done first. As said I am not thinking that "text" or "events" is the right thing to do.



bye
Ron


Mainsworthy1 week ago #11
I think it should be turn-based so it keeps things simple,

I think we need some input from others to decide what to do.


AdamStrange1 week ago #12
I suppose it really depends on what the game is and how it plays.

looking above (I haven't played anything so be kind), it seems to be:
1. a map (of some sort) - showing your location and others
2. quests -e.g. pick up passenger - probably shown on map?
3. your actual ship - so there would be some form of crafting and money system to upgrade ship etc
4. if there is money of some sort, then this could be gained by doing quests, etc
5. possibly some sort of 'other' display, 2d, 3d isometric, etc. maybe there is a global map and a local one?

looking at the above list. Skyrim and any rpg fits into this very well.

lets make some assumptions...
1. lets assume the global map is of a star system. with planets, moons and nebulae, etc
2. to get from planet A to planet B (x,y location on global map) you will need a ship capable of doing it. - we're sort a into elite territory now. and you will have to avoid thieves, engine overheating, enemy battles, etc
3. You could have different factions with different objectives. E.G. The Dohnutty are a raiding race who track any food deliveries and raid them...
4. on completion, you get a rating and awarded monies to upgrade your ship... and on to the next challenge.
5. Challenges could keep coming and you pick the one you like. like in transport tycoon.
6. more points awarded for completing task first. E.G. the dohnutty will pay the first person to deliver sprinkles for their "great bake off". if you accept and don't get there on time or dont get there first - they go ballistic and raid you...

Note - there is no UI, no dataset, just the basic concept


Mainsworthy1 week ago #13
I like the game your suggesting as an improvement on what Ive done.

if your starting from screatch....

all variables must be globals to be accessed from all individual functions, so anybody can work on a full function by them selves, each function has to be defined with strict inputs and output so again they can be worked on by any individual, or even inproved on another function, each function should be able to be hotsawapped with any function doing the same job. no time limit on working , after time there may be many modules doing the same job, so the game could be instantly built with different modules easily.

so I would start with a globals module, this is the only module that is flexible and can be build as each module needs different variables. so first thing is how we name the globals. eg MOVEMENT_X = 0 , MAP_X = 0 etc...

If you guys want to improve rogue 3 s code, its not perfect but understandable, personaly Id like to see rogue 3 upgraded by brains that see it better than me, Adam has a much more structured and different viewpoint than me, and I think rogue 3 would improve with his input. but I think a wider community would even be better.

Why don't we just cutup rogue 3 and replace each function, then add functions>?


Mainsworthy1 week ago #14
Adam, there is no map in rogue 3, I used a new idea to progress in a straight path from a random line of locations and events. I think it works amazingly


Mainsworthy1 week ago #15
https://numbergamer8.itch.io/rogue-three-privateer

ok Ive put soucecode online, so we can talk about what we want to do?


Mainsworthy1 week ago #16
I would say first thing to do is, to select graphics files paths to be rewrote to work on a Mac?

I don't know who uses Linux?


Derron1 week ago #17
There is no need to have file assets at all.

I thought you want to use modules for everything.

So every unit is kind of an module with defined methods (prepare (init assets if not done yet), update move renderBackground RenderForeground RenderDecoration...).

So if one wants to use vector drawing..he might do so.


@ globals
You could consider checking my Data-container-class it is kind of an registry for numbers, strings, objects (GitHub.com/GWRon/Dig.git/base.util.data.bmx). Of course you cannot guarantee existence of variables as you would do with a globals-container but the benefit is a non-changing base class for variables.

Hmm depends on how strict input/output predefinition becomes.



Back to files/URIs
Just use a generic function to sanitize/repair/... File urls. And to replace slashes (all OS will work nicely with slashes, so no backslashes needed IMHO).

Bye
Ron


Mainsworthy1 week ago #18
https://github.com/GWRon/Dig/blob/master/base.util.data.bmx

I needed to get a new link, above works


Mainsworthy1 week ago #19
I think for the community to joinin all code has to be super simple to understand ,


Mainsworthy1 week ago #20
this project could be ongoing perminantly.


Mainsworthy1 week ago #21
we should use rogue 3, and split it into functions(modules) and create a better structure & cut out new modules, then use it as a base game, then let everyone rewrite modules?

create better var names etc...


Mainsworthy1 week ago #22
@Derron I think just a list of globals is a more simple way of accessing and updating globals, we need to be simple for everyone to join in? I only used intergers, so super simple. but if a 3d battle module was added by someone you may possible use float, but to keep it simple just use intergers for everthing

the file paths I use on windows don't work on Adams Mac.


Mainsworthy1 week ago #23
@derron If we start from scratch, then your right a text game with no asset files would be good to do. I think the space adventure would be good to do.

that's quite a list of bmx files you have online :)


AdamStrange1 week ago #24
I like the thought of a universe system. sorta like this:


with each system being zoomed into to show the system itself - sorta like this:


but that is really getting ahead of things...


Mainsworthy1 week ago #25
Adam If were doing graphics ,if you ever played elite frontier 2 , you moved a cursor that locked onto a planet or star as you moved around the map with the mouse, so the first map would be easy to do as it is, just define the zone for each dot.

the second map same thing except this second map would be different every time,, so define dot locations would need to be dynamic( I would have the same dot locations but either on off for all possible numbers of planets)

you would need a 3rd closer map for citys or moons or space stations in the same location.

so for the first module I would do a simple set of arrays , easily understood by all skill levels of the comunity

global universe[solor,sys,orbit,base,basetype]

global description$[solor,sys,orbit,base,basetypedescription]

global goods[solor,sys,orbit,base,basetype,comodity,comoditytype,number]

global army[solor,sys,orbit,base,basetype,army,armytype,number]

global ships[solor,sys,orbit,base,ships,shiptype,number] ship number 1 could be player, ship number 2 could be pirate, ship 3 trader, ship 4 army, ship 5 destroyer, ship 6 transport etc...

global shipsweapons[solor,sys,orbit,base,ship,weapontype,number]

global shipscargo[solor,sys,orbit,base,ship,cargotype,number]

global playerweapons[weapontype,number] weapons type can have shields and other types of equipment

global playercargo[weapontype,number] cargo can have rooms such as bridge engineering cabins etc...

THE ARRAYS HAVE TO BE SET IN STONE SO ALL MODULES CAN INTERACT WITH THEM.

so the second module select destination on the nav map. draw map mouseclick select one

third module save and load arrays.

fourth module display location & description etc...

fifth module draw HUD and select an action for a command set of buttons

sixth module movemen from A to B with interuptions for pirates etc,,,

seventh module pirate interdiction to movement

eigth module setup randomly generate arrays

ninth module buy and sell commodity, so transfer to ship and transfer to base,

tenth shipyard for upgrades

11th module combat(this is the most complicated, but if the other modules generate where all the pirates are, it should be smooth) I would keep it turn based, but its upto the programer

12th module generate who is where, eg where are the pirates.

THE IDEA HERE IS NO ONE IS RIGHT WE DO ANY MODULE AT ANY TIME, WE JUST NEED TO DEFINE THE MODULES THAT WE THEN CAN CHOOSE TO WORK ON AS WE WISH, BUT THE BASE HAS TO BE THE SAME FOR EVERYONE. SO IM TRYING TO LAY DOWN THE MODULE LIST PLEASE ADD TO IT BEFORE ANYBODY STARTS PROGRAMING.

THE INPUTS ARE ALL THE SAME THE ARRAYS

THE OUTPUTS ARE ALL THE SAME THE ARRAYS

I TRYING TO MAKE THE MODULES EASY FOR ANYBODY TO CONTRIBUTE


OK I HAVE NOW SET THE FRAMEWORK, WE NEED TO ADD AND AMEND. PLEASE PLEASE KEEP IN MIND THAT THIS IS FOR ANYBODY TO PARTISIPATE SO IT HAS TO BE SUPER SIMPLE.

Have I got it started then?


Mainsworthy1 week ago #26
all we have to do to start this community project is set the arrays in stone, DO WE AGREE SO FAR? once we agree its upto individual programers how they do each module , text or graphical, turnbased or real time, 2d or 3d

also if we set the arrays in stone, extra modules can be added to the list with ease, the world exists in the arrays.


Mainsworthy1 week ago #27
once we agree, the array structure has to be created, eg ship 1 player, ship number 2 pirate, ship number 3 trader,

base number 1 city, base 2, space station base 3 shipyard etc...


Mainsworthy1 week ago #28
there is another alternative, is to add modules to my game rogue 3 , eg the maps Adam has done can be inserted into a nav module in rogue 3 quite easily, we could use rogue 3 as our base starting point>?

all need be done is to take the emergency move back 5 button in rogue 3 and instead of moving take it to Adams Map, and select destination? call it navigation. then have the program at startup randomly create the paths from one location to all others, the distances are pre known.

replace rogue 3 random mission generation , now every individual journey would be the same each time you travel it, but different from all others. you could randomise some things like passengers.

I think this is a good improvement to rogue 3

IF I was being honest, I realy like rogue 3, and if it got worked on and improved that would be my first choice


AdamStrange1 week ago #29
mmm.
ok. a few points:

1. the rogue3 code runs fine on my mac

2. blitzmax will soon be dead on macOS when 32bit support is removed - it is comping rapidly, probably by the end of the year.

3. although blitzNG is 64bit, it is using max as the base and it really is past it.

Sooo, that would mean me having to say no on the coding front.
But... I moved to monkey2 and it is very similar and I can help hold any ones hand and I have a uber stable editor (which blitz does not)

Code style. I think here @Mainsworthy you might have a few issues with other people not using goto's, etc. In this respect you may have to up your programming skills - DONT despair I can hold you hand...

Similar to the above, even if the rogue3 source was used as a base it would need be cleaned up and made readable and more modern. E.G. #uuy is not a simple understandable label. #DrawIntro is.

Now... to kick start this. I will take rogue3 and convert to monkey2. I will modularise and reformat the code. and I will bring Mainsworthy with me...


AdamStrange1 week ago #30
ok. looked over the rogue3 code. You have some error in the code.

start game > click on blackmarket = unhandled exception. attempt to index array element beyond array length.

Checking the code line 794
If pos = 5 And raidrun2[pos2] < 5
pos2 is 99 maximum array size is 55!

I'll see about finding a fix


AdamStrange1 week ago #31
indenting...


Derron1 week ago #32
@ monkey2 conversion

I think this is a "nice" idea (not a good or superb ... a nice one) as this allows to introduce us to monkey2. Because modules would allow to try out things.

Did not check the editor but I do not like "custom solutions" which do not follow OS guidelines (shortcuts, behaviour ...). Hope this is properly done. So no OGL-Window hogging ressources but therefor an event driven widget system only doing something if it is really needed.


@ goto
Yepp, this is a nogo today. And readable names are areally needed. in collab projects "readability" and "guidelines" are a must.

So uber-complex formulas either need to be written "differently" or need clear documentation of what they do.

iDmg = (atkDmg*psyDmgMod)*(1-armPct*(1-atkTpArmRed))*(Rand(100)/100.0<hitCh)


It is not that beautiful isn't it - and I even used variable names which are not that hard.


'skip calculations if we did not hit at all
if (Rand(100)/100.0 > hitChance) then return 0


'damage calculation is done by calculating the effective
'armor and then calculate the effective out of  the incoming
'raw damage. This also includes modifiers of armor and damage
'based on the attack type (eg. used weapon type). 


'calculate effective armor
local armorReductionPercentage:Float = armorPercentage

'take into consideration the armor ignorance of certain attack types (heavy, light, pierce...)
armorReductionPercentage :* attackTypeArmorReduction


'calculate effectively incoming damage
local incomingDamage:Float = attackDamage

'increase or lower damage depending on how frightened you are of
'the visual appearance of that enemy (it hurts more if you are afraid)
incomingDamage :* psychologicDamageMod

'reduce damage to what the armor lets through
incomingDamage :* (1 - armorReductionPercentage)


return incomingDamage



Depending on how descriptive your Method/Variable/...-names become you could leave out some comments. But I assume while reading above's code you know what the code does.
But I understand, that "too much" of comments makes things less snappier looking - and not able to get "catched" in one blink of an eye.



bye
Ron


AdamStrange1 week ago #33
OK. first steps. monkey2 is event driven, so I'm afraid Mainsworthy is not going to initially like it

step 1.
basic monkey 2 setup with initial framework with documentation showing layout of a monkey2 system with basic keyboard handling
done

step2.
add mouse handling and introduce gamemodes. gamemodes are different mode of operation. E.G. in rogue3 the first thing is the intro with text. this is GAMEMODE_INTRO. next it goes into the game, or GAMEMODE_GAME
To make it play really nice with OS systems I have set up an 60fps timer which handles display.
done

step3.
assets...


AdamStrange1 week ago #34
step1 monkey code



AdamStrange1 week ago #35
step 2 monkey code



AdamStrange1 week ago #36
ok. refactoring the rogue3 blitzmax code

refactoring is when you take code, and reformat it, adding tabs, spaces, then commands. basically making it look nice

Once it has a modern look I will then go into the code and start looking at ways it can be tidied up. from there I will get a better idea of how next to progress ;)


Derron1 week ago #37
@ monkey2 step2
I think you should handle mouse hit and gamestate changes in update rather than mouseevent handling. So store mousehits similar to mouseX and mouseY. Else you will sooner or later running into problems if scenes or modes are added dynamically and a lot of key combinations get added. For simple two-state games this might be overkill but as soon as things get complex that input handling should be redirected to the screens/gamestates.


This means I would create a gamestate-class. If you do not want to store moushits and hit keys you will have to call the active gamestate during onkey/onmouse ...after! globally available things are handled (escape to switch to mainscreen or so).
So it is up to the gamestates to handle inputs.

The other method is to call them in update() in which they then check for mousehits or keys on their own. Resetting handled inputs afterwards.

At the end it is similar to how you handle draw/update of gamestates.



It's just a suggestion of how _I_ would tackle it.


Bye
Ron


AdamStrange1 week ago #38
I have to disagree here.
We are dealing with an even based system. The OnUpdate may never be called.
The only thing you can depend on is using the correct event systems.

This actually goes much deeper, in that... once you master event programming, you can create a stand alone class that fits directly into any model.

To correctly use event based models, you have to track what is happening and plan for it.

But I also agree that passing mouse and keystones to separate classes would be better. but we have to get used to using event systems in the first place.

Otherwise we will end up with massive duplication, which is overkill for something simple

The other issue is I am attempting to convert the blitzmax code directly to monkey2 code. I am not trying to 'do it the right way'


Derron1 week ago #39
@ disagree

This is what I was talking about "redirection of input handling"


So with a "gamestate class" you could have "onKeyEvent()" too, and "onMouseEvent()". The main-files onKeyEvent handles "application wide" things and then sends the event to the current gamestate.

BUT this would of course not act the way Mainsworthy was supposing (modules). For them you need to encapsulate inputs so they can "easily" access them.
You will end up having an "Inputstate"-module, which stores keystates, (mousebutton)states ...
All modules could access them - and eg. when handled an mouse button hit, reset its state.


I know that this _isn't_ strictly an event based programming as it caches event data, but it is imho the only way to create something "modular" as Mainsworthy proposed.


Another way to make it "event based" is to have each module be able to register for events (defined by "main"). So an "input module" would register for "onmouseevent" and "onkeyevent". Each event needs a function which gets called as soon as the event happens (parameter = event data).
You then end with checking whether a module handled an event, vetos it etc.

Dunno if monkey2 already implements something in this regards.


You see - things become pretty more complex to achieve something similar to what Mainsworthy suggested.


Maybe I am just seeing it from my POV and and there is a way better solution so I wont stop you from doing "your thing" (this "conversion") in monkey2 - and if it works, fine, if not, we at least might have learned a bit monkey2-coding.


@ stand alone class
I hope you are creating such a thing, am interested in it (and how you tackled the related problems). Always enjoy learning something (to eg. improve my game).

bye
Ron


AdamStrange1 week ago #40
the first thing is to finish the refactoring and then correct the bugs. lots of index overruns at the moment...

On saying that I have found the Mainsworthy is using a 10x10 grid as the screen drawing ;)


Mainsworthy1 week ago #41
I'm just waking to this and playing catchup, I wll get monkey 2 installed ASAP, and the index overruns Adam I'm sure the arrays can be increased in size without problems.

Thankyou Adam for this , I will study what you've done, I didn't think Id convert to monkey2 but onwards I will probably need help though thankyou Adam.

Derron I can see a collab you need descriptive names :)


AdamStrange1 week ago #42
Monkey2 comes with ted2go editor which gives intellisense, or you can download my own ted21 from itch.io too


AdamStrange1 week ago #43
ok...
Step 3
Lets add a class for ships



not a great deal has changed apart from adding the initial class definition which has one variable _energy and setters, getters for accessing this variable.
I know that it seems a bit long winded, but there is an inherent elegance and simplicity hiding in there.

I have added lots of help text to let you know what is going on.

The game draw routine now has a default 10x10 grid showing.

Next step is to show the energy onscreen


Mainsworthy1 week ago #44
Ok , I got Monkey2 installed, I also downloaded your editor, but I think I need to get used to default first so I know the basics, your editor was much more impressive and as a programmer I want it, but I found as a newbie I needed a more simple view, I will progress to yours after a few compiles and when I know all the directories etc...

I'm sorta following the code, I will need some experiments as I go, but this is exciting :)


AdamStrange1 week ago #45
i'm here to hold you hand. don't think that any question is dumb - just ask.

The best thing is to get a feel for things to begin with. there is a lot of stuff that is familiar, but a lot of really alien stuff in there too.

Again, just let me know if you want anything explained and I'll do my best...


Mainsworthy1 week ago #46
Image.Load( "asset::r3b.png"

what does the :: mean , I know this is OOP thingy probably meand directory variable, just wondering?


OK I'm FOLLOWING THIS QUITE WELL WITH THE DESCRIPTIVE WAY YOUR DOING IT, KEEP IT COMING :)


AdamStrange1 week ago #47
ok.
at the top of the file are 2 important #imports
#import <mojo>
#import <std>

std is the basic monkey2 language and support stuff
mojo is all the nice window and app stuff

Canvas comes from mojo and deals with the screen - the canvas if you will.
Mojo sets up a basic framework, and OnRender(canvas:Canvas) is called from there.

In practice, you will probably always be using this as a basis, so that is how it looks and works.

Yep
OnMouseEvent comes from mojo. Basically it has done all the nasty stuff for you - window, event, etc. You just need to deal with the nice stuff like responding and dealing with events.

OK the asset:: stuff is Marks way of abstracting things for you.
You know all the crap about getting resources being different on a mac from windows, and the trouble thing got into?
Well... When you #import an asset (from the asset folder) it gets put (inside mojo) into a list of available assets.

Image.Load("asset::file") means look inside the asset list and give me that asset.

Why is this odd and strange?
Well On ios, you might not be dealing with a folder, but a packed set of assets. You don't have to know how android or ios, or windows stored the assets, you just need to know, that when developing, every asset lives in the asset folder, and on compiling, all the assets are dragged around and put into their proper place for each system AUTOMATICALLY for you. In this respect Mark has done something wonderful for you.


Mainsworthy1 week ago #48
Adam this is great, I'm really getting into it now,

If I was doing step 4, I would of made a currentlocation class with ships forward ,right,rear & left, drifting fuel , cargo, antimatter and ore, & base ?

add gold , passengers & cargo to ship class ?

I'm not saying do it, I'm saying its making sence :)

universe class with mission track array[](so tracks can be added to each part of a wider universe in the future) ?


does the Import PNGs have a sprite cutting option? I'm assuming there all transparent .


Derron1 week ago #49
Instead of adding passengers to the ship you create a TCargo class...and extending classes like TCargoPassenger TCargoLiquid ...

Each cargo gets a Getter for the current mass... And flags telling if they are incompatible to cargos with certain flags... So a forbiddenFlag could say "flammable" and another cargo could have a flag as "flammable"... They could not get stored together in the cargo list of a ship.

Each cargo also knows its own price and gets informed on load or unload (so it could eg. Explode or create special events).


Of course they could/should be able to/... also register for events...when following Adams suggestions.


Bye
Ron


Mainsworthy1 week ago #50
Derron, I like the cargo flags it would make the game much more interesting, and your right passengers are cargo too, I think though we need a base classes to start from, then add to them, we need a simple springboard.

I cant believe I'm saying class, I never thought Id do this, and its a real class for me


Derron1 week ago #51
Next to "cargo" you could do the SAME for the crew. So eg. a "mechanic from Alpha Xcr" wont work as effective with a "female engineer from Earth".

But THESE are things people could extend in their own module. So the base stays, that there is some kind of "crew member"-class. People then replace it with their incarnations.
The base class just needs to know in advance what this class could modify ... or you do it with your globals-class.

So eg. the perfect team would result in 100% usage of the machinery in a ship. The less perfect a team is mixed, the less efficient the machinery is used.
To make it adjustable you need to have all these little "mods" (shipEfficiencyMod - 100% = 1.0) accessible for modification.

We ignore for now, that "Getters" are nicer because you could override them and therefor extend them. So a "GetShipEfficiencyMod:float()" could use the parental definition or take into consideration way more than just a basic float "shipEfficiencyMod").

(Edit: that "efficiency" could even decrease if you have loaded liquids or explosives or ... depending on the engine of a ship and how this engine is working - magnetic impulses versus nuclear warp. An extended "GetShipEfficiencyMod:float()" could take these things into consideration by calling other "Getters" which itself could again get overridden/extended by even more complex things to consider)


Sorry for getting "offtopic" again by bringing in "new ideas" to make things more and more complex.



As you both said: first get it converted/error-corrected.


bye
Ron


Mainsworthy1 week ago #52
Derron, its good to see these things, but right now I'm a noob at monkey2 , I just found the help files, Ive never programed like this, so it takes me a minite to know what GetShipEfficiencyMod:float() is made from, I can figure it out , but its not auto yet, but that said I'm lovin it :)


AdamStrange1 week ago #53
Last post for today.
Step 4. some graphics



in essence I am expanding the code step by step, so it is in little jumps with full explanation of what's going on and some of the new commands.

@Mainsworthy There are no stupid questions. I'm here to help in any way possible.

You will also need the new button graphic png:


This is called newButton.png <- watch the capitals

You'll also notice that it jumps straight into the game screen missing the intro. This is due to testing and if you look in the private section you will find a change to the following line:
field _gameMode:int = GAMEMODE_GAME'INTRO
where I've commented out the INTRO bit...


Mainsworthy1 week ago #54
can I create global arrays at the top like const? and run external functions defined at the top, can I use variables outside of the class like public section of a class(does that exist?) I will test it soon, just idle thinking

the help in M2 is nice so far :) wow having some successful tests now, this is fun, I think I'm going to adopt Monkey2 now as my game creator.


Mainsworthy1 week ago #55
if you create a _myship

'we now need to set up our first class - the ship
_myShip = New Ship()


myShip.Energy = 4, or energy = myShip.Energy

My serious Question here is if we create _myship why do we access its variables as myShip? without the underscore, whats the relationship with the underscores, I know this is some kind of OOP but I'm sure you could tell me better than I could figure.?

I have to thank you Adam for getting me into Monkey2, I'm rotating scaling transarenting, globaling arraying. and thankyou Monkey2 devs this is to cool to say, and its fun like starting to program all over again. but I am still puzzled by the _underscores


just seen For f = _myShip.Energy+1 To 28 , so maybe I was to quick to look at the comments rather than the code, but is there a reason for the underscores, are they to denote class variables or something, is it voluntary?


AdamStrange6 days ago #56
it's voluntary. but there is method in the madness

Variable naming is personal. you say yada, I say _yada. The first this the note is that monkey2 is case sensitive, so myVar is different from MyVar and different from myvar. in blitzmax they are all the same variable

if you look at the setters/getter/propery you will see it looks like this:
	Property Energy:int()
		Return _energy
	Setter( energy:int )
		_energy = energy
	End


and when you access the variable it is through 'Energy' the setter uses 'Energy' even though in the code it is 'energy'. To keep your head from going to mush Mark uses _energy as the internal variable.

so in a class internal variables are generally _(lowercase)variable
E.G.
_myVar
_energy
_gold
_lotsOfGold

external properties (things you can get/set are (uppercase)Variable
E.G.
MyVar
Energy
Gold
LotsOfGold

For constants. this that don't change, like the GAMEMODE_STUFF I use all caps. that way you instantly know what sort of variable it is.

The other thing is better naming of variables with caps
E.G.
myVar rather than myvar
or lotsOfGold rather that lotsofgold

again it's a clarity thing. you can instantly read lotsOfGold because the capitals stand out

What I'm trying to do is install some clarity in your code. it will be better for you, me and Mrs Quot at the corner shop will loveYouForIt2...

slightly off but related. It is better to start methods with a capital.

local variables (to a method) can just be normal, like j and f etc, but again stuff like uuuyys although valid isn't much help for readability.

I'm not going to talk about globals or functions, you can have then and I do in places, but if we keep things class related, you are going to see something magic happen...


AdamStrange6 days ago #57
ok. this is just so you know what i am going to be up to...
universe class with mission track array[](so tracks can be added to each part of a wider universe in the future) ?


I'm going to start a completely new app and work on this as a Class. It can then be directly included into the main source with nothing extra added to the main code - a MODULE!!!!!!! - yep, that can be extended simply.... magic...


AdamStrange6 days ago #58
universe step 1 ... 3 systems with planets


have a good look over the code. there are lots of comments removed so you should be starting to feel a bit happier.

This really introduces use to arrays and classes. and how to have arrays of classes
in this case solarsytems and planets. a solar system can have 2 to 12 planets. we are using the solarsytems position to create a unique seed, which we will use heavily to create planets in the next step


AdamStrange6 days ago #59
ok lets have a picture


and now the code:


Now.... If all my calculations and saying do this works correct. When you run the code you should see the above pic?


skidracer6 days ago #60
Loving this thread.

Here is a picture of Earth and Moon taken from Saturn by Cassini yesterday, not sure if it is relevant :)




AdamStrange6 days ago #61
the blue planet with the grey moon - loving it...


Derron6 days ago #62
@ codes
Please consider using "codebox" instead of "code" so they become scrollable and limited in their initial size/dimension.


@ skid
A pity you did not add a jscript-syntax-highlighter yet bigger sources are harder to read with "comments" being in the same color than "code".


@ case sensitive variables
Oh... did not know that. For me that is nearly to a "no go" as it relies on "superstrict" to catch mistakes (multiple variables because of UC/LC-errors) - and on an IDE which does autocomplete so you do not misspell things each time.
I know it is just a matter of "getting used to" but somehow I think this is nearly as "arghhh" as python's tab-intend with a meaning.


@ underscore
This is common for languages with no "private" statement - just to say to 3rd party developers: hands off! this is something you should not access directly.
EG. BlitzMax does not have "private" for non-module-code so "_" helps in that regards.

So if you want to read more about Adam's coding style: Wikipedia "lowerCamelCase" might be of interest.
So you will see most likely this:
Const UPPER_CASE_WITH_UNDERSCORES:int = 1
Local myVariable:int = 1
Method GetMyVariable:int()

For Classes and Types you often prepend them with "C" or "T" so you distinguish them from variables (eg. a global instance "Game" of type "TGame").
As you see monkey2 uses classes like "window" and not "TWindow" while BlitzMax has all these "TGraphics", "TImage" ... so maybe Mark already moved away from that "agreement".



@ Adam
Is there a reason to use "arrays" for the solar systems and not "lists" or similar things (with added "convenience")? Step-by-step learning?


Some things I saw by having a quick glance:

_planets is of fixed size (13) but you fill it with a random amount
-> replace _planetCount = Rnd( 2, 12 ) with "12" being equal to _planets.length (or how the property for the array-length is called in monkey2)
-> alternatively create a _planets-array corresponding to the random _planetCount


field _parent:int
versus
Property Parent:string()
int -> string ?


Property Planets:int()
-> you should really call it "PlanetCount" as "Planets" implies (for me) that it returns a list, stack, array or something "iterateable". I understand that you want to teach him that you can name it differently, but you should not forget to change that back later on.



Back to talking about "dynamically filled solar systems" - do not forget to replace your "for 0 to 2"-loops with a simple "eachin" iterating over all available systems (or loop over all indices of the solarsystem-array and "continue" if there is no valid system stored there).



Sorry if that interrupts your "tutorial flow" :-)


bye
Ron


AdamStrange6 days ago #63
universe step 3 - kinds of planets

lets have a picture


and some code:


ok so what had happened here then?
Basically some planet kinds have been defined as consts
as planets don't know anything about other planets, we reference them in the solar system when they are created. and here we do some simple checks just to give us something nice to play with (there is no magic, I'm not using NASA data or anything)
We also track the size and decide if it is small then possible make it a moon. and lastly we make sure that there aren't too many gasgiants

moons are denoted as moons and given a red link to show the orbit around a planet

Finally we draw the new data so it can be simply visualized. NOTE belts and nebulae are currently being drawn as planets. we can change this next time around...


skidracer6 days ago #64
Woot, frontpage news!


AdamStrange6 days ago #65
i'de wait for the next one first... Adding some graphics. just finishing it


Mainsworthy6 days ago #66
just about followed ok, it worked fine, diff pic slightly because my rand would be diff,

there is a lot of looping code in classes, one references another that references another, but it does make sence if built bit by bit.

whats the importance of protected vs private?

just seen more code added looking at it now.


AdamStrange6 days ago #67
last post for the day
Universe Step 4 - pretty pictures


and the code.


couple of changes to make asteroids always small
and the Planet Class has now got a color

big change in the OnRender where we draw the planets. this has a new method to draw pretty things.

But note that this has nothing to do with the actual planet class. it is just holding the data.


AdamStrange6 days ago #68
@ Mainsworthy

anything in the private section can ONLY be accessed from the class itself
So... in the main program
You can't use planet[ref]._kind
try it and see what happens

That is why we have setters and getters.

Now we could make another class that is derived from Planets - just accept that you can - wav are not doing this
anything in protected and private wouldn't be available to a deprived class

the top level, is usually called 'public', but we don't need to specify it directly
anything that is in public can be accessed from anything else

It's all a bit odd and strange to get your head around
Think of a class as your trousers (pants for the us)
anyone can touch them - the public part
Your mom can put her hands in your pocket, cause she's protected, but the public cant
Your other half can put their hands down the front - it's private. but your mom and the public can't...

Stop laughing right now!


Mainsworthy6 days ago #69
I think I just saw a moon orbiting a moon. looked through code dosnt seem this is possible

going to look through next code now.

thanks for the class descriptive

thx Derron too


Mainsworthy6 days ago #70
clamp( Ive never even heard of , if you go over does it shrink it back to max? and if you go under increases it to min, I will look it up.


Mainsworthy6 days ago #71
properties, fields and methods are now very clear

curious how to go full screen & what the command is to rotate riound midpoints, but I will look out for these.

a gamesave would be tricky looking, loading private arrays to different classes, I suppose it would be a setter code.


Mainsworthy6 days ago #72
can I just say Adam, this code your doing is realy good, thx so much for this. I know your doing a lot of design here aswell .


Derron6 days ago #73
Think my post above got lost in the shuffle:

please use {codebox} rather than {code} to store your sources here... as it leads to easier scrollable threads (textarea with size constraints rather than a "show all"-code-area).


@ clamp
Yes, it limits values to be between min and max.
It is similar to writing (in BlitzMax):
myVar = Max(minValue, Min(maxValue, myVar))


bye
Ron


Mainsworthy6 days ago #74
thx Derron.

I can see the magic of classes New MyGameLvl1() New MyGameLvl2() very easy to setup a whole structure. organised is the word I would use for class extending a class sounds fun.


Mainsworthy6 days ago #75
Adam we need a RingPlanet Property, not to important , just an observation :)


Mainsworthy6 days ago #76
The 1Bit clicker result is in about 9 hrs, hope you do well :)


Mainsworthy6 days ago #77
just found Fullscreen :) , and a lovly little help feature F1 displays a line at the bottom of the editor telling you where in the help files the info is, its easily missed, but once spotted :)


AdamStrange6 days ago #78
step 5 bug hunting

first a pic


now the code (in a box)


so what's new?
well, I went on a bug hunt and edited some code to do with the planets.

I added the ability to press space and the last 2 systems are given new positions, and therefore new planets. so you can see lots of different kinds.

Tidied up some display code

in the keypress method you will find RequestRender() this is sorta like flip. It refreshes the screen

nebulae now has graphics, stars and gasgiants have minimum sizes

moons and asteroids can also have the same. but all corrected

orbiting objects show correct redline to their parent <- all of this is mostly visual

@ Mainsworthy I'll get onto rings next...


Mainsworthy6 days ago #79
cant find any way to rotate on the midpoint, does this exist in monkey2, in blitz it was AutoMidHandle( enable )


Mainsworthy6 days ago #80
that looks spectacular! still looking at code, the flip & keypress has learned me a lot.


AdamStrange6 days ago #81
ok, last one of the day




more tidying and added rings for Mainsworthy.

I think (generally) we are done here.


AdamStrange6 days ago #82
ok. now we have to think about how next to progress

My thoughts are:
for each planet - decide what it has to offer and what it wants

you have nothing to start with, but money.

money buys a ship within certain parameters. E.G. cargo ore hold, slow light drive, no armaments. that sort of thing?

You could then setup a star route. goto planet A: collect ore from mine, goto planet C, deliver ore, repeat

Sort of Galactic tycoon... See Transport tycoon for general game play.

Start ship handoff things go.

on each game tick it travels a certain amount. Of course there may be problems along the way. engine overheat, raider, passenger eaten by cargo.

each time you deliver something you get money. more money means upgrade the ship, etc.

Lets assume that you start with a single 'known' star system. You could do space research that would reveal other star systems. you would need to travel to that system to start more research etc.

And on it could go...

You could have a set of quests as in Rogue3 which on completion give you more money than usual, but with greater risks.

Maybe several star systems have grouped together to form an alliance. maybe they don't like you trading in their territory. I don't know I'm just winging this one, but in essence it has some very nice legs attached to it...


Mainsworthy6 days ago #83
first off I think this will set it apart from any game of this type , is multiEvents on a single mission, if you think about it in a real space world travelling vast distancies the time and cargo and everything like delivering secret plans - mapping a space worms trajectory - refuel - photos for art buffs - cloneing all the sorts of things that would not take cargo space BUT instead would add to a single mission, the mission would need to be random & be comparable to all other random missions - or you would just keep generating until a good one popped up.

rewards don't just have to be gold, it can be life extension, land, trade route manooly for regular rent or goods, passwords to secret locations, time travel, I think this would set the game apart from others.

you could join military, or traders, or pirates, or minors, or ship builders, or weapons makers, or monks, all for different game winning goals - so again the game wont be all about credits.


Mainsworthy6 days ago #84
Adam I cant find any way to rotate on the midpoint, does this exist in monkey2, in blitz it was AutoMidHandle( enable )

This really would help me with a side app I'm planning, but I don't know what I'm doing yet , I have looked and looked but cant seem to locate this. don't worry Adam if your busy with above, just niggleing me l was going to experiment as we went along with the space one, but an interesting app is hard to think up, and right now I want a midpoint :)


Mainsworthy6 days ago #85
its amazing what you've done without asset art


Mainsworthy6 days ago #86
image.Handle=New Vec2f( .5,.5 )

hey found it :)

I'm going on about daft stuff because I'm a noob at OOP, but its finally sunk in, I can find my way around a bit.

I'm going to experiment with a side app to try out commands I come across, and to learn a bit,


Mainsworthy6 days ago #87

'================================


I don't know how to do a code box , please advise?

I didn't want to say what I was working on until I knew what I was doing, but I have made a large scrollable map that your planets and ships can be drawn on. you will have to provide a 2000x2000 png map.png file, and chit1.png and chit2.png 50x50 pixels, but the sizes are not strict.

this will be of use I'm sure, you could add the map offsets 800+_mX 800+_mY to your planet displays as an example I did a circle in the code,

I also think it will serve as a local map for all kinds of things, you just rightclick and drag to move the map ships and planets move with the map, I havnt put code to dynamically move the ships, you do that in the program, but I think its great for my first app. I also included a rotation variable for each ship


Mainsworthy6 days ago #88
forgot to do the midpoint handle, will do it.


Mainsworthy6 days ago #89





I don't know how to do a code box , please advise?

I didn't want to say what I was working on until I knew what I was doing, but I have made a large scrollable map that your planets and ships can be drawn on. you will have to provide a 2000x2000 png map.png file, and chit1.png and chit2.png 50x50 pixels, but the sizes are not strict.

this will be of use I'm sure, you could add the map offsets 800+_mX 800+_mY to your planet displays as an example I did a circle in the code, feel free to edit or streamline into the code, its upto you. the code for a mouseclick would just be a test for _mX + _mouseX , _mY + _mouseY

I also think it will serve as a local map for all kinds of things, you just rightclick and drag to move the map ships and planets move with the map, I havnt put code to dynamically move the ships, you do that in the program, but I think its great for my first app. I also included a rotation variable for each ship

I think the ships HUD could go on this, it would give a big display area for all kinds of things too. a vast display of cargo & ship or realy big display of onboard weapons, or a really big terminal, honestly Adam its great, just make a class and throw big diplays up all over

'ok done the midpoint rotation, an easy round button could be turned on the HUD of the big display.

ADAM IF YOU PUT THIS DISPLAY IN THE CODE AS A CLASS OR SOMETHING I WILL BE HOOKED ON DEVELOPING THIS APP? IT DOSNT HAVE TO USE YOUR PLANETS I'D LIKE IT IF THEY WAS, BUT IF YOU COULD INTERGRATE IT AS A FEATURE TO BE USED IN THE APP

This large map scrolling was not possible in blitzmax, wow its great, worth upgrading to monkey2 for this



Derron6 days ago #90
click on "forum codes"


There will be something like this:



So before you paste your code in the reply box write
{codebox}
and afterwards
{/codebox}

(of course with the right kind of brackets).


bye
Ron


Mainsworthy6 days ago #91
thx Derron :)

Adam, if you have seen the app Zun Tzu my App replicates that, and isn't much off being the complete equivalent, except ZunTzu isn't very easy to put your own maps and chits in as this app


AdamStrange5 days ago #92
Brilliant!!!!!!!!

ok. I made some changes - DONT BE WORRIED. IT'S ALL GOOD

changed the chit class to Unit as it just made a bit more sense
the unit class now has the drawing stuff moved into it

Monkey2 uses radians for rotation not degrees, so I added those functions for you
mouse right is generally not used, so I moved it to mouse left

like the concept. a system has finite bounds of 2000x2000 centred at 0,0
I have made adjustments to the unit code to support this for you

I have commented out your old code so you can see how the changes have affected things. Look over the code and get a feel for what I have done ;)




Derron5 days ago #93
@ mouse right
of course you could use mouse right ... there is no reason for a normal PC user to not use it :-)

But - if you are on a non "desktop pc" (linux windows) you should consider doing it differently.

left mouse button + modifier key (left ctrl + left mouse button click = right mouse button click)

or - do it as Adam suggested and make everything possible with one button. Benefit is then: the Mac users enjoy it (with their onebutton-mouse) and tablet users are able to use it without much hassle (like "two finger hit detection").



@ Adam
I think you should introduce multiple files - so the "basic" could stay as it is and does not have to get posted here again and again.
Also it makes it easier to keep track of what was changed (without doing manual "diffs").


Think if you make that planet drawing "modifyable" people could jump in creating some random planets (with continents etc).



bye
Ron


AdamStrange5 days ago #94
ok second version.

What I have done is gone over the code and added 100 'spatial' interval lines, and 0,0 centre lines

I have added scale/zoom working on the mouse wheel

I have corrected the map display for this as well as correcting all other display routines



NOTE
I have used some nice but weird code to get correct x/y offsets for the spatial lines

I have updated the unit drawing routines so the image/items are also drawn properly scaled

All scaling is operated from the 0,0 centre point


AdamStrange5 days ago #95
here's the images I knocked quickly and am using:
chit 1/2 - the ships



and the starmap background


I am not a fan of the big 2000x2000 image, but it will do currently and is good for testing. I do have a though on how this can be done, so we''l just keep it at the moment :)


AdamStrange5 days ago #96
next version. removed the chits and star and replaced with an array _units[]

I will make a new class that will manage these for us next



AdamStrange5 days ago #97
next version introducing a unitmanager

basically all the units are now added to the manager,
when we come to draw them, we let the manager deal with it.

What this means is the unit class and manager are now separate from the main program. later we will start splitting up the main text file into smaller ones (modules if you want to call them that...)



I am going to do one more version to add some magic about getting the mouse location...


Derron5 days ago #98
@ Background
Use a DrawBackground() and it is up to the people what and how they draw it (talking about some parallax animation effects or "living" nebulaes/fogs).


Talking about "managers" - maybe it is nice to have "move to" commands for the map so it moves to a certain cell/point. There are surely similar convenience things a "Map"-class would handle well (GetShipsInArea(x,y,radius) or such things).


PS: thanks for the codebox (makes scrolling a breeze).


bye
Ron


AdamStrange5 days ago #99
here's the last one for a bit.

Basically you now have resolution independent mouse checking of units. is the mouse over a unit or not

You will need to run the code and play with it first then have a look at how it was done.

It's very cheap to do as half of it was already being done with the drawing, we are just adding a few mouse bits into it...

the colors have changed slightly, light grey is normal, white is when the mouse is over. This is really just so you get a feel for what is gong on at this stage.




AdamStrange5 days ago #100
when will my last one be my last one?

ok, new bits added functions for drawing circles - yep monkey2 doesn't have these

Added a global - the only one to act as a timer

unit drawing updated to show when mouse is over with pulsing circle and blue color




Mainsworthy5 days ago #101
YES! Wow, you've really done magic with that :) I can see all kinds of clever bits to it. the scalling great aswell.

Thanks so much Adam, you've shown me worlds of stuff. lighting up the unit Wow is all I will say :)


Mainsworthy5 days ago #102
Adam, please keep the function to allow for a any background and units to be drawn by new functions, I'm planning a cockpit on a big mapscreen and a ships internal display of all rooms and stuff. It works as is, just don't contrict it into just maps if that's ok. I know class stuff does what I'm asking already, just remember I'm still a noob at MX2,

But my god this looks great, and your right Mac only has one click, didn't remember


AdamStrange5 days ago #103
hehehehehe...
oh your thinking of ships with rooms? I was just thinking about classing them as ships with settings...

But no worries. I am trying to do stuff that won't break any other stuff.

I do have some really interesting stuff to test. but very technical in the visuals department. I'll keep you posted - you will like the results. but i need to do lots of tests...


AdamStrange5 days ago #104
I promised something visual and cool. Here's a peek:


Nothin special here, just a blurred shot from the universe.
But wait, monkey2 doesn't have blur?

It does now - based on a GLSL shader concept, and still the same code...

so.... lets say you had a ui that needed to display on top of the current screen, Maybe sell stuff or setting, whatever.

Using this, the screen could be blurred and the ui shown on top of it

Further to this... You liked the way the planets looked. How about shaders dealing directly with the surface, that show cracks, sun spots, moving liquid, etc. without writing any new code (in the app)?


Blitzplotter5 days ago #105
last post for the day
Universe Step 4 - pretty picture


+1 from me - pretty pics indeed - sweet ;)


Mainsworthy5 days ago #106
the rooms are just big units, and things in the rooms like rockets are too, so no problems, I just don't want the flexibility to disappear with a map orientated flow, but they can coexist . the rooms can have there own class or drawn straight onto the map , probably a class for each function of the backdrop like cockpit

even combat could be done on a local map, and the galactic stack market listings could all fit on a big backdrop,

that blur looks like a telescope view :) I'm into Monkey2 now and class programing, phew never thought Id say that :) but its been an easy transition because of this


Mainsworthy5 days ago #107
I love how you dynamically assign chit images, my question is why are you using lots of setters, its a lot easier to just use a normal propery, I know private properties are safer from unwanted changes, are you doing it for good programing or is it nessasay, why I'm asking is if I want lots of properties for a chit do I need to make them all setters and getters?

a few little things, your code is very clever, but the map units need to be drawn from left to right and top to bottom , or the units will all overlap oddly if they are close together, also the lightingup a chit is fantastic, but if I want to select it to change a property all overlapping chits would be hard to select, it actualy may work in practice , but if you had a room with cargo and rockets ontop of each other or near if rotated then selecting a single unit would be hard. I would use a for next loop to start at the centre of a units x,y and progressively expand to say 100 pixels in all 4 directions, the first one it finds it then exits the loop with the units number and x,y. .



I'm not saying to do this, I'm just sharing what I think may help, were not at a point its to important yet,. and we may not need it if everything never overlaps

don't forget to rest Adam, your doing wonders


Derron5 days ago #108
Setters allow for custom things or further checks.

So setting the name of a planet might invalidate a cached image so a prebuild image is regenerated automatically.

Every "indirection" allows to hook in and modify behaviour or extend it.

Eg. A unit has a setHealth() method. Normal units just assign health to health. But there is a spirit-connected healer. He gives 50 of the health to connected spirits in its setHealth imementation.


Bye
Ron


Mainsworthy5 days ago #109
Thanks Derron,


Mainsworthy4 days ago #110
I played all night with your code Adam, I didn't achieve anything except a good understanding of whats what, I love the array of class's , and you centred the map around zero, I spent some time with the wrong coordinates until I realised what you did. I love class's now cant never go back :)


AdamStrange4 days ago #111
lol
Classes are brilliant,that van bite, but brilliant.

A good way to think about them is small programs.
Each class is really a small program. the main app, tells other smaller bits (classes) what to do. so you main app becomes the place that has the entire overview of everything. the classes don't need to know about other classes -unless you want them to...


AdamStrange4 days ago #112
ok heres a pic of what I'm working on - the planet code


I've needed to make some changes to monkey2 itself, so can't (currently) post the code for you.

But. And here it is....
These new planets are dynamic! You are not looking at a static picture they are a seething mass of swirling, ever-changing patterns.
They are based on shader code, very cool and completely 2d

I should also add that the design of the new planets comes directly from Space 1999


AdamStrange4 days ago #113
Next pic


gas giants now have horizontal stripes, stars now have flames, planet rings now rings the different orientations.

Nearly finished with the planets, and stuff. Just nebulae, blackholesand stuff to do

contrast this with the initial concept:


it's really only the addition of some sneaky shaders


Mainsworthy4 days ago #114
Adam, they look fantastic, they really do look like amazing, but changing M2 code is scary, I don't think people would join in a project if they had to change the compiler.

When you say the classes don't know about other classes unless you want them to, what do you mean, I found you can make a variable of type class, and you can set public vars, and you can send class in the calling paramiters is there any other way Ive missed


AdamStrange4 days ago #115
last shot of the day.


two classes A and B
A doesn't know anything about B.
E.G.
A can't access vars from B


Mainsworthy4 days ago #116
Your blazing light years. I see the stations are moons too.


Mainsworthy4 days ago #117
two classes A and B
A doesn't know anything about B.
E.G.
A can't access vars from B

WHAT iM REALY ASKING IS HOW DO I CHANGE VARS FROM A DIFFERENT CLASS?


AdamStrange4 days ago #118
the app is the bridge

it created A and B and can pass and inspect variables of both A and B.

so...
All this A and B stuff is not helping.

What do you want to do?
E.G. 4 ships and a map
The ships each have a position, but don't know anything about the other ships

but the app knows all about the ships and the map, so you do all the interesting stuff like checking ship positions, in the app and not in the ship class

lets say each ship has a position
in the manager you do the checking for each ship there. the manager knows all about each ship

it's a bit like an inverted tree with the app at the top, and lots of classes underneath. if the classes need access to each others data. go up the level 1 to the caller(creator), it should be the one that has access to the things it's created.

This might all sound like bull. But... if you tell me what you want to do. then I can see about getting you the best (simplest) way of doing it without confusing you ;)

HOW DO I CHANGE VARS FROM A DIFFERENT CLASS?

Directly, you shouldn't. The class should say Hi I want to do something and it's parent does it for it. The parent knows all and sees all


Derron4 days ago #119
To have classes not know each other has also the benefit of increased "re-useability".

While it is not waht Adam explained it is good to have "TEnemyWithSound" being the only one knowing "TSoundEngine" while "TEnemyBase" does not know it (and therefor does not need to include the soundengine (and its systemlibraries etc.).

The only thing other classed need to know about a class could be defined in the "base class" (or in an "interface"). it defines the in- and out-going data/methods the extending classes have in common. So all have a "DrawBackground()" "GetSpeed()" and so on.


What Adam suggested does not necessarily do the above thing. There might be hard wired connections between classes.

So this might be troublesome:
otherShipsSpeed = GetManager().GetShip(123).GetSpeed()

because you then need to know the class returned by "GetShip(123)". It works, if that class is the same (or a parental class - or if you imported the definition/class-file too).
To make it really "independend" from the real implementation you would need a base manager class (or interface or so) which has "GetShipSpeed(id)" and it returns eg. "0" in all cases, as it does not know about ships.
Then you add a new manager class extending the base manager. And there you override "GetShipSpeed()" to return the speed of the actual requested ship.
Then you eg. add a global variable "manager" which is defined as being of type "base manager" while the content is created with type "manager" (this is possible as the ladder extends the base manager).

This allows to import just the base manager (without further dependencies) and ask the base manager for a ship's speed without knowing about "ship classes".

Similar things could be done by having "GetShip()" returning a "base ship" class object which of course might be a "ship" class object and every call to "GetSpeed()" is doing what I have written in the start of this post.


Also something to annotate: if A does not know B's details but want to know something about B then of course you need to ask someone who knows it - and this is the parental container or a manager. Benefit is also something like "access control".

If a ship could directly request "GetSecretCargo()" then you might run into trouble. You could extend "GetSecretCargo()" to accept "askingShip" as parameter but then you end up having no "centralized" method for restricting such accesses.
A Manager knows where a ship is, and eg. if there is a "holo warp tunnel" near them, so their scans could check the other ship. It also could check if the owner of the ship is the same and they have access to the same "ship cargo database".
You redirect these checks to a class which knows more about the universe, which could ask other classes, classes the ships do not need to know about.
Nonetheless you end up to add "GetSecretCargo()" to a ship - that way the ship class itself is able to override what it returns as answer (eg. if there is a spy on the ship it might fake the data...).


bye
Ron


Mainsworthy4 days ago #120
Ok here is what I was trying to change the display of ships, not from midX and middy but from the real x,y because they need a priority from left to right and top to bottom, if units are overlapping it will matter if there are lots of ships rockets etc..

second I wanted to select a ship without selecting the ships its overlapping. _over lightsup all ships even overlapping, so if you wanted to move a ship you need a way to select just top ship.

I also want to have more variable for each ship I can change when selected, like health armor. I'm not going to be doing this from unit or unitmanager I will be doing it from a control class (the bridge)

this is what I was messing with last night, I found I was running around looking for the source of the variables, but I'm getting the hang of it, but I'm trying to stay away from globals etc... I was trying to give a priority here is the code I was doing, it had an effect but didn't work right, its probably not correct way to do it, it is a testing code I was working on it has a double loop not correct I was testing




AdamStrange4 days ago #121
. ok the first bit about the ordering and display priority.
There is a really nice way to do it. at this stage don't worry about it. it is a display issue and we can look at that later - but it's sorted ;)

second the selection.
yep, this is a problem. but a good one.
the selection will not be 'top one', but whatever is closest to the start of the array of units
basically we introduce some counters.
The manager counts how many units are selected (some units like bombs or missiles can't be selected so that will need to be thought of)
you then have a second counter which decides which of the selected units to show.
Either this could be done automatically, or done when the user presses a key (like shift) and clicks.
I can write an update to deal with this for you.
So... Don't worry too much about that one

this point - no problem, just add some more to the base unit class.

Here's something to consider. if the base unit class knows about lots of things. E.G. how big the hold is, what cargo is has, what it wants, etc

the only different between a planet and a ship, is the planet doesn't move, and has a big 'hold', etc. When you come into contact with the planet. decrements what it has and increments them into your ship (space allowing)

I think I should do some work on the solar system and movement. get one thing finished and then move on to the next thing.

Mainworthy - I know you move fast and on to the next thing. But you are going reap many rewards by taking a step back and having a quick think about the What, How, and Why's of the game.

We can certainly replicate Elite at a basic level and concept now....


Mainsworthy4 days ago #122
ok Adam, I'm Happy to learn from this, I will definatly enjoy it, thanks for this,


Derron4 days ago #123
>the only different between a planet and a ship, is the planet doesn't move, and has a big 'hold'


This is what "components" are made for. You end up having basic entity classes and add components. This way you could add things like "cargo/hold" or "weapons" (which have upgraded and so on).

But even without an entity-system you could do what I described (think so at least) in a post way earlier in this thread.
The idea is to not have a "list of cargos" in a ship, but a whole object "cargo:TCargo". Cargo has its own methods (GetCapacity(), Unload(), Seal(), UnSeal() ...).
That way even planets could get their own cargo / holds ...

It even allows to "steal" the whole cargo-module from a ship :-)

Weapon-components could come in handy too as you could upgrade weapons - eg. add a "homing missile-radar"-tech-upgrade to your basic rocket launcher. Of course you could keep it easy and just create another weapon type (HomingMissileRocketLauncher extends RocketLauncher) but this is less "dynamic/versatile".


Think this "component-like" approach will be something you like once you understood the benefits. But let's first follow what Adam is doing "in collaboration with himself" ;-)


bye
Ron


Mainsworthy4 days ago #124
wow a class has a variable of a cargo class , did I say wow. :)


Mainsworthy4 days ago #125
@Adam if you create a display priority, then selecting a unit is done too, just use the highest priority unit selected. I look forward to the next class :)


therevills4 days ago #126
Woah! I totally missed this thread! Some top stuff in it!


Mainsworthy3 days ago #127
therevills, feel free to join-in with us?


AdamStrange3 days ago #128
just woke up.
@Mainsworthy Indenting. ifs are indented. so are for. it's about clarity.
I've not checked what the code does, but I have reformatted it with correct indenting. .. ;/


Yep. I'm being a bit pedantic here. But once you get into the habit, it will make you life sooo much simpler ;)


AdamStrange3 days ago #129
checked the code, didn't work only one ship displayed and no planets.
but I can see what you are trying to do.

I'll get a working version back to you...


AdamStrange3 days ago #130
ok Here's the latest with multiple planets and planetary rotation.


basically some minor changes within the manager and drawing routines. and now with added parents. so planets can rotate around a parent.
quite mesmerising and very simple.

OK next up will be the corrected display.
YES IM WORKING ON IT. Shut up and eat your breakfast!


AdamStrange3 days ago #131
we're on a roll now - a ham roll!
This is the new version with the unit sorting.

there has been a bit of shifting around of stuff and modifying code. but as you are starting to know the code. it won't be all alien to you.

Basically we pre find the screen locations of any units. What we really want is the actual y locations.

we don't need to deal with left to right (on top of each other X) as it's not really that useful.
But For any top down map, the further away the Y is, it must be drawn first.
This works even if we change our eye position and look at it from the side!

Guess what, it even works in 3d and 2d and brilliant for sprite sorting too.

So... We do a quick bubble sort on the screen y locations (we only change the int references, so the data stays exactly where it was placed and not moved around) <- moving data around is costly, so we only move a single int around.

I've also split the dashed line in two, so we can draw the back and front separately.

The 'select only the top thing' is not yet implemented

heres the code:



Matty3 days ago #132
This is quite good. I like this.


AdamStrange3 days ago #133
latest
I know you are gonna love the one Mainsworthy
It's got logical picking. so the top most item is the one selected

the basic premise is a few lines added to the update manager routine which reverse finds the first thing we are over and then turns off anything else

here's the code



Mainsworthy3 days ago #134
That's is a galactic App, the velocity and eye, and top selection , this is superman stuff.

I am going to have to look at this overnight and figure everything out, it is clearer seeing it as your updating.


AdamStrange3 days ago #135
yep. I'm trying to do it all in little steps as there is a lot to get your head around - especially moving to a new language.

As I said before - I'm here to help - I might not describe thing in the best way, but hopefully you'll get most from the code.

The YDraw sorting is kinda magic, but works really well. now it's written you don't even have to understand it, it just works...

I'm sorta looking at UI, bringing the planet stuff over, etc. nothing will be updated till tomorrow now...


Mainsworthy3 days ago #136
I must say this is incredible , the little rotating moons are great. selection is great. I really like my own enthusiasm to read your code and play around with it, you progress with it at a blazing rate for it to all be correct as well. its is allowing me to progress with learning far faster than I could on myself and that's if I ever would of moved to class's, sorry GOTO ! old friend , your use is gone:)


AdamStrange2 days ago #137
thanks. Let's call it a learning project

But i'm ve mindful of the initial premise of based on rogue3 with quests, and missions and am not forgetting about that. either


AdamStrange2 days ago #138
OK. just updating so you know what's going on.
I'm writing a UI system. This will be something new and very nice and will be the main way of communicating with buttons, etc.

It's not a simple thing, but I already have all the code written. I am stripping a lot of stuff to make it simple to understand and build it one step at a time ;)

You will thank me for this one...


AdamStrange2 days ago #139
this is the big one (007)....

basically I have created to new classes UXPageView and UXControl
the page is the manager, it handles all the controls
the controls will be a new thing that will do all the nice stuff and be very extendable and simple
But. the nasty part is this bit - the setting up.

We need a page and controls. and make sure we track the window sizes and feed them to the page.
then we simply tell the page to do the drawing and off it goes

Here's the base code. you should see an blue grid with orange bits on the left...



AdamStrange2 days ago #140
and now...
The finished nasty version with a lot more controls stuff going on inside.
The mouse is hooked up correctly and the control now highlight and clicks correctly

Finally we introduce Lambdas. In this versions we are using them to signal from each button back to the main app that it has been clicked.
We then print some text in the console so you know a click has happened.

in it's purest form the page and Control system is complete. we will tinker with it here are there to add little bits. but in essence complete.

We could push it out to a separate file, but I think it works best all together (at the moment)

So...
Here's the code



Mainsworthy2 days ago #141
wo, that was a jump in complexity, I am still following ,I'm glad your explaining makes it understandable, never seen type Eachin before, but I will look it up, and Lambdas never seen that, but I seen it in the help files.

but all in all this is very good stuff, I'm glad your going to complete the game, its what this is about, so happy about that.

I like the way you can drop classes into future apps too, as there practicaly self contained, its making sence.


AdamStrange2 days ago #142
Yep. I'm really sorry about the complexity. But you will like it in the end.

The page and control system is the most complex. I'm testing and debugging all the time and it does just work. And its nice and portable and simple when you start to ignore the base classes...

I'll have another update soonish which will show some magic...


AdamStrange2 days ago #143
ok, you ready for some magic....?

what we are now going to do is subclass the UXControl.
This means use everything the UXControl has and add any bits we want.

In this case we are going to make a button that shows text
and an image button that shows an image
First you will need the images
the first is hex1.png

the next hex2.png


and now the code...


you should see a number of different buttons, some with different colors and text. and an image that is clickable.

You can also see the page grid has been made visible, so you can see how it all fits.
try changing some of the variables for the grid settings

or maybe give a different image for the image button

Here is a pic of this in operation, so you can see what it should look like:


Check out the new() of the main app to see how these are set up


Mainsworthy2 days ago #144
Wow, Ive got to look closer at the code, but wow, setting up buttons and positions is great!

I can see how building a flexible UI would well fit into this App.


Mainsworthy1 day ago #145
Ok ,I am taking a back seat, just playing with code, I'm doing an App from the beginning that I will plug into yours when you've done it, so I can develop some extra parts of the game if you wanted that is, its not pretty yet but I'm learning as I go. Ive got a similar type setup map and chits,But I totally rewritten it, but I'm thinking of it being a separate entity for displaying cargo images on a big ship display, or something of use to us, I love the way these classes can be added ontop of an app. you may not want my code in the game I'm studying the method of creating an App.

I've not used setters yet, but the code is working, you can move chits and rotate them. figured out all the formulas that was fun :) the chit selection is 50x50 from top, but it scales with the map.

Adam, you need to remember I'm experimenting, and its not ready for use by others yet, but I thought you would like a preview of it for fun,it uses right and left mouseclicks at the moment sorry, and I'm using a simple menu built into the window class , It can be slid into your UI, you may like the formulas too they are crazy but they worked, I now know why you used a unitmanger class :) I love monkey2 now.

rightclick on an empty part of the map to deselect.

I HAD TO SIMPLIFY AN APP FOR MYSELF TO ALLOW ME TO CONTRIBUTE AT A LATTER STAGE, AS YOUR CODE IS ULTRA PERFECT AND TAILORED FOR YOU, I KNOW I SHOULD PROGRAM LIKE YOUR SHOWING ME , MAYBE WHEN IM MORE FAMILIAR WITH IT. I CAN ADD TO YOUR CODE IN THE GAMECODE YOUR SHOWING ME AND I CAN USE THE SIMPLE METHODS FOR SOME THINGS AND IT WILL GIVE ME A BASE TO DO THINGS LATER.

I DONT WANT TO STOP WITH WHAT WERE DOING, I JUST THOUGHT YOU WOULD APPRECIATE I'M LEARNING A LOT, AND YOUR TIME ISN'T WASTED, AND MY LEARNING IS EXTRA TO CREATING THE GAME. I THINK I MAY WRITE A UI LIKE YOURS IN THE FUTURE TOO, BUT USEING YOURS IS GREAT

you will need some files THEY START AT 1 NOT 0

#Import "assets/map.png"
#Import "assets/chit1.png"
#Import "assets/chit2.png"
#Import "assets/chit3.png"
#Import "assets/chit4.png"
#Import "assets/chit5.png"
#Import "assets/chit6.png"
#Import "assets/chit7.png"
#Import "assets/chit8.png"
#Import "assets/dashed.png"


NAME THIS FILE dashed.png






AdamStrange1 day ago #146
You know what. brilliant

My thoughts are dashed.png would be better replaced by a draw rect and some UXButtons - but that code still doesn't exist, so what you have done is brilliant!

my only complaint would be indenting.
use tab and not space

Apart from that... brilliant


AdamStrange1 day ago #147
ok. Here's a quick change.

I've been working on the UI controls. added text text align, sorted out some problems.

Using the basis of what you just showed:
I added a panel with three buttons, like above

Check the new to see how you set up a UI to do this:



AdamStrange1 day ago #148
working on modularising the planets into a single galaxy.
galaxy has solarsytems (up to 255)
solar systems have planets (up to 16)

My thought here is that each solar system will have a mission tree.
You can do the missions or not, just trade, fight, or whatever. <- this will be the same as the missions in rogue 3

But. I thought that missions could be completed in batches.
say there were 12 missions. grouped in 4 (which gives 3)
only the first set of missions were available. the next set would not by unlocked until you have completed all the first 4.

One a sub set of missions are complete you would get something - don't know what? upgrade, points, gold, unlock new system???


AdamStrange1 day ago #149
ok, here's a pic


This shows the new galaxy map with 3 solar systems. I think it would be nice to show the current system at the bottom using the new planet drawing code?


AdamStrange1 day ago #150
mmmmmm. thoughts

Lets assume that each solar system can accept/trade a number of base things

to keep it simple lets keep these to a small amount

we could list the available 'things' in a list on the top right going down.
select the thing you are interested in and the systems that match will be highlighted on the map

on the right we could list factions/alliences. again keep this simple and small.
so you could be aligned to a certain faction/alience and get more favourable results.
factions could then have desires, which might lead to conflict with other factions... etc


Derron1 day ago #151
Do not forget to add taxes... So exporting and importing costs a bit. There might wven be taxes for "cross solar system trade". And these taxes change according wbo leads a galaxy ("secures" it). Imho this is who owns the most planets in that system.


This allows to "smuggle* ...means to not pay exports/imports with the danger of getting stopped by a ship of the "leader" who then attack you / seize goods ...


Taxes bring in some economical strategy... To whom you export to (they know you then and chances for checks of your cargo lower a bit) also knowing about wars between leaders allow to predict ownership changes and therefor changes in taxes and prices of goods.



Bye
Ron


Mainsworthy1 day ago #152
Ok I'm following along, I will be interested in how you move a Unit around.

I thought a goal for the player could be cyborg implants as a reward , to allow longer life or more abilities :)

Derron Tax & smuggling tax avoidance is great idea


AdamStrange19 hours ago #153
yep smuggling and taxes is a great concept


Mainsworthy18 hours ago #154


I'm making tons of mistakes, but the compiler is the best Ive ever used, very good at spotting errors and telling you what they are,

I tried making a few classes that messedup, tried feeding events into classes messed up, tried to setup arrays of chits but ended up with a big list of chits, that unitmanager sure looks good now, I thought that having to enter every image name, I would not need a unitmanager, but forgot I could have copies.

Here is my crapy code so far, but it works and some elements may be of use, just remember I'm still at noob at this



Ive not used setters yet, or commented, but its pretty simple what Ive done, I really messed up not having a dynamic addchit method and manager class, but at least I'm learning :)


AdamStrange16 hours ago #155
ok, only comment so far just looking at the code
I only scrolled though the code and saw all the 'chits'.
Dump them all. keep 2 or 4 and just get rid of every other image load.

reasons:
1. they are just confusing everything. KEEP IT SIMPLE
2. You code is no longer testable by others without having access to all the images - not a good solution
3. what are there so many. you should be focussing on the code and not the images
4. theres a huge amount of 'if mouse is at this position'. Although I can guess what it is doing -> checking for a position on screen that relates to a pseudo button. what happens if you need to alter the UI in any way? You would need to go through all the code and start working out where it is going wrong.

OK. That's just letting you know some pits that are before you.

I've been working separating the code I've got here into bits, so hopefully the UI stuff can be forgotten about. I'll post something today...


AdamStrange16 hours ago #156
Just to recap. get rid of all the chitimages - just use 2
enemy 1 and an enemy 2
When you create a new unit just set it to be either one or the other. You are NEVER going to have 100 different types of things and be able to work out how to get any further.

You MUST keep it simple at this stage

Just concentrate on your workflow and feeling happy about thing first.. please ;)


Mainsworthy16 hours ago #157
Adam, I was working on a separate entity to you, to addon at a later stage I needed lots of images for creating a ships internal display, rockets cargo crew fuel lasers ore goods robots all that sort of stuff. I can visualise a massive ships mechanisms , I know were doing elite type, but I think this would be a cool addon maybe. I'm was doing what I was able as a noob, I'm still into your code, but I needed to learn at the same time, don't take my code to seriously I'm on a back seat.

This just fell into my lap, Ive added a couple of dice rollers and already created an app, its need artworks but the app is running ok for a tabletop miniatures game.

https://numbergamer8.itch.io/miniatures-game-tool

I put the file here for download, I know I had lots of chits.

I understand workflow, and what we need to be doing, I was testing out what your showing me , I'm enjoying the project a lot , I'm finished with experimental side flow now, I will get right to reviewing more code. I think the game were are doing is incredible and you code like a professor, I'm wondering how you code so well, you've impressed me for ever.

PS: I could not keep up with workflow unless I tried a few things out, Ive got a sound idea now of what monkey and classes are, now I can look at your code with a better viewpoint.


Derron15 hours ago #158
You do not need "graphics" in this stage at all.

-> give your units class a "draw()" command - maybe even a "drawbackground, drawforeground"

If you unit has "weapons" then either have a "ship extends unit"-class or have "weapons" being of type "weapon" including a "DrawAsShipInteriour()" method

Principle is: Ship defines area to draw to (x,y,w,h) and it is up to the weapon to draw itself into that portion - how it does it? It does not matter - DrawOval() or DrawImage() - it is up to the implementation of the class and could be done in a later stage.


@ if mouse is at this position
You do need to abstract things.
Instead of
If mouseX() > 10 and mouseX() < 20 ... then HandleClickedButton1()

you need to have it that way (at another location in the code...):
UX.update()
and at the mouseX-line you need:
if button1.IsClicked() then HandleClickedButton1()

UX.update (or how Adam supposes to handle it) is there to check all the GUI elements whether they get hovered and "hit" or "clicked" or maybe "dragged/dropped" ...
It refreshes states of the contained elements.


If you do not want to use that UXManager ... you could call "button.update()" which does the mouse-position checks in relation to its own ScreenCoordinates.
Using this approach allows to move or resize a button ("SetX(10)") and the update() will automatically handle it.
Yes, you could do this "procedurally" with your lines of "ifs" too but this allows to manipulate things where it belongs to: in the methods of an object, not somewhere in your application.



@ hundred different types
Think of these types to equal to "Red car", "blue car", "green car". you already knew before, that you could store the "color" as a property of a car. Similar things could be done with armory, weapons, ... of a ship.

So as soon as things share many properties it is a good thing to have them base on the same class (or use interfaces or "components").

To distinguish things, you just use what Adam (I believe at least) already did with the planet types - you create an "enum" (or just numbers) to define a distinguishable typeID for the ship.
TYPE_SHIP_DESTROYER
TYPE_SHIP_TRANSPORTER
...

But of course you could stay using individual classes for each of them - I would use that eg. to split "planets" from "ships" ... just to avoid checks like
"is type =TYPE_PLANET or type = TYPE_MOON or type = TYPE_SUN ..."
just to see whether a ship hit something "planetish". With planets extending from "TPlanet" you could do a
"if TPlanet(crashingObject) then ..."

Just to complete things. Of course a Method of the unit could be called "IsPlanet:int()" and returns true for the types listed above.


There are so many ways to Rome so do not see above things as a "must", they are more "suggestions" based on personal experiences. So if Adam says "do not do this at this stage" you should consider doing so.


bye
Ron


AdamStrange14 hours ago #159
ok. lets step back a bit...

The current code with the UI stuff is getting complex.

So...
I've separated it out along with the nice drawing stuff.

I'll start a new app and just detail some of the UI stuff. that way we can keep things at a nice simple level, and everyone can focus on the important stuff which is getting a feel for how it all works.

..... we can then use this new knowledge in oodles of ways :)


Mainsworthy14 hours ago #160
You guys are fantastic at this, and I have learned from you even when I didn't think I needed to, so I take everything you guys say seriously, my code was just a playabout, don't worry about it, if it became usefull all the good, else it was a learning lesson.

I found I did not know the rules of the class flow, I still cant pass a mouse event to a class that's whats Adams UI is doing.


AdamStrange13 hours ago #161
ok, this is going to get a bit nasty...

But bear with me

You already have the graphic for chit1.png

now here are the sources.
There are 4:
GameUI.monkey2 is the core of the UI. i would not recommend changing anything in there, but please have a good look.

GameUIExtras.monkey2 is the nice other stuff like drawing frames, ellipses, etc. consider this a helper which the other UI stuff depend on. These are functions so they can be called outside of the UI in you own app.

GameUIBaseControls.monkey2 this is where the fun starts. All the stuff in gameui was the setup stuff. the nasty stuff.
We now use the base classes and create our own simple controls from these. don't worry if you don't understand. everything is commented.
Basically we now have custom ui controls for:
UXButton - nice clickys things
UXImageButton - nice clicks things with images on them
UXPanel - draw a nice coloured or textured panel with images if you want
UXText - simple text drawing with bold and different colors along with custom alignments

So here are those first three:
GameUI.monkey2



GameUIExtras.monkey2



and finally the controls: GameUIBaseControls.monkey2



Now we need a demo...


Have a play and then have a look at this source. notice how it operates?
There is no processing, just set up each control, where it lives and any other bits we might want. and it just does it. I've sorted out virtually all the nasty stuff for us...

it is arranged into three lessons, with 4 pages. 3 of which are dynamically shown and hidden as needed.

The best thing I can suggest is to have a play around with this and get a feel for it.

Also. UI design is not the simplest thing. there is always lots of setting up and stuff like that. but...


Derron10 hours ago #162
Page.ShowGrid = false
RequestRender()
...

I would suggest do use setters (showGrid(falae)).

As soon as a setter changes something (so it was not false before) you mark the widget as "dirty".

If a widget is dirty then a render is requested. That way you could handle multiple things in ine turn without multiple renderrequests..
If you do not do partial rendering (only area of a widget) you could also have "dirty" stored globally for all widgets in the uxmanager class.


PS: good to see sources split into files. This will ease to follow the changes in the main project.



Bye
Ron


AdamStrange10 hours ago #163
ok. I've been brainstorming

1. the galaxy has 256 solar systems
2. each solar system is unique
3. there are 7 factions, each based in a home solar system
4. the central system is also present and generally where you start. But you could align yourself to anyone of the 7 factions and start there instead

5. The other solarsytems are unknown, and you can't visit them when you start

I will see about giving factions colors and icons and also see about spreading outwards from each home system. that way we could have potential systems that have more than one faction, and therefore possibly have trouble...


AdamStrange10 hours ago #164
Here's a shot of the galaxy map showing the location of the seven factions and the center.

The colors are also correct. with grey being a system that has no dominant faction.

There is also a work in progress UI




skidracer3 hours ago #165
Mainsworthy, what do you mean by pass a mouse event?

Typically, as an application, you catch events.


Mainsworthy3 hours ago #166
@skidracer, sorry the mouse drove me crazy trying to look at it from within a subclass, but I know its simple, will get it soon, Ive only been at this a couple of days.


@Adam thankyou for those Apps, I am going to look in a little while, .

@Derron your like the sound of a Air traffic controller guideing us in :)


Blitz Social Club