Skip to content

Instantly share code, notes, and snippets.

Created January 11, 2013 11:59
Show Gist options
  • Save anonymous/4510190 to your computer and use it in GitHub Desktop.
Save anonymous/4510190 to your computer and use it in GitHub Desktop.
Snowflake.qml
import QtQuick 1.1
Rectangle { //background rectangle
id: background //name of the object
color: "white" //background colour
width: 800 //width of background
height: 600 //height of background
Rectangle {
id: skullflake
width: 15
height: 15
y: 560
x: {
Math.floor(Math.random() * 770) + 15
}
}
Timer { //spawnrate
interval: 2000; running: true; repeat: true
onTriggered: Qt.createQmlObject(skullflake)
}
Rectangle { //rectangle on the right border of screen
id: borderright
x: 797
y: 0
width: 3
height: 600
color: "light grey"
}
Rectangle { //rectangle on the left border of screen
id: borderleft
x: 0
y: 0
width: 3
height: 600
color: "light grey"
}
Rectangle { //player basket
id: basket
x: 350 //x start position of basket
y: 556 //y start position of basket
width: 100
height: 44
focus: true
Image {
id: basketmodel
x: basket.x
y: 258
width: 100
height: 44
anchors.fill: parent
source: "player.png"
}
Item { //Controls the boundaries of the edges in the game
id: edges
function leftedge() { //Javascript function for left edge
if (basket.x < 1)
return basket.x = 1;
}
function rightedge() { //Javascript function for right edge
if (basket.x > 700)
return basket.x = 700;
}
}
Keys.onRightPressed: {
basket.x += 10 //movement towards right with right arrowkey
edges.rightedge();
}
Keys.onLeftPressed: {
basket.x -= 10 //movement towards right with left arrowkey
edges.leftedge();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment