Skip to content

Instantly share code, notes, and snippets.

View CodingDino's full-sized avatar

Sarah Herzog CodingDino

View GitHub Profile
@CodingDino
CodingDino / screensaver.py
Created May 17, 2024 15:06
Screensaver loading screen demo showing vectors in pygame
# Libraries to use. Pygame and system library
import pygame, sys, random, time, math
from pygame.locals import *
#-----------------------------------------------
# INITIALISATION
#-----------------------------------------------
# Set up pygame
pygame.init()
@CodingDino
CodingDino / Item.cpp
Created May 16, 2024 12:17
Polymorphism in an Adventure Game (Room and Thing unchanged so not included)
#include "Item.h"
#include <iostream>
Item::Item()
: Thing()
, useable(false)
{
}
Item::Item(string newName, string newDesc, bool newUseable)
@CodingDino
CodingDino / Item.cpp
Created May 9, 2024 22:52
Inheritance in an Adventure Game
#include "Item.h"
#include <iostream>
Item::Item()
: Thing()
, useable(false)
{
}
Item::Item(string newName, string newDesc, bool newUseable)
@CodingDino
CodingDino / drawRelative.py
Created May 2, 2024 17:17
Python script using pygame, illustrating how to use coordinates and create a relative draw function based on alignment with parts of the screen
# Libraries to use. Pygame and the system library.
import pygame, sys
from pygame.locals import *
# Set up pygame
pygame.init()
#Set up the window size and title text
SCREEN_WIDTH = 1000
SCREEN_HEIGHT = 500
@CodingDino
CodingDino / Main.cpp
Created May 2, 2024 16:16
Example of the use of Access Modifiers, Getters, and Setters in an Adventure Game
// Libraries
#include <string>
#include <iostream>
#include <vector>
#include "Room.h"
// Needed to avoid having to type std:: a lot!
using namespace std;
@CodingDino
CodingDino / Main.cpp
Last active May 2, 2024 15:56
Constructors and Destructors in an Adventure Game
// Libraries
#include <string>
#include <iostream>
#include <vector>
#include "Room.h"
// Needed to avoid having to type std:: a lot!
using namespace std;
@CodingDino
CodingDino / Dog.cpp
Created May 2, 2024 15:21
Example of Getters and Setters
#include "Dog.h"
#include <iostream>
using namespace std;
Dog::Dog()
: name("")
, breed("")
, color("")
, coatType("")
@CodingDino
CodingDino / Dog.h
Created May 2, 2024 14:40
Example of access modifiers used for Dog class
#pragma once
#include <string>
using namespace std;
class Dog
{
public:
string name;
@CodingDino
CodingDino / enemyDPS.py
Created April 18, 2024 21:34
An example of the use of multiple algebraic equations in game programming, using enemy DPS calculations
def calcEnemyDPS(t, h):
return h/t
def calcDamage(e,c):
return e * c
d = calcDamage(calcEnemyDPS(30,50),2)
@CodingDino
CodingDino / Main.cpp
Created April 18, 2024 21:16
OOP Classes and Cohesion Example - Dogs - Part 5 - Classes and Vectors
// When we add Dogs to this kennel, they are cloned! (copied in to the vector)
vector<Dog> cloningKennel;
cloningKennel.push_back(myDog1);
cloningKennel.push_back(myDog2);
cloningKennel.push_back(myDog3);
// Loop through the vector just like we learned before
for (int i = 0; i < cloningKennel.size(); ++i)
{