Giter VIP home page Giter VIP logo

hurkalumo's People

Contributors

furthen64 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hurkalumo's Issues

Replace all HPos with PixPos and IsoPos

This is a BIG task.

Might take a couple of weeks to do working at a slow pace.
Take your time, make it right, make it tight.

What about "Gpix TopLeft" and "Gpix Middle"?
I'll have to think about that one.

  • Think about Gpix TopLeft and Gpix Middle
  • Split HPos to PixPos and IsoPos class instances
  • Write (more) unit test code for position correctness

Dijkstra that bus

Oy! First check out CR5!

The Buses needs to find out the shortest path from A to B. You have the code, just merge it prettily, make sure we have simple functions to use when creating a BusRoute for any given Bus going from A to B.

Classes involved: Graph, Node, Link.

Todo:

  • Make BusRoute use Graph with the Dijkstra algorithm to plan which tiles to move in from A to B
  • Test it out , thoroughly !!

Add Blocks in the editor by Clicking

Adding road blocks to the gamematrix by adding a new Block object to the HurkaMap hmap object in Core.

Prepwork:

  • Alter the GameMatrix from 64 x 64 to something smaller
  • Alter the HurkaMap matrix to go from whatever file.txt size is to the gamematrix size
  • Core, hmap modification

Actual cr15:

  • Add a Road block in the right place in the BlockList in HurkaMap when left mouse button is clicked
  • If Road already exist? Change it to another type of road

Add proper Logging

Need log files with verbosity levels

  • install a Logging library for C++ that works well within Windows, thread safe, singleton
  • replace all std::cout lines
  • replace all dbgLevel and debugLevel variables with whatever the logging library has

Core needs a Lifecycle

Core enters "run" function when it boots up aand for now that has worked ok.
Now I need to enable the whole game engine to restart, and restart fresh, restart with a specific map loaded, etc... all this requires me to restart core.

  • Core needs some kind of lifecycle structure
  • Create Classes used when returning from lifecycle() and run() so we know what happened

Toolbar functionalities:

  • usecase: User clicks on Exit Game
  • usecase: User clicks on Load Map
  • usecase: User clicks on New Map

Buses are not placed on the roads

Buses move one step off to the roads in the X-axis. Something is off...

Unit test:

Create iso position and run through "Grid::convert_iso_to_gpix_y" into gpix position.
Then from that gpix position, run function to create an iso_position and compare it to the original
If its not the same - you have an issue there.... its gonna offset many things and cause for concern further down the line.

  • unit test gpix to iso and back
  • add two functions, one for topleft- and one for middle gpix position
  • make all code adjustment for gpix_x_topleft and y_topleft renaming...
  • unit test convert_iso_to_gpix_y_topleft
  • unit test convert_iso_to_gpix_y_middle

Update:
+/-1 bug discovered as I was going from gpix to iso and back and when searching using findTile()

  • Fix +-1 bug in findTile or new HPos
  • Fix currenty bug in findTile bruteforce function
  • Fix entire game that you broke by separating gpix to middle and topleft....

Check:

  • Create better functions for converting iso to gpix
  • Check planBusRoute to see if the Dijkstra createSlotPath are creating X-axis off by 1?
  • Check GameUpdate() for bus
  • Check GpixToIso synch function

Bug, sfml issue with assigning sf Texture

Symtom:

An internal OpenGL call failed in Texture.cpp(98).
Expression:
   glFlush()
Error description:
   GL_INVALID_OPERATION
   The specified operation is not allowed in the current state.
  • Recreate the issue with small code example, pseudocode:
main
 core 
   startup singleton texturemanager with Texture objects
   startup a window
   paint some stuff
   close window
   allocate textures in the texturemanager, see what happoons

Helpful insight:
explains sfml windows and opengl context
https://www.sfml-dev.org/tutorials/2.5/window-opengl.php

Ahhh!!
Yes: https://www.sfml-dev.org/tutorials/2.5/window-opengl.php#opengl-without-a-window

Test:

  • Find out the scope of issue, see if there is a workaround
  • Maybe it's my design that's causing the issue, think, compare HurkaLumo with this small code example
  • using namespace sf; in core?

Make Graph and Node work with Relative iso pos

In order to solve Dijkstra issues right now I have to use relative iso pos instead of absolute values.
Will make it easier to debug because lets say you have a map of 4000,4000
and you have a road down there at 3800,3800... you dont like to have whitespace in the submatrix
from 0,0 to 3800,3800 do you?

That would make for some horrible extra output when debugging.

  • TrafficManager (planForBusesOnRoadNetwork)
  • RoadNetwork
  • Graph
  • Node

Make Sprites and Fonts pixel perfect

Sprites: (old sfml however... not sure if it still applies)
https://en.sfml-dev.org/forums/index.php?topic=87.0

Fonts:
"Note that if the used font is a bitmap font, it is not scalable, thus not all requested sizes will be available to use. This needs to be taken into consideration when setting the character size. If you need to display text of a certain size, make sure the corresponding bitmap font that supports that size is used."

from https://www.sfml-dev.org/documentation/2.5.0/classsf_1_1Text.php#ae96f835fc1bff858f8a23c5b01eaaf7e

Design a Window-handle mechanism

See #24 Fix annoying bug,
umm I made a new window just to solve that OpenGL issue.
Please only have one window and have that window exist in main

  • One Window, in Main
  • Pass Window as reference into all the different places it needs to go, convert to pointer and work it work it
  • Test this new Design
  • run Regressiontests

Go over all FIXME and TODO

Last thing you do before closing milestone alpha 0.1:

  • Check all functions that return pointers, that they in fact return something and not accidentally return 0 or something
  • FIXME
  • TODO
  • BUGS in the Docs \ Bugs folder

Pause Play

Should be easy!
Clicking in the toolbar or on Spacebar will pause or resume play (more of Game mode than editor but hey... lets do it)

Simplify findTile

Make sure it no longer needs a Window to run.

  • No window needed to run
  • Add Unit testing, from gpix to iso using a fixed gamematrix size

Data folder

The data folder is a mess,
also the way the files are reached from the software is messy...

Please clean it up

RoadNetwork - revamp

RoadNetwork uses some weird variables for the offsets on the GameMatrix.
Needs proper positioning with HRect.

  • Fix the positioning in RoadNetwork by removing max_isoYOffset and replacing with an hrect
  • Make a unit test for RoadNetwork:
might be complex
create a map specific for it
run the map
parse the roadnetworks
look at the roadnetwork, does it have the '1:s' and "0:s" in the right places? make spot checks!

Change all Vector2f to HPos

Lot of changes, to a bunch of things T_T

I find it useful to take one function at a time to test... it got messy when I tried to do too much at once.

Make Buses move along the roads (Routes)

Create Routes for the Buses . It don't have to look pretty, but just to get us started with Dijkstra. This precedes the Dijkstra CR.

  • SlotPos - The most simple step a Bus can take within a Block
  • SlotPath - A list of SlotPos:es that a Bus iterates over when it moves
  • Situations - getSlotPosesOnBlockSituation() a function that yields a list of SlotPos based on what situation the bus is, caring for where it comes from and where it is going and through what Block. See Docs/HowItWorks/SlotPos images.
  • TrafficManager.planForBusesOnRoadNetwork() Makes plans for how all the buses should move by iterating the roadNetworks datastructures and finding all the buses
  • TrafficManager.planSlotPath() - Function that creates a SlotPath for a Bus running from A to B
  • Bus.update() - Needs to set the bus gpix values along the slots in the slotpath
  • TrafficManager.updateAll This function should update all the buses on the roadnetwork that they are on. For each RoadNetwork, for each Bus in that roadnetwork, make an .update() on the bus

Simple test:

  • Place one bus on a roadnetwork, in Core, run update() on the bus to see if it moves to the next tile

Complex test:

  • Place a Bus on each Roadnetwork in that example where you have 4 separate straight roads
  • Make busroutes for each Bus, run dijkstra from start to end of each stretch
  • Try running TrafficManager.updateAll and see if they all move

Save to File

Clicking on the save icon in the toolbar saves everything to a default map "default.txt" in Data.
Things that will be saved:

  • HurkaMap
    • GameMatrix's matrix
    • the Blocklist containing all the houses, roads, etc

This does NOT save the buses and the roadnetworks.

  • HRect - make it more friendly to work with in terms of Gpix values
  • Toolbar, add support for clicking on specific button
  • Save current HurkaMap to "data\maps\_default.txt"

DO THIS ONE FIRST - Recode entire project from scratch

Recode HurkaLumo with what you know now.

Just scrap the entire thing and do it aaaaaaaaaalll over again.
That would remove some of the old headaches and make for a much better evolved design.

  • Deal with the Design Issues you already have (#36, #30, #10, #26)
  • Move old code into an alpha_0.1
  • Create new CodeBlocks project HurkaLumo (not Hurka this time)

Would you like to know more?

BONUS UPDATE: Please oh god please, first fix the " gpix to iso " function!

  • introduce "HRect" class
  • finish "findTile" and "findTileBruteForce"
    • resolve the flashing display bug.. everything goes black for a while for some reason
    • resolve "nr of rows are not max index"-issue
    • resolve "nothing happens when I click on (2,9)"-bug
    • resolve "0,15" bug
    • resolve "5,5" bug
    • resolve "precise click" bug
  • cleanup "core.cpp" code
  • test "findTile" with huge map(64x64), small map(10x10), wonky map( 15x35)
    • fix "invalid searchposition" bug at roadNetworkAtPos()
  • test "findTile" with all the blocks rendered
  • specific find functions "findBus" "findRoadNetwork" "findBlock"

Know your foe!

When I click on something I want to see a debug dump on all the objects under the mouse cursor.
Everything in that isometric tile.

  • Block
  • Bus
  • Roadnetwork

Fix annoying Texture() bug

Symptom:

An internal OpenGL call failed in Texture.cpp(98).
Expression:
   glFlush()
Error description:
   GL_INVALID_OPERATION
   The specified operation is not allowed in the current state.

Recreate:
Create any sf::Texture object in Debug mode in Code::Blocks within HurkaLumo project (2018-06),
and create the texture before you have an OpenGL handle . The handle is an open sf::RenderWindow.

Solution:
Fix them by never allocating sf::Texture objects without having a sf::RenderWindow created in the same scope

  • Figure out a better design
  • Implement one
  • Regression test functions

Load from File

Load "default.txt" when clicking on Load icon in toolbar

  • Restart lifecycle of Core given this mapname

Test Test TEST alpha-0.1

Test all the complicated parts so they become stable basic building blocks.
In the future I'll break out some parts to their own functions, which will make it easier to work with my codebase... but for now. Test!

Turn all of the (--) into at least (-+)

  • Graph
  • TrafficManager
  • SlotPath
  • Bus
  • Dijkstra on Many Maps

Traffic Situations

In order to plan greater detail in slotpos slotpath, umm.. I need information on every Road.
That means I need like road type 101 stored in a Node when I am working with the Graph datastructure.

See roadnetwork:createSlotPathFromDijkstraResult. That's where I need it when I create the SlotPos

  • RoadNetwork::createGraphFromHMatrix takes a HurkaMatrix, but that one does not contain road textureId information... change HurkaMatrix:

  • HurkaMatrix to store away road textureIDs too in another "fullMatrix" sort of

  • during Graph creation, when creating Nodes: store away road type information or textureID :

  • Graph::addFirstNode

  • Graph::attachFirstNode

findTile optimize

  • pen n paper, figure out how to walk any gamematrix size to find the iso position based on gpix values
  • practical test
  • unit test

Positioning

  • Create temporary new project "PosProj"

Positions
The way I did it first in 0.1 was super stupid and I need to look at other peoples ideas for how to move effortlessly between the Gameboard Pixel position, the Rendered Window Pixel positions and the Isometric Positions....

Here's an idea, think of "the view" and the "logic" as two different things. We only need to convert gameboard positions (logic) into isometric positioning when drawing to screen (the view).

  • Orthographic Projection for Logic, a simple square, stored in a matrix.
  • Isometric Projection for Drawing, "the view" (with special case of user clicking with mouse)
  • Upload PosProj to github
  • Decide on a Naming standard for the positions and the spaces they exist in
  • Class "Positive Euclidian Space" = Canvas
  • Class "SView" = SFML View, play around with it and see how it affects mouse positions from sfml
  • Class OrMatrix for Logic (OrthoMatrix)
  • Class IsoMatrix for View
  • Unit tests
  • Draw Canvas and an OrMatrix
  • Press Spacebar to flip between OrMatrix and IsoMatrix rendered in the Canvas
  • Draw positions as Text boxes everywhere so I can clearly see where the iso tiles are, and also what they are (0,1 0,2 and so on)
  • going from Ortho to Iso function
  • going from Iso back to Ortho function (algebra? scale and rotate ?)
  • Add singleton for a high level Settings (a Key,Val map please)
  • Add sfml view

Going from Iso back to Ortho

Maybe this can be solved by using algebra and right offsets. If so, it's totally amazingly easy and quick:
http://clintbellanger.net/articles/isometric_math/

Another solution if that does not pan out...

  • scale entire thing in y axis by +198%
  • rotate entire thing ccw 45 deg (solved with cos or something?)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.