Browse Source

Initial commit

Graham Northup 4 years ago
commit
dc6adcde33
Signed by: Grissess <grissess@nexusg.org> GPG Key ID: 5D000E6F539376FB
8 changed files with 62 additions and 0 deletions
  1. 15
    0
      README.md
  2. BIN
      senpai_bkgd.png
  3. BIN
      senpai_bkgd.xcf
  4. BIN
      senpai_eye.png
  5. BIN
      senpai_eye.xcf
  6. BIN
      senpai_eyemask.png
  7. BIN
      senpai_eyemask.xcf
  8. 47
    0
      senpai_simulator.py

+ 15
- 0
README.md View File

@@ -0,0 +1,15 @@
1
+# Senpai Simulator 2016
2
+
3
+The gaming sensation that's sweeping the nation!
4
+
5
+Note that this program uses only joystick inputs, and expects a two-stick
6
+controller. If you have one of these, but the axes are wrong, change this line
7
+as you see fit:
8
+
9
+```python
10
+    x1, y1, x2, y2 = map(joy.get_axis, [0, 1, 3, 4])
11
+```
12
+The `[0, 1, 3, 4]` correspond to left X, left Y, right X, and right Y axes
13
+respectively.
14
+
15
+There's no support for other input devices yet, sorry ¯\\_(ツ)_/¯

BIN
senpai_bkgd.png View File


BIN
senpai_bkgd.xcf View File


BIN
senpai_eye.png View File


BIN
senpai_eye.xcf View File


BIN
senpai_eyemask.png View File


BIN
senpai_eyemask.xcf View File


+ 47
- 0
senpai_simulator.py View File

@@ -0,0 +1,47 @@
1
+import pygame
2
+pygame.init()
3
+
4
+disp = pygame.display.set_mode((1480, 1080), pygame.FULLSCREEN)
5
+
6
+joys = [pygame.joystick.Joystick(i) for i in range(pygame.joystick.get_count())]
7
+print(joys)
8
+for joy in joys:
9
+    joy.init()
10
+
11
+BKGD = pygame.image.load('senpai_bkgd.png').convert_alpha()
12
+EYE_FULL = pygame.image.load('senpai_eye.png')
13
+EYE = EYE_FULL.convert_alpha()
14
+EYE_MASK = pygame.image.load('senpai_eyemask.png').convert_alpha()
15
+INV_MASK = pygame.Surface(EYE_MASK.get_size(), pygame.SRCALPHA)
16
+INV_MASK.fill((255, 255, 255, 255))
17
+INV_MASK.blit(EYE_MASK, (0, 0), None, pygame.BLEND_RGBA_SUB)
18
+##EYE_SF = 0.15
19
+##EYE = pygame.transform.smoothscale(EYE_FULL, list(map(int, (EYE_SF * EYE_FULL.get_width(), EYE_SF * EYE_FULL.get_height())))).convert_alpha()
20
+EYE_OFF = (EYE.get_width() / 2, EYE.get_height() / 2)
21
+LE_CEN = (878, 552)
22
+RE_CEN = (631, 588)
23
+LE_DEL = (50, 20)
24
+RE_DEL = (40, 20)
25
+msk_tmp = EYE_MASK.copy().convert_alpha()
26
+bkd_tmp = INV_MASK.copy().convert_alpha()
27
+
28
+while True:
29
+    for ev in pygame.event.get():
30
+        ##print(ev)
31
+        if ev.type == pygame.KEYDOWN and ev.key == pygame.K_ESCAPE:
32
+            exit()
33
+    disp.fill((255, 255, 255))
34
+    ##w, h = disp.get_size()
35
+    ##w2, h2, w4, h4 = w / 2, h / 2, w / 4, h / 4
36
+    joy = joys[0]
37
+    x1, y1, x2, y2 = map(joy.get_axis, [0, 1, 3, 4])
38
+    ##pygame.draw.circle(disp, (255, 255, 255), (int(w4 * x1 + w4), int(h2 * y1 + h2)), 15)
39
+    ##pygame.draw.circle(disp, (255, 255, 255), (int(w4 * x2 + w4 + w2), int(h2 * y2 + h2)), 15)
40
+    msk_tmp.blit(EYE_MASK, (0, 0))
41
+    msk_tmp.blit(EYE, (RE_CEN[0] + int(RE_DEL[0] * x1) - EYE_OFF[0], RE_CEN[1] + int(RE_DEL[1] * y1) - EYE_OFF[1]), None, pygame.BLEND_RGBA_MULT)
42
+    msk_tmp.blit(EYE, (LE_CEN[0] + int(LE_DEL[0] * x2) - EYE_OFF[0], LE_CEN[1] + int(LE_DEL[1] * y2) - EYE_OFF[1]), None, pygame.BLEND_RGBA_MULT)
43
+    bkd_tmp.blit(INV_MASK, (0, 0))
44
+    bkd_tmp.blit(BKGD, (0, 0), None, pygame.BLEND_RGBA_MULT)
45
+    disp.blit(msk_tmp, (0, 0))
46
+    disp.blit(bkd_tmp, (0, 0))
47
+    pygame.display.flip()

Loading…
Cancel
Save