Digital and Interactive Games 2015, Term 2, Week 9, Session 1
Mastermind continued
Today:
int correctPlace = 0;
int correctColour = 0;
if new(i) = puzzle(i)
correctPlace++;
Square.cpp
#include "Square.h"
Square::Square()
{
DrawingObject::DrawingObject();
}
void Square::setUp(float size, ID2D1SolidColorBrush* brush) {
this->size = size;
setLocation(halfSize, halfSize);
setBrush(brush);
setActive(true);
}
void Square::setLocation(float x, float y) {
location.x = x;
location.y = y;
rect = D2D1_RECT_F(/*
D2D1::Point2F(location.x, location.y),
location.x - halfSize, location.y - halfSize, location.x + halfSize, location.y + halfSize*/
);
}
void Square::update(GameTime gameTime) {
velocity.setX(velocity.getX() + getAccelerationX());
velocity.setY(velocity.getY() + getAccelerationY() + getGravity());
setLocation(static_cast(location.x + velocity.getX() * static_cast(gameTime.getElapsedTime())),
static_cast(location.y + velocity.getY() * static_cast(gameTime.getElapsedTime())));
}
void Square::draw(ID2D1HwndRenderTarget* renderingTarget) {
renderingTarget->DrawRectangle(rect, brush, strokeWidth);
renderingTarget->FillRectangle(rect, brush);
}
Square::~Square()
{
}
BaseApp.h
#include “Square.h”
Mastermind.java
image.Background
background = new image(“media/Mastermind 002.png”)