fixed slow grid drawing, which also fixed transient tile quirk
This commit is contained in:
		
							parent
							
								
									1c0f3d19d0
								
							
						
					
					
						commit
						6f85a90b58
					
				
							
								
								
									
										8
									
								
								TODO.md
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								TODO.md
									
									
									
									
									
								
							| @ -14,12 +14,6 @@ | ||||
| 
 | ||||
| - Add shaders for animation (player destruction etc) | ||||
| 
 | ||||
| - Add Score system, see game_observer.go bottom. | ||||
|   - add MinMoves to each level (one line) [min moves to win] | ||||
|   - count moves in player_scene.Update (put to observer as well?) | ||||
|   - reset counters when new level starts | ||||
|   - display level score in level select | ||||
| 
 | ||||
| - for finding caller: | ||||
| 	pc := make([]uintptr, 10) | ||||
| 	n := runtime.Callers(0, pc) | ||||
| @ -32,7 +26,7 @@ | ||||
| 	slog.Debug("get observer", "minmoves", observer.LevelScore, | ||||
| 		"file", source.File, "line", source.Line) | ||||
| 
 | ||||
| ## Collider Rework | ||||
| ## Collider Rework [abandoned: see branch collider-system, fails] | ||||
| 
 | ||||
| - do not use the map anymore for collision detection | ||||
| - central collision_system | ||||
|  | ||||
| @ -11,6 +11,6 @@ const ( | ||||
| 	All | ||||
| ) | ||||
| 
 | ||||
| const PLAYERSPEED int = 4 | ||||
| const PLAYERSPEED int = 5 | ||||
| const PARTICLE_LOOPWAIT time.Duration = 250 * time.Millisecond | ||||
| const LEVEL_END_WAIT time.Duration = 500 * time.Millisecond | ||||
|  | ||||
| @ -1,9 +1,6 @@ | ||||
| package systems | ||||
| 
 | ||||
| import ( | ||||
| 	"image" | ||||
| 	"image/draw" | ||||
| 	"log/slog" | ||||
| 	. "openquell/components" | ||||
| 
 | ||||
| 	"github.com/hajimehoshi/ebiten/v2" | ||||
| @ -40,32 +37,33 @@ func NewGridSystem(world *ecs.World, width, height, | ||||
| 	return system | ||||
| } | ||||
| 
 | ||||
| func (system *GridSystem) Update() error { return nil } | ||||
| func (system *GridSystem) Update() error { | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (system *GridSystem) Draw(screen *ebiten.Image) { | ||||
| 	op := &ebiten.DrawImageOptions{} | ||||
| 	query := system.Selector.Query(system.World) | ||||
| 
 | ||||
| 	if !system.UseCache || query.Count() != system.Count { | ||||
| 		slog.Debug("entity number changes", "old", system.Count, "current", query.Count()) | ||||
| 		// map not cached or cacheable, write it to the cache | ||||
| 		draw.Draw(system.Cache, system.Background.Bounds(), system.Background, image.ZP, draw.Src) | ||||
| 		system.Cache.DrawImage(system.Background, op) | ||||
| 
 | ||||
| 		system.Count = query.Count() | ||||
| 
 | ||||
| 		counter := 0 | ||||
| 		for query.Next() { | ||||
| 			sprite, pos, _ := query.Get() | ||||
| 
 | ||||
| 			//slog.Debug("drawing sprite", "sprite", sprite, "point", pos.Point()) | ||||
| 			draw.Draw( | ||||
| 				system.Cache, | ||||
| 				image.Rect(pos.X, pos.Y, pos.X+pos.Cellsize, pos.Y+pos.Cellsize), | ||||
| 				sprite.Image, image.ZP, draw.Over) | ||||
| 			counter++ | ||||
| 			op.GeoM.Reset() | ||||
| 			op.GeoM.Translate(float64(pos.X), float64(pos.Y)) | ||||
| 			system.Cache.DrawImage(sprite.Image, op) | ||||
| 		} | ||||
| 
 | ||||
| 		op.GeoM.Reset() | ||||
| 		screen.DrawImage(system.Cache, op) | ||||
| 
 | ||||
| 		system.UseCache = true | ||||
| 
 | ||||
| 	} else { | ||||
| 		// use the cached map | ||||
| 		op.GeoM.Reset() | ||||
|  | ||||
| @ -1,6 +1,7 @@ | ||||
| package systems | ||||
| 
 | ||||
| import ( | ||||
| 	"log/slog" | ||||
| 	"openquell/assets" | ||||
| 	"openquell/components" | ||||
| 	. "openquell/components" | ||||
| @ -78,17 +79,19 @@ func (system *TransientSystem) Update() error { | ||||
| 						Position:  *transientposition, | ||||
| 						NewSprite: transient.GetNext(), | ||||
| 					}) | ||||
| 					//slog.Debug("done transient", "transient", transientposition) | ||||
| 					slog.Debug("transient added to make solid") | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	for _, convertible := range EntitiestoMakeSolid { | ||||
| 		slog.Debug("transient remove") | ||||
| 		// remove transient entity | ||||
| 		system.World.RemoveEntity(convertible.Entity) | ||||
| 
 | ||||
| 		// replace with solid entity | ||||
| 		slog.Debug("transient add solid") | ||||
| 		entity := system.SolidMapper.New() | ||||
| 		pos, render, _, _ := system.SolidMapper.Get(entity) | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user