aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGene Pasquet <dev@etenil.net>2024-05-24 17:06:40 +0100
committerGene Pasquet <dev@etenil.net>2024-05-24 17:06:40 +0100
commitc27a672ee7d67c9376c3a5d7692e2f060583fffa (patch)
tree96d437cf5bab5d1aaf88ee3a2414ada0ef7b0559
parentd3454d9954393626a42e99cdb2a28481408b674f (diff)
Added dashboard displays
-rw-r--r--7segment-background.pngbin0 -> 160 bytes
-rwxr-xr-xDSEG-LICENSE.txt95
-rw-r--r--DSEG7Classic-Regular.ttfbin0 -> 23272 bytes
-rw-r--r--TODO.org7
-rw-r--r--dash-background.pngbin0 -> 303 bytes
-rw-r--r--turbo.scm56
6 files changed, 146 insertions, 12 deletions
diff --git a/7segment-background.png b/7segment-background.png
new file mode 100644
index 0000000..56c1edd
--- /dev/null
+++ b/7segment-background.png
Binary files differ
diff --git a/DSEG-LICENSE.txt b/DSEG-LICENSE.txt
new file mode 100755
index 0000000..ad4c0bf
--- /dev/null
+++ b/DSEG-LICENSE.txt
@@ -0,0 +1,95 @@
+Copyright (c) 2017, keshikan (http://www.keshikan.net),
+with Reserved Font Name "DSEG".
+
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/DSEG7Classic-Regular.ttf b/DSEG7Classic-Regular.ttf
new file mode 100644
index 0000000..5e02edc
--- /dev/null
+++ b/DSEG7Classic-Regular.ttf
Binary files differ
diff --git a/TODO.org b/TODO.org
index bd5db55..a6c0b9f 100644
--- a/TODO.org
+++ b/TODO.org
@@ -11,14 +11,13 @@
** DONE Add restart option
** DONE Smooth acceleration
** DONE Measure traveled distance
-** TODO Smooth increasing turn rate
** DONE Display level on screen
-** TODO Level up automatically
+** DONE Level up automatically
+** DONE Add graphical speedometer (look at knight rider)
+** TODO Add start menu
** TODO Add weapon to player car
*** TODO Make weapon a power-up
*** TODO Make weapon use limited (bullet? time?)
-** TODO Add graphical speedometer (look at knight rider)
** TODO Improve visuals
-** TODO Add start menu
** DONE Add music
** STARTED Add sound effects
diff --git a/dash-background.png b/dash-background.png
new file mode 100644
index 0000000..abb8e60
--- /dev/null
+++ b/dash-background.png
Binary files differ
diff --git a/turbo.scm b/turbo.scm
index 09b9d4c..c28f508 100644
--- a/turbo.scm
+++ b/turbo.scm
@@ -10,6 +10,7 @@
;;;; Constants and variables
(define the-font (load-bitmap-font "thick_8x8.xml"))
+(define font-7-segments (load-font "DSEG7Classic-Regular.ttf" 24))
(define lane-height 65)
(define lane-length 192)
@@ -22,6 +23,10 @@
(define road-bottom (texture-atlas-ref road 0))
(define road-lane (texture-atlas-ref road 1))
(define grass (load-image "grass.png"))
+(define dashboard-set (load-tileset "dash-background.png" 64 64))
+(define dash-background (texture-atlas-ref dashboard-set 0))
+(define dash-7seg-background (texture-atlas-ref dashboard-set 1))
+
(define grass-height 96)
(define vehicles-sprites (load-tileset "vehicles.png" vehicle-length vehicle-height))
@@ -36,6 +41,11 @@
(define player-car-deceleration -500)
(define player-current-acceleration 0)
(define player-distance-travelled 0)
+(define (distance-in-miles)
+ (/ player-distance-travelled 12440))
+
+(define (speed-in-mph)
+ (* (vehicle-speed player-car) 0.11187))
(define level-difficulty 1)
@@ -118,7 +128,7 @@
(* lane-height (- num-lane 1))))
(define initial-player-position
- (vec2 (/ (- (window-width (current-window)) vehicle-length) 4)
+ (vec2 (/ (- (window-width (current-window)) vehicle-length) 6)
(+ (lane-y 3)
(/ (- lane-height vehicle-height) 2))))
@@ -188,6 +198,10 @@
(set! player-distance-travelled (+ player-distance-travelled (* interval (vehicle-speed player-car))))
+ ;; Increase level every 2 miles
+ (when (and (< level-difficulty 20) (> (distance-in-miles) (* 2 level-difficulty)))
+ (set! level-difficulty (+ 1 level-difficulty)))
+
(let ((new-speed (+ (vehicle-speed player-car)
(* player-current-acceleration interval))))
(set-vehicle-speed! player-car (min player-max-speed
@@ -215,7 +229,7 @@
(for-each vehicle-reset-ahead (filter vehicle-off-screen? vehicles))
;; Randomly respawn vehicles based on level difficulty
- (let ((challenge (- (/ 200 level-difficulty) 9)))
+ (let ((challenge (- (round (/ 200 level-difficulty)) 9)))
(when (= 0 (random challenge))
(let* ((inactive-vehicles (filter vehicle-inactive? vehicles))
(spawnable-vehicles (filter vehicle-has-spawn-space? inactive-vehicles)))
@@ -240,18 +254,42 @@
(draw-sprite (vehicle-sprite veh) (vehicle-position veh)))
(filter vehicle-active? vehicles))
- (draw-text (format #f "Distance: ~1,1fmi" (/ player-distance-travelled 12440))
- (vec2 30.0 (- (window-height (current-window)) 25))
+ (let loop ((index 0))
+ (draw-sprite dash-background (vec2 index 0))
+ (when (< (+ index (texture-width dash-background)) (window-width (current-window)))
+ (loop (+ index (texture-width dash-background)))))
+
+ (draw-sprite dash-7seg-background (vec2 270 0))
+ (draw-sprite dash-7seg-background (vec2 324 0))
+ (draw-text (format #f "~5,1,,,'0f" (distance-in-miles))
+ (vec2 275 20)
+ #:font font-7-segments
+ #:color red)
+ (draw-text "MI"
+ (vec2 395 12)
#:font the-font
#:scale (vec2 2 2))
- (draw-text (format #f "Speed: ~smph" (round (* (vehicle-speed player-car) 0.11187)))
- (vec2 400.0 20.0)
+ (draw-sprite dash-7seg-background (vec2 450 0))
+ (draw-sprite dash-7seg-background (vec2 503 0))
+ (draw-text (format #f "~5,1,,,'0f" (speed-in-mph))
+ (vec2 455.0 20.0)
+ #:font font-7-segments
+ #:color red)
+ (draw-text "MPH"
+ (vec2 570 12)
#:font the-font
#:scale (vec2 2 2))
- (draw-text (format #f "Level: ~s" level-difficulty)
- (vec2 30.0 20.0)
+ (draw-sprite dash-7seg-background
+ (vec2 20 0)
+ #:scale (vec2 0.5 1))
+ (draw-text (format #f "~s" level-difficulty)
+ (vec2 20.0 20.0)
+ #:font font-7-segments
+ #:color red)
+ (draw-text "LVL"
+ (vec2 60.0 12.0)
#:font the-font
#:scale (vec2 2 2))
@@ -274,6 +312,8 @@
((eq? key 'escape)
(abort-game))
((and (eq? key 'return) game-over)
+ (set! player-distance-travelled 0)
+ (set! level-difficulty 1)
(set-vehicle-position! player-car initial-player-position)
(set-player-speed! (level-min-speed))
(set! player-rotation 0)