Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubtomsu committed Feb 11, 2022
1 parent 2e7fca9 commit 6dd34ef
Show file tree
Hide file tree
Showing 23 changed files with 115 additions and 75 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ build/*.exp
build/*.lib
build/*.exe
build/log.txt
build/maps/_quickload.doqm
build/maps/_quickload.dqm
build/.doq_settings
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
**currently work in progress!**

# maps
#### Info for creating maps is in [DOQM file spec](doqm_format_spec.md)
#### Info for creating maps is in [DQM file spec](doqm_format_spec.md)
Maps are a top-down, ascii view on the map, and different characters correspond to different
tiles - this means anyone can edit maps with just a simple text editor.
`.doqm` file extension is used, even though the underlying file is just plain text.
`.dqm` file extension is used, even though the underlying file is just plain text.

> The raw tile table is in [map.odin](/doq/map.odin) as `map_tileKind_t`
Expand All @@ -32,9 +32,6 @@ health pickup `h` is translated to `empty` tile, and the pickup itself gets spaw


# TODO
- settings:
- field of view
- background music volume
- 3D audio
- simple profiler, maybe with [chrome://tracing](chrome://tracing)
- particles
Expand Down
2 changes: 1 addition & 1 deletion build/maps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

Maps with underscore `_` as a first character are hidden in the map selection menu.

You can use `_quickload.doqm` map file to instantly load a level, and bypass all the menu's.
You can use `_quickload.dqm` map file to instantly load a level, and bypass all the menu's.
Subdirectories are supported in the map selection menu, but their name isn't relative to this folder, it's just the last folder in path.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 0 additions & 21 deletions build/maps/example0 - Copy.doqm

This file was deleted.

2 changes: 1 addition & 1 deletion build/maps/example0.doqm → build/maps/example0.dqm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
skyColor: 1.0 0.2 0.0
fogStrength: 1.2
startPlayerDir: 0.0 -1.0
nextMapName: "parkour0.doqm"
nextMapName: "parkour0.dqm"
}

#######-------#######
Expand Down
File renamed without changes.
Binary file modified build/models/shotgun.glb
Binary file not shown.
4 changes: 2 additions & 2 deletions build/shaders/postprocess.frag
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ void main() {

//col = pow(col, vec3(1.0 / screengamma)); // gamma correction

col += dither(gl_FragCoord.xy)*0.3;
col = posterize(col, 8, 1.1);
col += dither(gl_FragCoord.xy)*0.25;
col = posterize(col, 12, 0.8);
//col = gameboyColor(col);

// if(gl_FragCoord.x < 30 && gl_FragCoord.y < 30) col = vec3(1,0,1); // debug
Expand Down
8 changes: 4 additions & 4 deletions build/shaders/tile.frag
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ void main() {
vec2 griduv = floor(uv*64.0)/64.0;
//col += vec3(abs(fragNormal.x)*0.04 + fragNormal.y*0.04);
vec3 gridpos = toGridPos(fragPosition*1.0001/TILE_WIDTH);
float gridnoise = simplex3d(gridpos*0.33);
gridnoise += sign(gridnoise)*0.25;
float gridnoise = simplex3d(gridpos*0.25);
gridnoise += sign(gridnoise)*0.2;
gridnoise += simplex3d(gridpos);
gridnoise += sign(gridnoise)*0.25;
col += vec3(gridnoise*0.017);
gridnoise += sign(gridnoise)*0.2;
col += vec3(gridnoise*0.02);
//float tileCenterDist = (pow(abs(mod(griduv.x,1.0) - 0.5)*2.0, 3.0)+pow(abs(mod(griduv.y,1.0) - 0.5)*2.0, 3.0))*0.5;
//col = vec3(pow(tileCenterDist, 0.5));
//col *= vec3(1.0) + vec3(abs(gridnoise)*tileCenterDist*simplex3d(toGridPos(fragPosition/TILE_WIDTH)*0.4)*10.0);
Expand Down
59 changes: 47 additions & 12 deletions doq/doq.odin
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ settings : struct {
drawFPS : bool,
debugIsEnabled : bool,
audioMasterVolume : f32,
audioMusicVolume : f32,
crosshairOpacity : f32,
mouseSensitivity : f32,
FOV : f32,
viewmodelFOV : f32,
gunXOffset : f32,
}


Expand All @@ -80,10 +84,18 @@ _doq_main :: proc() {
println("### frame =", framespassed, "deltatime =", deltatime)
framespassed += 1

settings.audioMasterVolume = clamp(settings.audioMasterVolume, 0.0, 1.0)
settings.crosshairOpacity = clamp(settings.crosshairOpacity, 0.0, 1.0)
settings.mouseSensitivity = clamp(settings.mouseSensitivity, 0.1, 5.0)
// fixup
settings.audioMasterVolume = clamp(settings.audioMasterVolume, 0.0, 1.0)
settings.audioMusicVolume = clamp(settings.audioMusicVolume, 0.0, 1.0)
settings.crosshairOpacity = clamp(settings.crosshairOpacity, 0.0, 1.0)
settings.mouseSensitivity = clamp(settings.mouseSensitivity, 0.1, 5.0)
settings.FOV = clamp(settings.FOV, 20.0, 170.0)
settings.viewmodelFOV = clamp(settings.viewmodelFOV, 80.0, 120.0)
settings.gunXOffset = clamp(settings.gunXOffset, -0.4, 0.4)
rl.SetMasterVolume(settings.audioMasterVolume)

camera.fovy = settings.FOV
viewmodelCamera.fovy = settings.viewmodelFOV

rl.DisableCursor()

Expand All @@ -92,6 +104,7 @@ _doq_main :: proc() {
}


if app_updatePathKind != .GAME do gameStopSounds()

switch app_updatePathKind {
case .LOADSCREEN:
Expand Down Expand Up @@ -286,14 +299,12 @@ _app_init :: proc() {
camera.position = {0, 3, 0}
camera.target = {}
camera.up = vec3{0.0, 1.0, 0.0}
camera.fovy = PLAYER_FOV
camera.projection = rl.CameraProjection.PERSPECTIVE
rl.SetCameraMode(camera, rl.CameraMode.CUSTOM)

viewmodelCamera.position = {0,0,0}
viewmodelCamera.target = {0,0,1}
viewmodelCamera.up = {0,1,0}
viewmodelCamera.fovy = PLAYER_VIEWMODEL_FOV
viewmodelCamera.projection = rl.CameraProjection.PERSPECTIVE
rl.SetCameraMode(viewmodelCamera, rl.CameraMode.CUSTOM)

Expand All @@ -311,8 +322,8 @@ _app_init :: proc() {

map_clearAll()
map_data.bounds = {MAP_MAX_WIDTH, MAP_MAX_WIDTH}
if os.is_file(appendToAssetPath("maps", "_quickload.doqm")) {
map_loadFromFile("_quickload.doqm")
if os.is_file(appendToAssetPath("maps", "_quickload.dqm")) {
map_loadFromFile("_quickload.dqm")
app_setUpdatePathKind(.GAME)
}

Expand Down Expand Up @@ -445,12 +456,19 @@ world_reset :: proc() {




settings_setDefault :: proc() {
settings.drawFPS = false
settings.debugIsEnabled = false
settings.audioMasterVolume = 0.5
settings.crosshairOpacity = 0.2
settings.mouseSensitivity = 1.0
settings = {
drawFPS = false,
debugIsEnabled = false,
audioMasterVolume = 0.5,
audioMusicVolume = 0.4,
crosshairOpacity = 0.2,
mouseSensitivity = 1.0,
FOV = 100.0,
viewmodelFOV = 100.0,
gunXOffset = 0.1,
}
}

settings_getFilePath :: proc() -> string {
Expand All @@ -463,8 +481,12 @@ settings_saveToFile :: proc() {
"drawFPS", SERI_ATTRIB_SEPARATOR, " ", settings.drawFPS, "\n",
"debugIsEnabled", SERI_ATTRIB_SEPARATOR, " ", settings.debugIsEnabled, "\n",
"audioMasterVolume", SERI_ATTRIB_SEPARATOR, " ", settings.audioMasterVolume, "\n",
"audioMusicVolume", SERI_ATTRIB_SEPARATOR, " ", settings.audioMusicVolume, "\n",
"crosshairOpacity", SERI_ATTRIB_SEPARATOR, " ", settings.crosshairOpacity, "\n",
"mouseSensitivity", SERI_ATTRIB_SEPARATOR, " ", settings.mouseSensitivity, "\n",
"FOV", SERI_ATTRIB_SEPARATOR, " ", settings.FOV, "\n",
"viewmodelFOV", SERI_ATTRIB_SEPARATOR, " ", settings.viewmodelFOV, "\n",
"gunXOffset", SERI_ATTRIB_SEPARATOR, " ", settings.gunXOffset, "\n",
},
sep="",
)
Expand All @@ -487,13 +509,26 @@ settings_loadFromFile :: proc() {
if seri_attribMatch(buf, &index, "drawFPS") do settings.drawFPS = seri_readBool(buf, &index)
if seri_attribMatch(buf, &index, "debugIsEnabled") do settings.debugIsEnabled = seri_readBool(buf, &index)
if seri_attribMatch(buf, &index, "audioMasterVolume") do settings.audioMasterVolume = seri_readF32 (buf, &index)
if seri_attribMatch(buf, &index, "audioMusicVolume") do settings.audioMusicVolume = seri_readF32 (buf, &index)
if seri_attribMatch(buf, &index, "crosshairOpacity") do settings.crosshairOpacity = seri_readF32 (buf, &index)
if seri_attribMatch(buf, &index, "mouseSensitivity") do settings.mouseSensitivity = seri_readF32 (buf, &index)
if seri_attribMatch(buf, &index, "FOV") do settings.FOV = seri_readF32 (buf, &index)
if seri_attribMatch(buf, &index, "viewmodelFOV") do settings.viewmodelFOV = seri_readF32 (buf, &index)
if seri_attribMatch(buf, &index, "gunXOffset") do settings.gunXOffset = seri_readF32 (buf, &index)
}
}



gameStopSounds :: proc() {
rl.StopSound(map_data.elevatorSound)
rl.StopSound(player_data.swooshSound)
}





//
// BULLETS
//
Expand Down
52 changes: 39 additions & 13 deletions doq/gui.odin
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,18 @@ menu_updateAndDrawPauseMenu :: proc() {
gui_menuButton_t{"exit to desktop", &app_shouldExitNextFrame},

gui_menuTitle_t{"settings"},
gui_menuFloat_t{"audio volume", &settings.audioMasterVolume},
gui_menuFloat_t{"mouse sensitivity", &settings.mouseSensitivity},
gui_menuFloat_t{"crosshair visibility", &settings.crosshairOpacity},
gui_menuBool_t{"show FPS", &settings.drawFPS},
gui_menuBool_t{"enable debug mode", &settings.debugIsEnabled},
gui_menuFloat_t{"audio volume", &settings.audioMasterVolume, 0.05},
gui_menuFloat_t{"music volume", &settings.audioMusicVolume, 0.05},
gui_menuFloat_t{"mouse sensitivity", &settings.mouseSensitivity, 0.05},
gui_menuFloat_t{"crosshair visibility", &settings.crosshairOpacity, 0.1},
gui_menuFloat_t{"gun X offset", &settings.gunXOffset, 0.025},
gui_menuFloat_t{"fild of view", &settings.FOV, 10.0},
gui_menuFloat_t{"viewmodel field of view", &settings.viewmodelFOV, 10.0},
gui_menuBool_t{"show FPS", &settings.drawFPS},
gui_menuBool_t{"enable debug mode", &settings.debugIsEnabled},
}

menu_drawNavTips()
if gui_updateAndDrawElemBuf(elems[:]) {
settings_saveToFile()
}
Expand Down Expand Up @@ -235,6 +240,7 @@ menu_updateAndDrawMainMenuUpdatePath :: proc() {

rl.BeginDrawing()
rl.ClearBackground(rl.ColorFromNormalized(MENU_BACKGROUND))
menu_drawNavTips()
menu_drawDebugUI()

if menu_data.mapSelectIsOpen {
Expand Down Expand Up @@ -264,11 +270,15 @@ menu_updateAndDrawMainMenuUpdatePath :: proc() {
gui_menuButton_t{"exit to desktop", &app_shouldExitNextFrame},

gui_menuTitle_t{"settings"},
gui_menuFloat_t{"audio volume", &settings.audioMasterVolume},
gui_menuFloat_t{"mouse sensitivity", &settings.mouseSensitivity},
gui_menuFloat_t{"crosshair visibility", &settings.crosshairOpacity},
gui_menuBool_t{"show FPS", &settings.drawFPS},
gui_menuBool_t{"enable debug mode", &settings.debugIsEnabled},
gui_menuFloat_t{"audio volume", &settings.audioMasterVolume, 0.05},
gui_menuFloat_t{"music volume", &settings.audioMusicVolume, 0.05},
gui_menuFloat_t{"mouse sensitivity", &settings.mouseSensitivity, 0.05},
gui_menuFloat_t{"crosshair visibility", &settings.crosshairOpacity, 0.1},
gui_menuFloat_t{"gun size offset", &settings.gunXOffset, 0.025},
gui_menuFloat_t{"fild of view", &settings.FOV, 10.0},
gui_menuFloat_t{"viewmodel field of view", &settings.viewmodelFOV, 10.0},
gui_menuBool_t{"show FPS", &settings.drawFPS},
gui_menuBool_t{"enable debug mode", &settings.debugIsEnabled},
}

if gui_updateAndDrawElemBuf(elems[:]) {
Expand Down Expand Up @@ -315,7 +325,7 @@ menu_mainMenuFetchMapSelectFiles :: proc() {
if fileinfo.name[0] == '_' do continue // hidden
dotindex := strings.index_byte(fileinfo.name, '.')
if dotindex == 0 do continue
if fileinfo.name[dotindex:] != ".doqm" do continue // check suffix
if fileinfo.name[dotindex:] != ".dqm" do continue // check suffix
//menu_data.mapSelectFileElems[menu_data.mapSelectFileElemsCount] = gui_menuButton_t{fileinfo.name[:dotindex], &menu_data.mapSelectButtonBool}
menu_data.mapSelectFileElems[menu_data.mapSelectFileElemsCount] = gui_menuFileButton_t{
fileinfo.name[:dotindex], fileinfo.fullpath, &menu_data.mapSelectButtonBool,
Expand Down Expand Up @@ -353,6 +363,7 @@ menu_updateAndDrawLoadScreenUpdatePath :: proc() {

rl.BeginDrawing()
rl.ClearBackground(rl.ColorFromNormalized(linalg.lerp(vec4{0,0,0,0}, MENU_BACKGROUND, unfade)))

OFFS :: 200
STARTSCALE :: 12.0
scale := glsl.min(
Expand Down Expand Up @@ -380,6 +391,17 @@ menu_updateAndDrawLoadScreenUpdatePath :: proc() {



// draw info about the menu navigation
menu_drawNavTips :: proc() {
SIZE :: 25.0

gui_drawText(
{SIZE*2.0, f32(windowSizeY)-SIZE*3}, SIZE, {200,200,200,120},
"hold CTRL to skip to next title / edit values faster",
)
}





Expand All @@ -405,6 +427,7 @@ gui_menuBool_t :: struct {
gui_menuFloat_t :: struct {
name : string,
val : ^f32,
step : f32,
}

gui_menuTitle_t :: struct {
Expand Down Expand Up @@ -538,11 +561,14 @@ gui_updateAndDrawElemBuf :: proc(elems : []gui_menuElem_t) -> bool {
isEdited = true
}
case gui_menuFloat_t:
step := elem.step
if rl.IsKeyDown(rl.KeyboardKey.LEFT_CONTROL) do step *= 5.0

if rl.IsKeyPressed(rl.KeyboardKey.RIGHT) {
elem.val^ += 0.1
elem.val^ += step
isEdited = true
} else if rl.IsKeyPressed(rl.KeyboardKey.LEFT) {
elem.val^ -= 0.1
elem.val^ -= step
isEdited = true
}
case gui_menuTitle_t:
Expand Down
Loading

0 comments on commit 6dd34ef

Please sign in to comment.