-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame-explorer.grph
More file actions
81 lines (81 loc) · 2.26 KB
/
game-explorer.grph
File metadata and controls
81 lines (81 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#requires GRPH 1.7
#import stdio
#import math
#import random
// Menu
//shape game = back
//back = (640,480 WHITE)
//shape start = Text(["Start"] 100,100 0 40 BLUE)
//setHCentered: start
//validate: start
//#while start != getSelectedShape[this]
// Game
back = (640,480 AQUA)
/// The color of the grass
color grassc = color[0 128 0]
/// The grass rectangle, at the bottom
shape grass = Rect(0,400 640,80 grassc)
validate: grass
/// The ball
shape ball = Circle(90,325 75,75 radial[YELLOW 0.5,0.5 ORANGE 0.5])
validate: ball
/// Indicates the ball's current jumping status
integer jumping = 0
/// Current handling obstacle, ball by default because null doesn't exists
shape obs = ball
/// Number of obstacles
integer obsCount = 0
/// Number of obstacles that has been removed when they became invisible
integer removedObstacles = 0
/// Current handling obstacle number
integer currentObstacle = 0
/// Time before next obstacle spawns
integer nextObstacle = 1000
#while true
#if isKeyPressedWithKeyCode[32] && jumping <= 0
jumping = 250
#if jumping > 150
translate ball: 0,-1
jumping -= 1
#elseif jumping > 100
jumping -= 1
#elseif getYForPos[getPosition[ball]] < 325 // TODO change to platforms
translate ball: 0,1
#if jumping > 0
jumping -= 1
//
#if nextObstacle <= 0
obsCount += 1
obs = Polygon(toString["Obstacle" obsCount] grassc 640,400 660,350 680,400)
validate: obs
nextObstacle = 300 + randomInteger[2000]
#else
nextObstacle -= 1
currentObstacle = removedObstacles + 1
#while currentObstacle <= obsCount
obs = getShapeNamed[toString["Obstacle" currentObstacle]]
translate obs: -1,0
#if getXForPos[getPoint[obs 0]] < 0 - 40
unvalidate: obs
removedObstacles = currentObstacle
#elseif intersects[ball obs]
unvalidate: grass
unvalidate: ball
back = (640,480 RED)
shape go = Text(["Game over"] 197,100 0 50 WHITE)
validate: go
string s = toString["You" "survived" [divide[getTimeInMillisSinceLoad[] 1000]] "seconds"]
shape survTime = Text(s 100,160 0 30 WHITE)
setHCentered: survTime
validate: survTime
s = toString["You" "survived" "to" [currentObstacle - 1] "obstacles"]
shape survObs = Text(s 100,210 0 30 WHITE)
setHCentered: survObs
validate: survObs
end:
currentObstacle += 1
//
rotate ball: 1°
wait: 1
//
//