<commit_before>package main

import (
	"fmt"
	"runtime"

	"github.com/tanema/amore"
	"github.com/tanema/amore/gfx"
	"github.com/tanema/amore/keyboard"
	"github.com/tanema/amore/timer"

	"github.com/tanema/amore-examples/platformer/game"
	"github.com/tanema/amore-examples/platformer/lense"
)

var (
	width   float32 = 4000
	height  float32 = 2000
	camera  *lense.Camera
	gameMap *game.Map
)

func main() {
	amore.OnLoad = onLoad
	amore.Start(update, draw)
}

func onLoad() {
	keyboard.OnKeyUp = keypress
	camera = lense.New()
	gameMap = game.NewMap(width, height, camera)
}

func update(dt float32) {
	l, t, w, h := camera.GetVisible()
	gameMap.Update(dt, l, t, w, h)
	camera.LookAt(gameMap.Player.GetCenter())
	camera.Update(dt)
}

func draw() {
	camera.Draw(gameMap.Draw)
	gfx.SetColor(255, 255, 255, 255)
	w, h := gfx.GetWidth(), gfx.GetHeight()
	stats := runtime.MemStats{}
	runtime.ReadMemStats(&stats)
	gfx.Printf(fmt.Sprintf("fps: %v, mem: %vKB", timer.GetFPS(), stats.HeapAlloc/1000), 200, gfx.ALIGN_RIGHT, w-200, h-40)
}

func keypress(key keyboard.Key) {
	switch key {
	case keyboard.KeyEscape:
		amore.Quit()
	case keyboard.KeyTab:<commit_msg>Better memory tracking<commit_after>package main

import (
	"fmt"
	"runtime"

	"github.com/tanema/amore"
	"github.com/tanema/amore/gfx"
	"github.com/tanema/amore/keyboard"
	"github.com/tanema/amore/timer"

	"github.com/tanema/amore-examples/platformer/game"
	"github.com/tanema/amore-examples/platformer/lense"
)

var (
	width   float32 = 4000
	height  float32 = 2000
	camera  *lense.Camera
	gameMap *game.Map
)

func main() {
	amore.OnLoad = onLoad
	amore.Start(update, draw)
}

func onLoad() {
	keyboard.OnKeyUp = keypress
	camera = lense.New()
	gameMap = game.NewMap(width, height, camera)
}

func update(dt float32) {
	l, t, w, h := camera.GetVisible()
	gameMap.Update(dt, l, t, w, h)
	camera.LookAt(gameMap.Player.GetCenter())
	camera.Update(dt)
}

func draw() {
	camera.Draw(gameMap.Draw)
	gfx.SetColor(255, 255, 255, 255)
	w, h := gfx.GetWidth(), gfx.GetHeight()
	stats := runtime.MemStats{}
	runtime.ReadMemStats(&stats)
	gfx.Printf(fmt.Sprintf("fps: %v, mem: %vKB", timer.GetFPS(), stats.HeapAlloc/1000000), 200, gfx.ALIGN_RIGHT, w-200, h-40)
}

func keypress(key keyboard.Key) {
	switch key {
	case keyboard.KeyEscape:
		amore.Quit()
	case keyboard.KeyTab:
{'fraction_non_alphanumeric': 0.15775862068965518, 'fraction_numerical': 0.03405172413793103, 'mean_word_length': 4.410256410256411, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '722215', 'n_tokens_mistral': 1023, 'n_tokens_neox': 957, 'n_words': 175}