Skip to content

Commit

Permalink
Add gun
Browse files Browse the repository at this point in the history
  • Loading branch information
raub committed Nov 13, 2023
1 parent 7d10634 commit a18a837
Show file tree
Hide file tree
Showing 18 changed files with 606 additions and 127 deletions.
576 changes: 491 additions & 85 deletions examples/fps/main.ts

Large diffs are not rendered by default.

Binary file added examples/fps/models/Flamingo.glb
Binary file not shown.
Binary file added examples/fps/models/blasterG.glb
Binary file not shown.
Binary file added examples/fps/models/targetB.glb
Binary file not shown.
4 changes: 2 additions & 2 deletions examples/fps/qml/EscMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ Rectangle {
}

MenuItem {
text: 'Quit'
text: 'Leave'
Layout.alignment: Qt.AlignCenter
onPressed: eventEmit('custom-esc', { button: 'quit' });
onPressed: eventEmit('custom-esc', { button: 'leave' });
}
}
}
19 changes: 19 additions & 0 deletions examples/fps/qml/HpTextLarge.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import QtQuick 2.7


Text {
FontLoader { id: future; source: 'fonts/Kenney Future Narrow.ttf' }

readonly property int fontSizeHp: 84
readonly property string shadowColor: '#333333'

text: '100'

font.pixelSize: fontSizeHp
font.bold: true
font.family: future.name
color: 'green'

style: Text.Raised;
styleColor: hudView.shadowColor
}
3 changes: 2 additions & 1 deletion examples/fps/qml/Hud.qml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import QtQuick 2.7
import QtQuick.Layouts 1.3


Item {
objectName: 'hud'
anchors.fill: parent
Expand All @@ -12,6 +11,7 @@ Item {
property alias hp: hud.hp
property alias charge: hud.charge
property alias fuel: hud.fuel
property alias score: over.score
property string mode: 'start'

StartMenu {
Expand All @@ -28,6 +28,7 @@ Item {
}

OverMenu {
id: over
visible: mode === 'over'
}
}
2 changes: 2 additions & 0 deletions examples/fps/qml/HudTextSmall.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import QtQuick 2.7


Text {
FontLoader { id: bookxel; source: 'fonts/Bookxel.otf' }

readonly property int fontSizeSmall: 36
readonly property string shadowColor: '#333333'

Expand Down
15 changes: 3 additions & 12 deletions examples/fps/qml/HudView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import QtQuick.Layouts 1.3


Item {
readonly property int fontSizeHp: 84
readonly property int ammoBarWidth: 400
readonly property int ammoBarHeight: 42
readonly property int paddingHor: 42
Expand All @@ -15,7 +14,6 @@ Item {
id: hudView
anchors.fill: parent

objectName: 'hud'
property real hp: 100
property real charge: 0
property real fuel: 1
Expand Down Expand Up @@ -51,16 +49,9 @@ Item {
Layout.topMargin: hudView.paddingVert
Layout.alignment: Qt.AlignLeft | Qt.AlignBottom

Text {
HpTextLarge {
text: Math.floor(hudView.hp)

font.pixelSize: fontSizeHp
font.bold: true
font.family: future.name
color: getColor(hudView.hp)

style: Text.Raised;
styleColor: hudView.shadowColor
}

HudTextSmall {
Expand Down Expand Up @@ -97,7 +88,7 @@ Item {
anchors.topMargin: 3

border.color: hudView.shadowColor
border.width: 1
border.width: 2
color: 'green'

transitions: Transition {
Expand All @@ -116,7 +107,7 @@ Item {
anchors.bottomMargin: 3

border.color: hudView.shadowColor
border.width: 1
border.width: 2
color: 'orange'

transitions: Transition {
Expand Down
16 changes: 7 additions & 9 deletions examples/fps/qml/MenuItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import QtQuick 2.7
import QtQuick.Layouts 1.3


Item {
MouseArea {
FontLoader { id: future; source: 'fonts/Kenney Future Narrow.ttf' }

readonly property int fontSizeEsc: 48
readonly property string shadowColor: '#333333'
readonly property string textColor: '#CCCCCC'
Expand All @@ -15,26 +17,22 @@ Item {

property alias text: buttonText.text

hoverEnabled: true
width: buttonText.width + 2 * paddingHor
height: buttonText.height

onClicked: pressed()

Text {
id: buttonText
text: 'EscMenuItem'

font.pixelSize: button.fontSizeEsc
font.bold: true
font.family: future.name
color: mouseArea.containsMouse ? button.textColorHover : button.textColor
color: button.containsMouse ? button.textColorHover : button.textColor

style: Text.Raised;
styleColor: button.shadowColor
}

MouseArea {
id: mouseArea
hoverEnabled: true
anchors.fill: parent
onClicked: parent.pressed()
}
}
9 changes: 9 additions & 0 deletions examples/fps/qml/OverMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@ Rectangle {
anchors.fill: parent
color: '#BB000000'

property alias score: score.score

ColumnLayout {
anchors.centerIn: parent
spacing: 32

Item {
Layout.alignment: Qt.AlignCenter
Score {
id: score
}
}

MenuItem {
text: 'Restart'
Layout.alignment: Qt.AlignCenter
Expand Down
8 changes: 4 additions & 4 deletions examples/fps/qml/Score.qml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import QtQuick.Layouts 1.3


Item {
FontLoader { id: future; source: 'fonts/Kenney Future Narrow.ttf' }
FontLoader { id: bookxel; source: 'fonts/Bookxel.otf' }

readonly property int fontSizeTitle: 84
readonly property int fontSizeValue: 110
readonly property string shadowColor: '#222222'
Expand All @@ -13,9 +16,6 @@ Item {

property real score: 0

FontLoader { id: future; source: 'fonts/Kenney Future Narrow.ttf' }
FontLoader { id: bookxel; source: 'fonts/Bookxel.otf' }

ColumnLayout {
anchors.centerIn: parent

Expand All @@ -33,7 +33,7 @@ Item {
}

Text {
text: root.score
text: Math.min(9999, root.score)
Layout.alignment: Qt.AlignCenter

font.pixelSize: fontSizeValue
Expand Down
1 change: 1 addition & 0 deletions examples/fps/qml/_preview.pro
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin

DISTFILES += \
EscMenu.qml \
HpTextLarge.qml \
Hud.qml \
HudTextSmall.qml \
HudView.qml \
Expand Down
80 changes: 66 additions & 14 deletions examples/fps/qml/_preview.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import QtQuick 2.7
import QtQuick.Window 2.7
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.3

Window {
visible: true
Expand All @@ -13,32 +14,83 @@ Window {
console.log('EVENT', type, JSON.stringify(data));
}

readonly property var hudModes: ["start", "hud", "esc", "over"]

Image {
anchors.fill: parent
source: "_preview.png"
fillMode: Image.Stretch
}

Score {
score: 123
score: sliderScore.value
}

Hud {
id: hud
mode: "start"
}

ComboBox {
id: selectMode
currentIndex: 0
model: ["start", "hud", "esc", "over"]
width: 200
onCurrentIndexChanged: {
if (selectMode.model.length) {
hud.mode = selectMode.model[currentIndex];
}
mode: hudModes[selectMode.currentIndex]
hp: sliderHp.value
charge: sliderCharge.value
fuel: sliderFuel.value
}

ColumnLayout {
id: selectModeBox
anchors.left: parent.left
anchors.leftMargin: 20
width: 140
HudTextSmall {
text: 'Mode:'
}

ComboBox {
id: selectMode
currentIndex: 0
model: hudModes.slice()
Layout.alignment: Qt.AlignJustify
}
}

Slider {
id: sliderFuel
x: 424
y: 0
value: 1
width: 140
anchors.left: selectModeBox.right
anchors.leftMargin: 20
}

Slider {
id: sliderCharge
x: 636
y: 0
width: 140
anchors.left: sliderFuel.right
anchors.leftMargin: 20
}

Slider {
id: sliderHp
x: 211
y: 0
stepSize: 1
value: 100
maximumValue: 100
width: 140
anchors.left: sliderCharge.right
anchors.leftMargin: 20
}

Slider {
id: sliderScore
x: 844
y: 0
stepSize: 100
value: 0
maximumValue: 9999
width: 140
anchors.left: sliderHp.right
anchors.leftMargin: 20
}
}

Expand Down
Binary file added examples/fps/qml/sfx/accept.wav
Binary file not shown.
Binary file added examples/fps/qml/sfx/button.wav
Binary file not shown.
Binary file added examples/fps/qml/sfx/flaunch.wav
Binary file not shown.
Binary file added examples/fps/qml/sfx/stepstone_1.wav
Binary file not shown.

0 comments on commit a18a837

Please sign in to comment.