internal void GameUpdateAndRender(game_memory *Memory, game_input *Input, game_offscreen_buffer *Buffer) { Assert(sizeof(game_state) <= Memory->PermanentStorageSize); game_state *GameState = (game_state *) Memory->PermanentStorage; if (!Memory->IsInitialized) { char *Filename = __FILE__; debug_read_file_result File = DEBUGPlatformReadEntireFile(Filename); if (File.Contents) { DEBUGPlatformWriteEntireFile("test.out", File.ContentsSize, File.Contents); DEBUGPlatformFreeFileMemory(File.Contents); } GameState->ToneHz = 512; Memory->IsInitialized = true; } for (int ControllerIndex = 0; ControllerIndex < ArrayCount(Input->Controllers); ++ControllerIndex) { game_controller_input *Controller = GetController(Input, ControllerIndex); if (Controller->IsAnalog) { // Use analog movement tuning. GameState->BlueOffset += (int) (4.0f * Controller->StickAverageX); GameState->ToneHz = 512 + (int) (128.0f * Controller->StickAverageY); } else { // Use digital movement tuning. if (Controller->MoveLeft.EndedDown) { GameState->BlueOffset -= 1; } if (Controller->MoveRight.EndedDown) { GameState->BlueOffset += 1; } } // Input.AButtonEndedDown; // Input.AButtonHalfTransitionCount; if (Controller->ActionDown.EndedDown) { GameState->GreenOffset += 1; } } RenderWeirdGradient(Buffer, GameState->BlueOffset, GameState->GreenOffset); }
internal void GameUpdateAndRender( game_memory *Memory, game_input *Input, game_offscreen_buffer *Buffer, game_sound_output_buffer *SoundBuffer ) { Assert(sizeof(game_state) <= Memory->PermanentStorageSize); game_state *GameState = (game_state *)Memory->PermanentStorage; if (Memory->IsInitialized) { char *Filename = "test.bmp"; debug_read_file_result Result = DEBUGPlatformReadEntireFile(Filename); if (Result.Contents) { DEBUGPlatformFreeFileMemory(Result.Contents); } GameState->ToneHz = 256; GameState->GreenOffset = 0; GameState->BlueOffset = 0; Memory->IsInitialized = true; } for (int ControllerIndex = 0; ControllerIndex < ArrayCount(Input->Controllers); ControllerIndex++) { game_controller_input *Controller = GetController(Input, ControllerIndex); if (Controller->IsAnalog) { // Analog GameState->ToneHz = 256 + (int)(128.0f * (Controller->StickAverageX)); GameState->BlueOffset += (int)(4.0f * (Controller->StickAverageY)); } else { // Digital if (Controller->MoveLeft.EndedDown) { GameState->BlueOffset--; } else if (Controller->MoveRight.EndedDown) { GameState->BlueOffset++; } } if (Controller->ActionDown.EndedDown) { GameState->GreenOffset += 1; } else if (Controller->ActionUp.EndedDown) { GameState->GreenOffset -= 1; } } GameOutputSound(SoundBuffer); RenderWeirdGradient(Buffer, GameState->BlueOffset, GameState->GreenOffset); }