This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
QList<int> Hangman::findAllOccurrences(const QChar& theChar, const QString& theStr) | |
{ | |
QList<int> occurrences; | |
for (int i = 0; i < theStr.size(); i++) | |
{ | |
if (theStr.at(i).toUpper() == theChar.toUpper()) | |
{ | |
occurrences.push_back(i); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add letters to our vector using ASCII conversion (saves typing =p) | |
for (int i = 65; i < 91; i++) | |
{ | |
char letter = static_cast<char> (i); | |
alphabet.push_back(QString(letter)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool Hangman::isAlpha(const QString& key) | |
{ | |
if (alphabet.size() > 0) | |
{ | |
return alphabet.contains(key.toUpper()); | |
} | |
return false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
{ | |
public: | |
Foo() { std::cout << "ctor\n"; } | |
~Foo() { std::cout << "dtor\n"; } | |
}; | |
int main() | |
{ | |
std::vector<Foo> foos; | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void reverse(char str[]) | |
{ | |
// Add 1 for the terminating character | |
int len = strlen(str) + 1; | |
char temp[len]; | |
// Data resides from indices 0-2 | |
int i = len - 2; | |
for (; i >= 0; --i) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void swap(char str[], | |
const int firstIndex, | |
const int secondIndex) | |
{ | |
char temp = str[firstIndex]; | |
str[firstIndex] = str[secondIndex]; | |
str[secondIndex] = temp; | |
} | |
void reverse2(char src[]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//utils.h | |
#ifndef UTILS_H | |
#define UTILS_H | |
#include | |
struct Point2d | |
{ | |
float x; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CircularList.hpp | |
// | |
// Zach Elko | |
// 2010 | |
// | |
// Simple templated data structure that allows you to toggle 'wrap-around' behavior | |
// to achieve a circular list. | |
// | |
#ifndef CIRCULAR_LIST_H | |
#define CIRCULAR_LIST_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find the shortest beaker so we know which drops to check for collisions | |
# against | |
beakerHeights = [] | |
shortest = 0 | |
for beaker in level.beakers: beakerHeights.append(beaker.rect.y) | |
beakerHeights.sort() | |
if (beakerHeights): shortest = beakerHeights[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def render(self, screen): | |
screen.blit(self.image, (self.rect.x, self.rect.y)) | |
if (self.drops > 0): | |
x = self.rect.x + 2 | |
rainColor = () | |
if (self.full): | |
level = 1 | |
rainColor = (255,0,0) | |
else: |
OlderNewer