You are browsing as a guest. Sign up (or log in) to start making projects!

6h 18m 30s logged

Preformance Checkup + Audio System

Things I did:

  • I stress tested my game to work with 512 & 1024 entities. Ran under 3ms and 5ms. The difference maker was the number of entities currently in the screen (rendering).
  • Profiled all the “slow” parts
  • Implemented sound system, for menu and game
  • Recorded the sounds myself!! (both in-game and ui)!

Performance

I tried my best to find ways to increase speed in my game. Unfortunately, all the things that I thought were “slow” weren’t actually slow.

  • Orui UI build was like under 50micro seconds.
  • Orui Rendering was under 250micro seconds.
  • Animation system ran under 50micro for all entities combined iirc

So, for now, there has been done no performance improvements this devlog

Sound System

First I made the sound system simple, for the menu. It worked and I was happy. I made 6 different similar sounds for the hover and click actions, and I play one of them randomly when clicked.

menu_hover_sounds: [6]rl.Sound
loadMenuSounds :: proc() {
	for i in 0 ..< len(menu_hover_sounds) {
		path := fmt.ctprintf("res/audio/menu/menu_click_%d.wav", i + 1)
		menu_click_sounds[i] = rl.LoadSound(path)
	}
}

playMenuHoveredSound :: proc() {
	i := rand.int_max(len(menu_hover_sounds))
	rl.PlaySound(menu_hover_sounds[i])
}

When I went on to make the Player sounds, I noticed that I am unable to the same sound twice simultaneously. I needed that so that I can simulate multiple enemies and other stuff.

So I googled a bit, found this raylib example. And implemented it. For both menu and entities.

TOTAL_ALIASES :: 4
Sound :: struct {
	aliases: [TOTAL_ALIASES]rl.Sound,
	index:   int,
}

loadSound :: proc(path: cstring) -> Sound {
	sound: Sound
	sound.aliases[0] = rl.LoadSound(path)

	for i in 1 ..< TOTAL_ALIASES {
		sound.aliases[i] = rl.LoadSoundAlias(sound.aliases[0])
	}

	sound.index = 0
	return sound
}

playSound :: proc(sound: ^Sound) {
	rl.PlaySound(sound.aliases[sound.index])
	sound.index = (sound.index + 1) % TOTAL_ALIASES
}

playMenuClickedSound :: proc() {
	i := rand.int_max(len(menu_click_sounds))
	playSound(&menu_click_sounds[i])
}

I also stole borrowed :evilrondo: this really great background music from raylib source.

0
11

Comments 0

No comments yet. Be the first!