merge master
This commit is contained in:
		
							
								
								
									
										18
									
								
								TODO
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								TODO
									
									
									
									
									
								
							| @@ -27,7 +27,7 @@ Assets and i18n: | |||||||
| ECS & engine: | ECS & engine: | ||||||
|     - implement time queue (how to deal with closures?) (?) github.com/thefish/scheduleq - get rid od time.Now inside |     - implement time queue (how to deal with closures?) (?) github.com/thefish/scheduleq - get rid od time.Now inside | ||||||
|     - move all rendering to systems |     - move all rendering to systems | ||||||
|     - try to move input handling to systems |     + try to move input handling to systems | ||||||
|  |  | ||||||
| Dungeon and branches: | Dungeon and branches: | ||||||
|     General: |     General: | ||||||
| @@ -53,7 +53,7 @@ Combat: | |||||||
|     - mass |     - mass | ||||||
|     - damage calculated from: |     - damage calculated from: | ||||||
|         kinetic energy  is calculated by mass / speed / material density (p = mv) масса на скорость = кинетическая энергия |         kinetic energy  is calculated by mass / speed / material density (p = mv) масса на скорость = кинетическая энергия | ||||||
|         next you determine target and its subpart (accuracy appied) |         next you determine target and its subpart (accuracy applied) | ||||||
|         next we calculate the area, on which kinetic energy is applied (determined by piercing, hacking, crushing damage profile) находим площадь |         next we calculate the area, on which kinetic energy is applied (determined by piercing, hacking, crushing damage profile) находим площадь | ||||||
|         next we calculate |         next we calculate | ||||||
|  |  | ||||||
| @@ -81,5 +81,17 @@ Combat: | |||||||
|  |  | ||||||
| Quest engine: | Quest engine: | ||||||
|     - look at parsers like URQL etc |     - look at parsers like URQL etc | ||||||
|     - distorted Aschenputtel story / partisans / rapist prince / Grey Mountains |     - distorted Aschenputtel story / partisans / rapist prince / Grey Mountains / No gold | ||||||
|  |  | ||||||
|  |  | ||||||
|  | No Gold in Gery Mountains / Kim Newman | ||||||
|  |  | ||||||
|  | - Drakenfells castle //location | ||||||
|  | - Greteschele // char / rogue / charred zombie | ||||||
|  | - Yom Lamprecht // char / rogue / | ||||||
|  | - Tiley manor(?) // location / княжество | ||||||
|  | - Melissa d'Acu // char / small girl | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -149,6 +149,7 @@ func main() { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	screenMgr.AddScreen("devmenu", screens.NewDevmenuScreen( | 	screenMgr.AddScreen("devmenu", screens.NewDevmenuScreen( | ||||||
|  | 		mainCtx, | ||||||
| 		mw, | 		mw, | ||||||
| 		controller, | 		controller, | ||||||
| 		screenMgr, | 		screenMgr, | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| { | { | ||||||
|     "version": "v0.0.1.7", |     "version": "v0.0.1.7-16-gbf13c9c", | ||||||
|     "title": "Alchemyst", |     "title": "Alchemyst", | ||||||
|     "sizeX": 100, |     "sizeX": 100, | ||||||
|     "sizeY": 47, |     "sizeY": 47, | ||||||
|   | |||||||
| @@ -18,14 +18,14 @@ func TestDelaunay(t *testing.T) { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	expected := []types.Edge{ | 	expected := []types.Edge{ | ||||||
| 		{types.Coords{10, 60}, types.Coords{10, 10}}, | 		{types.Coords{ 60, 10}, types.Coords{40, 20}}, | ||||||
| 		{types.Coords{30, 10}, types.Coords{40, 20}}, | 		{types.Coords{40, 20}, types.Coords{10, 10}}, | ||||||
| 		{types.Coords{60, 10}, types.Coords{40, 60}}, | 		{types.Coords{30, 10}, types.Coords{60, 10}}, | ||||||
| 		{types.Coords{40, 20}, types.Coords{40, 60}}, | 		{types.Coords{40, 60}, types.Coords{10, 60}}, | ||||||
| 		{types.Coords{10, 10,}, types.Coords{30, 10}}, | 		{types.Coords{40, 20,}, types.Coords{10, 60}}, | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	result := delaunay.GetMst(coords, 100, 100, -1) | 	result := delaunay.GetMst(coords, 100, 100, 100 ) | ||||||
|  |  | ||||||
| 	for idx, _ := range result { | 	for idx, _ := range result { | ||||||
| 		if result[idx] != expected[idx] { | 		if result[idx] != expected[idx] { | ||||||
|   | |||||||
| @@ -7,10 +7,12 @@ import ( | |||||||
| 	"lab.zaar.be/thefish/alchemyst-go/engine/gamestate" | 	"lab.zaar.be/thefish/alchemyst-go/engine/gamestate" | ||||||
| 	"lab.zaar.be/thefish/alchemyst-go/engine/types" | 	"lab.zaar.be/thefish/alchemyst-go/engine/types" | ||||||
| 	"lab.zaar.be/thefish/alchemyst-go/ui/mainwindow" | 	"lab.zaar.be/thefish/alchemyst-go/ui/mainwindow" | ||||||
|  | 	"lab.zaar.be/thefish/alchemyst-go/util/appctx" | ||||||
| 	"strings" | 	"strings" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| type DevmenuScreen struct { | type DevmenuScreen struct { | ||||||
|  | 	ctx appctx.ClientCtx | ||||||
| 	mw         *mainwindow.MainWindow | 	mw         *mainwindow.MainWindow | ||||||
| 	controller *ecs.Controller | 	controller *ecs.Controller | ||||||
| 	scm        *types.ScreenManager | 	scm        *types.ScreenManager | ||||||
| @@ -23,8 +25,9 @@ type DevmenuScreen struct { | |||||||
| 	fgColor string | 	fgColor string | ||||||
| } | } | ||||||
|  |  | ||||||
| func NewDevmenuScreen(mw *mainwindow.MainWindow, controller *ecs.Controller, scm *types.ScreenManager, state *gamestate.GameState, rect types.Rect, renderParent bool) *DevmenuScreen { | func NewDevmenuScreen(ctx appctx.ClientCtx, mw *mainwindow.MainWindow, controller *ecs.Controller, scm *types.ScreenManager, state *gamestate.GameState, rect types.Rect, renderParent bool) *DevmenuScreen { | ||||||
| 	return &DevmenuScreen{ | 	return &DevmenuScreen{ | ||||||
|  | 		ctx: ctx, | ||||||
| 		mw:         mw, | 		mw:         mw, | ||||||
| 		controller: controller, | 		controller: controller, | ||||||
| 		scm:        scm, | 		scm:        scm, | ||||||
| @@ -58,6 +61,7 @@ func (devm *DevmenuScreen) HandleInput(input string) { | |||||||
| 			level.Tiles[idx].Explored = false | 			level.Tiles[idx].Explored = false | ||||||
| 		} | 		} | ||||||
| 		devm.scm.SetScreen(devm.scm.PreviousScreen) | 		devm.scm.SetScreen(devm.scm.PreviousScreen) | ||||||
|  | 		appctx.Logger(devm.ctx).Info().Msg("resetting to normal visibility") | ||||||
| 		break | 		break | ||||||
| 	case "v": | 	case "v": | ||||||
| 		level := devm.state.Level | 		level := devm.state.Level | ||||||
| @@ -65,13 +69,15 @@ func (devm *DevmenuScreen) HandleInput(input string) { | |||||||
| 			level.Tiles[idx].Visible = true | 			level.Tiles[idx].Visible = true | ||||||
| 			level.Tiles[idx].Explored = true | 			level.Tiles[idx].Explored = true | ||||||
| 		} | 		} | ||||||
| 		fmt.Printf("making everything visible!") | 		appctx.Logger(devm.ctx).Info().Msg("making everything visible") | ||||||
| 		devm.scm.SetScreen(devm.scm.PreviousScreen) | 		devm.scm.SetScreen(devm.scm.PreviousScreen) | ||||||
| 		break | 		break | ||||||
| 	case "p": | 	case "p": | ||||||
| 		if devm.controller.HasComponent(devm.state.Player, effects.BuffPassWall) { | 		if devm.controller.HasComponent(devm.state.Player, effects.BuffPassWall) { | ||||||
|  | 			appctx.Logger(devm.ctx).Info().Msg("disabling passwall") | ||||||
| 			devm.controller.RemoveComponent(devm.state.Player, effects.BuffPassWall) | 			devm.controller.RemoveComponent(devm.state.Player, effects.BuffPassWall) | ||||||
| 		} else { | 		} else { | ||||||
|  | 			appctx.Logger(devm.ctx).Info().Msg("enabling passwall") | ||||||
| 			devm.controller.AddComponent(devm.state.Player, effects.PassWall{}) | 			devm.controller.AddComponent(devm.state.Player, effects.PassWall{}) | ||||||
| 		} | 		} | ||||||
| 	case "Escape": | 	case "Escape": | ||||||
|   | |||||||
| @@ -46,7 +46,7 @@ func (ts *GameScreen) UseEcs() bool { return true } | |||||||
| func (ts *GameScreen) Enter() { | func (ts *GameScreen) Enter() { | ||||||
| 	ts.mw.GetLayer("overlay").ClearArea(0, ts.mw.H-3, 30, 3) | 	ts.mw.GetLayer("overlay").ClearArea(0, ts.mw.H-3, 30, 3) | ||||||
| 	ts.mw.GetLayer("overlay").WithColor("#77777777"). | 	ts.mw.GetLayer("overlay").WithColor("#77777777"). | ||||||
| 		Print(1, ts.mw.H-2, "Press [color=white]?[/color] for help") | 		Print(ts.mw.W - 17 , 1, "Press [color=white]?[/color] for help") | ||||||
| } | } | ||||||
| func (ts *GameScreen) Exit() { | func (ts *GameScreen) Exit() { | ||||||
| 	//trs := ts.controller.GetSystem(ecs.LevelRenderSystem) | 	//trs := ts.controller.GetSystem(ecs.LevelRenderSystem) | ||||||
|   | |||||||
| @@ -57,5 +57,5 @@ Roguebasin Libtcod Tutorial (c) 2010-2011, Jotaf Henriques | |||||||
| Brogue 1.3 (c) 2010 Brian Walker                                             | Brogue 1.3 (c) 2010 Brian Walker                                             | ||||||
| Madness (c) 2010 hmp <humpolec@gmail.com>                                    | Madness (c) 2010 hmp <humpolec@gmail.com>                                    | ||||||
| BearLibTerminal (c) Cfyz 2009-2019 <http://foo.wyrd.name/en:bearlibterminal> | BearLibTerminal (c) Cfyz 2009-2019 <http://foo.wyrd.name/en:bearlibterminal> | ||||||
| Gogue (c) jcerise                                                            | Gogue (c) 2019 jcerise                                                       | ||||||
| ` | ` | ||||||
|   | |||||||
							
								
								
									
										78
									
								
								util/wu/line.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								util/wu/line.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,78 @@ | |||||||
|  | package wu | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"lab.zaar.be/thefish/alchemyst-go/engine/types" | ||||||
|  | 	"math" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | func ipart(x float64) float64 { | ||||||
|  | 	return math.Floor(x) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func round(x float64) float64 { | ||||||
|  | 	return ipart(x + .5) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func fpart(x float64) float64 { | ||||||
|  | 	return x - ipart(x) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func rfpart(x float64) float64 { | ||||||
|  | 	return 1 - fpart(x) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (Layer types.Putable) WuLine(x1, y1, x2, y2 float64, w int) { | ||||||
|  | 	dx := x2 - x1 | ||||||
|  | 	dy := y2 - y1 | ||||||
|  | 	ax := dx | ||||||
|  | 	if ax < 0 { | ||||||
|  | 		ax = -ax | ||||||
|  | 	} | ||||||
|  | 	ay := dy | ||||||
|  | 	if ay < 0 { | ||||||
|  | 		ay = -ay | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	var plot func(int, int, float64) | ||||||
|  |  | ||||||
|  | 	if ax < ay { | ||||||
|  | 		x1, y1 = y1, x1 | ||||||
|  | 		x2, y2 = y2, x2 | ||||||
|  | 		dx, dy = dy, dx | ||||||
|  | 		plot = func(x, y int, c float64) { | ||||||
|  | 			Layer.Put(y, x,  uint8(255 * c)) | ||||||
|  | 		} | ||||||
|  | 	} else { | ||||||
|  | 		plot = func(x, y int, c float64) { | ||||||
|  | 			Layer.Put(x, y, uint8(255 * c)) | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	if x2 < x1 { | ||||||
|  | 		x1, x2 = x2, x1 | ||||||
|  | 		y1, y2 = y2, y1 | ||||||
|  | 	} | ||||||
|  | 	gradient := dy / dx | ||||||
|  |  | ||||||
|  | 	xend := round(x1) | ||||||
|  | 	yend := y1 + gradient*(xend-x1) | ||||||
|  | 	xgap := rfpart(x1 + .5) | ||||||
|  | 	xpxl1 := int(xend) | ||||||
|  | 	ypxl1 := int(ipart(yend)) | ||||||
|  | 	plot(xpxl1, ypxl1, rfpart(yend)*xgap) | ||||||
|  | 	plot(xpxl1, ypxl1+1, fpart(yend)*xgap) | ||||||
|  | 	intery := yend + gradient | ||||||
|  |  | ||||||
|  | 	xend = round(x2) | ||||||
|  | 	yend = y2 + gradient*(xend-x2) | ||||||
|  | 	xgap = fpart(x2 + 0.5) | ||||||
|  | 	xpxl2 := int(xend) | ||||||
|  | 	ypxl2 := int(ipart(yend)) | ||||||
|  | 	plot(xpxl2, ypxl2, rfpart(yend)*xgap) | ||||||
|  | 	plot(xpxl2, ypxl2+1, fpart(yend)*xgap) | ||||||
|  |  | ||||||
|  | 	for x := xpxl1 + 1; x <= xpxl2-1; x++ { | ||||||
|  | 		plot(x, int(ipart(intery)), rfpart(intery)) | ||||||
|  | 		plot(x, int(ipart(intery))+1, fpart(intery)) | ||||||
|  | 		intery = intery + gradient | ||||||
|  | 	} | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user