Commit Graph

21 Commits

Author SHA1 Message Date
Julien Ganichot 1f2771e8bc
Resolves #874 and #892 (#894)
* Move engine initialization to d2app
* adding debug print of error returned from `App.Run`
* adding ClampInt utility function to d2math
* cleaned up argument parsing in app.go, dedicated server no longer starts a renderer

Co-authored-by: gravestench <dknuth0101@gmail.com>
2020-11-01 16:05:50 -08:00
gravestench 815cfa09cb
fix all gosec lint errors (#844) 2020-10-25 23:38:15 -07:00
gravestench e274260787
fixed all golint type lint errors (#780) 2020-10-21 23:41:21 -07:00
Gürkan Kaymak f4a71c72e4
lint fixes (#727) 2020-09-12 16:25:09 -04:00
Ziemas 8d87c19532
Draw entities back to front within tiles (#705)
* Draw entities per subtile for correct depth order

* Use a temporary entity slice for depth sorting

Speeds things up quite a bit
2020-08-16 14:59:03 -04:00
lord 8e41133f39
lint and minor refactor of d2common (#690)
- moved contents of `d2common/math.go` into `d2math/math.go`
- removed lint errors from files in d2common
2020-08-05 00:03:33 -04:00
danhale-git 259c6e7e76
Vector method pointers (#621)
* All Vector methods which operate on the vector return pointers to it.

* All Vector methods which take vectors take Vector pointers.
2020-07-25 09:36:54 -04:00
Gürkan Kaymak 7a49f3637f
lint fixes (#615) 2020-07-23 12:56:50 -04:00
Ziemas d0c6cd61dd
Simple LOS pathfinding without walkmesh (#610)
* Reorganize MapEngine

This is already turning into a mess...

* Map engine selects tile index to use

Still very ugly

* Fix subtile flag combination

* Prepare randomly generated base tiles

* Restore collision viewer

* Movement works again, searches for straight paths

Paths are now d2vector slices

* Fix LOS calculation

* Fix test (I think)
2020-07-21 08:50:45 -04:00
danhale-git 727e8244c6
Implemented Position in Path and PathTile (#605)
* Unnecessary constructor assignments removed.

* Position implemented in d2common.Path

* Position implemented in mapEntity.Step.

* Position implemented in d2common.PathTile.
2020-07-18 18:07:13 -04:00
danhale-git 54ff33c552
Benchmark d2math (#595)
* Vector and tests reviewed.

* Tests and benchmarks for d2math.math.

Also docs/comments.
2020-07-17 18:50:07 -04:00
danhale-git dcb0c087b9
Vector benchmark (#594)
* Reflect and ReflectSurface benchmark.

* Rotate, NinetyAnti and NinetyClock benchmark.

* Equals, EqualsApprox, CompareApprox and IsZero benchmark.

* Benchmarks for everything else.

Also removing dead functions and commented out code and correcting typos.
2020-07-16 14:13:01 -04:00
danhale-git 921d44a70c
mapEntity.Step() benchmark and improvements. (#593)
* Initial test and benchmark for mapEntity.Step().

* Removed `&& !m.hasPath()` from mapEntity.atTarget

* Direction is now updated when the path node changes mid-step and target is updated when path is set.

* Test improvements.

* Deleted old benchmark function and tidying.

* d2math.Abs added.

* Abs benchmark and optimisation.

* Negate and Distance benchmark.

* Length and SetLength benchmark.

* Lerp and Dot benchmark.

* Cross and Normalize benchmark.

* Angle and SignedAngle benchmark.

* Trivial change to Vector.Abs()
2020-07-16 12:06:08 -04:00
danhale-git 894c60f77a
Map entity rework - vectors in mapEntity (#579)
* Fixed NaN on normalize 0 vector.

* Tentative implementation in getStepLength.

* mapEntity.TileX/Y removed.

* Fixed Position and Target not being initialised in createMapEntity.

* mapEntity.Position is no longer embedded.

* mapEntity.LocationX/Y no longer used outside map_entity.go.

* mapEntity.subCellX/Y removed.

* mapEntity.LocationX/Y removed.

* mapEntity.OffsetX/Y and TargetX/Y removed.

* Direction method added to Vector, returns 0-64 direction.

* Moved Vector.Direction() to Position.DirectionTo and refactored.

* Renamed RenderOffset from SubCell and tested IsZero.

* d2math.WrapInt added for use with directions.

* Tidied up position and tests.

* Refactored d2common.AdjustWithRemainder into d2mapEntity.

* Tidying up d2mapEntity.

* Final cleanup.

* Lint warnings.

* Spelling correction.
2020-07-13 09:06:50 -04:00
dk 7a32e7bbac
adding ranged number type, for use in stats (#581) 2020-07-13 09:03:19 -04:00
danhale-git fa0814e0b1
Position supports current coordinate types. (#576) 2020-07-11 18:11:26 -04:00
danhale-git 029cb62972
Vector float64 (#565)
* Fixed nil pointer in Copy()

* Position added

Added Floor() and String() methods to Vector.

Also added Position which declares an embedded Vector2 and returns various forms of it.

* d2vector.Vector2 renamed to d2vector.BigFloat

* vector.go renamed to big_float.go

* Float64 stub and more renaming

* Vector value getters

* Separate vector types with initial methods.

* Divide and lint warnings.

* Distance and Length.

* Scale, Abs and Negate.

* CompareFloat64Fuzzy delta direction reversed.

* Refactor vector_test.go.

* Renamed Approx methods.

* Distance and Length.

* Distance and Length.

* Removed BigFloat and Vector, renamed Float64 to Vector, simplified tests.

* Angle, SignedAngle and other small functions.

* Receiver rename.

* SingedAngle and test fixed

* Rotate.

* SetLength.

* Cross.

* NinetyAnti and NinetyClock.

* Lerp and Clamp.

* Reflect and ReflectSurface.

* Cardinal convenience functions.

* Comments.

* Panic on NaN and Inf in Position.

* Lint warnings and comments.
2020-07-09 08:30:55 -04:00
danhale-git 07d90e9681
Position struct for managing world coordinates (#540)
* Fixed nil pointer in Copy()

* Position added

Added Floor() and String() methods to Vector.

Also added Position which declares an embedded Vector2 and returns various forms of it.

* Position tests improved
2020-07-04 19:25:53 -04:00
danhale-git 853ad7ae64
Cardinal vectors (#539)
* Comments and newlines in vector.go

* Added cardinal direction functions.

* Moved vector.go into d2vector.
2020-07-04 08:02:47 -04:00
dk de116e8367
moving package comments into doc.go files (#534) 2020-07-03 18:33:46 -04:00
dk 48bde64a7e
vector implementation with big.Float (#527) 2020-07-03 02:26:59 -04:00