Skip to content

Instantly share code, notes, and snippets.

View KenoLeon's full-sized avatar

Keno Leon KenoLeon

View GitHub Profile
@KenoLeon
KenoLeon / Indexing_Slicing_MultDim.py
Created August 13, 2020 00:37
Indexing slicing multidimensional arrays Numpy
import numpy as np
multiDimnArray = np.array([[1, 2, 3, 4], [5, 6, 7, 8]])
# Dimensions: 2
# Shape: (2, 4)
# -------------- SELECTING: --------------
multiDimnArray[0, 1] # Second element from first array
# >>> 2
@KenoLeon
KenoLeon / Numpy_Reshape.py
Last active August 14, 2020 01:22
Numpy_Reshape
import numpy as np
array_of_ones = np.ones(10, dtype=np.uint8)
# [1 1 1 1 1 1 1 1 1 1]
# Dimensions: 1
# Shape: (10,)
@KenoLeon
KenoLeon / PyGame_Starter.py
Last active November 10, 2020 20:59
PyGame Starter
import sys
import pygame
from pygame.locals import KEYDOWN, K_q
# CONSTANTS:
SCREENSIZE = WIDTH, HEIGHT = 600, 400
BLACK = (0, 0, 0)
GREY = (160, 160, 160)
# GLOBAL VARS, Using a Dictionary.
_VARS = {'surf': False}
import sys
import pygame
from pygame.locals import KEYDOWN, K_q
# CONSTANTS:
SCREENSIZE = WIDTH, HEIGHT = 600, 400
BLACK = (0, 0, 0)
GREY = (160, 160, 160)
PADDING = PADTOPBOTTOM, PADLEFTRIGHT = 60, 60
# VARS:
import sys
import pygame
from pygame.locals import KEYDOWN, K_q
# CONSTANTS:
SCREENSIZE = WIDTH, HEIGHT = 600, 400
BLACK = (0, 0, 0)
GREY = (160, 160, 160)
PADDING = PADTOPBOTTOM, PADLEFTRIGHT = 60, 60
# VARS:
import sys
import pygame
from pygame.locals import KEYDOWN, K_q
# CONSTANTS:
SCREENSIZE = WIDTH, HEIGHT = 600, 400
BLACK = (0, 0, 0)
GREY = (160, 160, 160)
# VARS:
_VARS = {'surf': False}
import sys
import pygame
from pygame.locals import KEYDOWN, K_q
# CONSTANTS:
SCREENSIZE = WIDTH, HEIGHT = 600, 400
BLACK = (0, 0, 0)
GREY = (160, 160, 160)
# VARS:
_VARS = {'surf': False}
import sys
import pygame
from pygame.locals import KEYDOWN, K_q
# CONSTANTS:
SCREENSIZE = WIDTH, HEIGHT = 800, 600
BLACK = (0, 0, 0)
GREY = (160, 160, 160)
# NOTE WE MOVED ALL GRID CONSTANTS HERE FOR CONVENIENCE:
_VARS = {'surf': False, 'gridWH': 400,
import numpy as np
# CREATE AN EMPTY (zeros) list of lists:
MAP = np.zeros((6, 6), dtype=int)
print(MAP)
print(MAP.shape)
print(MAP.shape[0]) # ROWS
print(MAP.shape[1]) # COLUMNS
import sys
import pygame
from pygame.locals import KEYDOWN, K_q
import numpy as np
# CONSTANTS:
SCREENSIZE = WIDTH, HEIGHT = 800, 600
BLACK = (0, 0, 0)
GREY = (160, 160, 160)