-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray.go
327 lines (251 loc) · 6.5 KB
/
array.go
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
package main
import (
"fmt"
"log"
"os/exec"
"os"
"math/rand/v2"
"github.com/eiannone/keyboard"
)
//main function is basically a functioning level. I could copy and paste it and make more levels. that'd be pretty cool, and it'd make it easier for people to make their own levels. although I might be the only person who would.
func main() {
var chr = "\033[41mX"
var fuck [20][20]string
fuck = newMap()
printMap(fuck)
//var choice string
var x int
var y int
x = 3
y = 5
//cX and cY are the customers pos
cX := 5
cY := 4
//drugs sold
drugSold := 0
//player money
money := 0
//stash is the amount of drugs the player has, the player starts with a q
stash:= 7
// Start listening to the keyboard
err := keyboard.Open()
if err != nil {
log.Fatal(err)
}
defer keyboard.Close()
for {
//fmt.Println("type command up")
//fmt.Scanln(&choice)
// Non-blocking listen for keypress
char, key, err := keyboard.GetKey()
if err != nil {
log.Fatal(err)
}
fmt.Println(key)
switch char {
case 'w':
x--
if boundries(x, y) == true {
x++
continue
}
if x == 0 {
x++
continue
}
case 's':
x++
if boundries(x, y) == true {
x--
continue
}
if x == 19 {
x--
continue
}
case 'd':
y++
if boundries(x, y) == true {
y--
continue
}
if y == 19 {
y--
continue
}
case 'a':
y--
if boundries(x, y) == true {
y++
continue
}
if y == 0 {
y++
continue
}
case 'q': // Quit the game with 'q' or ESC
return
}
clear()
fuck = newMap()
//reminder to make collision work
fuck[3][7] = "\033[45m="
fuck[3][8] = "\033[45m="
fuck[3][9] = "\033[45m="
fuck[5][7] = "\033[44mH"
fuck[5][8] = "\033[49mn"
fuck[5][9] = "\033[44mH"
fuck[4][7] = "\033[44mH"
fuck[4][8] = "\033[44mH"
fuck[4][9] = "\033[44mH"
fuck[cX][cY] = "\033[41mE"
fuck[x][y] = chr
//print map here
printMap(fuck)
//if customer is touching player they'll do a drug deal
if fuck[cX][cY] == chr {
//log.Fatal()
if stash >= 1{
stash--
//10 bucks a gram firms
money += 10
drugSold++
cX = rand.IntN(18) + 1
cY = rand.IntN(18) + 1
if boundries(cX, cY) == true {
cX = rand.IntN(18) + 1
cY = rand.IntN(18) + 1
}
} else {
fmt.Println("get more dope!")
}
}
//printMap(fuck)
// this is what happens when you enter the house
if fuck[5][8] == chr {
//levelTwo()
if money >= 60 {
money -= 60
stash += 7
} else {
fmt.Println("get more money")
}
}
//printMap(fuck)
//I fucked up and var x measures the vertical position. var y measures the horizontal position. I switched it in the print statement so it's technically right.
fmt.Println("Y:", x)
fmt.Println("X:", y)
fmt.Println("money:", money)
fmt.Println("Stash", stash, "grams")
fmt.Println("Drugs Sold:", drugSold)
fmt.Println("press Q to quit")
continue
}
}
//boundries func is called everytime the player moves. if it returns true the player shouldnt move into that space cause its prolly a house.
func boundries(x, y int) bool {
var penis bool
switch {
//here you can add switch case statements to make the player collidee with parts of the grid
//basically if x is one coordinate of the house and y is also a coordinate of the house, player no move
case x == 3 && y == 7:
penis = true
case x == 3 && y == 8:
penis = true
case x == 3 && y == 9:
penis = true
case x == 4 && y == 7:
penis = true
case x == 4 && y == 8:
penis = true
case x == 4 && y == 9:
penis = true
case x == 5 && y == 7:
penis = true
//x5 y8 at the house is the door
case x == 5 && y == 8:
penis = false
case x == 5 && y == 9:
penis = true
}
return penis
}
func levelTwo() {
var chr = "8"
var fuck [20][20]string
fuck = newMap()
printMap(fuck)
var choice string
var x int
var y int
for {
fmt.Println("type command up")
fmt.Scanln(&choice)
switch choice {
case "up", "w":
x--
case "down", "s":
x++
case "left", "a":
y--
case "right", "d":
y++
}
if fuck[5][4] == chr {
log.Fatal()
}
if fuck[5][8] == chr {
}
clear()
fuck = newMap()
fuck[1][5] = "%"
fuck[1][6] = "%"
fuck[1][7] = "%"
fuck[3][5] = "H"
fuck[3][6] = "n"
fuck[3][7] = "H"
fuck[2][5] = "H"
fuck[2][6] = "H"
fuck[2][7] = "H"
fuck[5][4] = "E"
fuck[x][y] = chr
printMap(fuck)
}
}
func clear() {
cmd := exec.Command("clear")
cmd.Stdout = os.Stdout
cmd.Run()
}
//prints 2d array
func printMap(fuck [20][20]string) {
/* for d := 0; d <= 9; d++ {
fmt.Println("", fuck[d], " ", "\n")
}
fmt.Println()*/
for i := 0; i < len(fuck); i++ { // Loop through each row
for j := 0; j < len(fuck[i]); j++ { // Loop through each element in the row
fmt.Print(fuck[i][j], " ") // Print element with a space
}
fmt.Println() // Move to the next line after printing a row
}
}
//THIS IS WHERE YOU CAN CHANGE THE BACKGROUND SHIT
//returns 2d array of all Xs
func newMap() [20][20]string {
borderColor := "\033[40mX"
backGroundColor := "\033[42m0"
var fuck [20][20]string
for j := 0; j <= 19; j++ {
for i := 0; i <= 19; i++ {
fuck[j][i] = borderColor
}
}
//this part fills the inside with 0s
for d := 1; d <= 18; d++ {
for f := 1; f <= 18; f++ {
fuck[d][f] = backGroundColor
}
}
return fuck
}