Digital
and Interactive Games 2015 – Term 2, Week 8, Session 2
Today – Spawn Object & Remove Object
Balls
BaseApp.h
BaseApp.cpp
it = at(2)
http://i483.photobucket.com/albums/rr193/Brenorenz/W16001_zpsccyurnf9.png
1. if declaring
std::vector<objects> objects
use the clean up
delete __
erase __
Ball.cpp
Change from elipse to rectangle
2. Create a square object
& implement necessary methods and fields (similar to Ball)
3. Spawn at least 50 of your objects
4. Clean up and delete objects on the fly
2. D2D – microsoft site
http://i483.photobucket.com/albums/rr193/Brenorenz/W16002_zps0stvvlvx.png
location.x - ½ width
location.y - ½ width
location.x + ½ width
location.y + ½ width
CreateViewBox(25.f, 100.f, 350.f, 400.f);
CreateViewBox(400.f, 100.f, 250.f, 400.f);
Square.h
#pragma once
#ifndef _SQUARE_H
#define _SQUARE_H
#include <d2d1.h>
#include "DrawingObject.h"
#include "GameTime.h"
class Square :
public DrawingObject
{
protected:
D2D1_RECT_F rect;
float size{ 1.f };
float halfSize{ size / 2 };
public:
Square();
~Square();
void setUp(float, ID2D1SolidColorBrush*);
void draw(ID2D1HwndRenderTarget*);
void update(GameTime);
void setLocation(float, float);
float setSize() { return size; }
};
#endif
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) {
//
}
Square::~Square()
{
}
#cplusplus #gamedesign #gameprogramming #programming #tafe
Today – Spawn Object & Remove Object
Balls
BaseApp.h
BaseApp.cpp
it = at(2)
http://i483.photobucket.com/albums/rr193/Brenorenz/W16001_zpsccyurnf9.png
1. if declaring
std::vector<objects> objects
use the clean up
delete __
erase __
Ball.cpp
Change from elipse to rectangle
2. Create a square object
& implement necessary methods and fields (similar to Ball)
3. Spawn at least 50 of your objects
4. Clean up and delete objects on the fly
2. D2D – microsoft site
http://i483.photobucket.com/albums/rr193/Brenorenz/W16002_zps0stvvlvx.png
location.x - ½ width
location.y - ½ width
location.x + ½ width
location.y + ½ width
CreateViewBox(25.f, 100.f, 350.f, 400.f);
CreateViewBox(400.f, 100.f, 250.f, 400.f);
Square.h
#pragma once
#ifndef _SQUARE_H
#define _SQUARE_H
#include <d2d1.h>
#include "DrawingObject.h"
#include "GameTime.h"
class Square :
public DrawingObject
{
protected:
D2D1_RECT_F rect;
float size{ 1.f };
float halfSize{ size / 2 };
public:
Square();
~Square();
void setUp(float, ID2D1SolidColorBrush*);
void draw(ID2D1HwndRenderTarget*);
void update(GameTime);
void setLocation(float, float);
float setSize() { return size; }
};
#endif
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) {
//
}
Square::~Square()
{
}
#cplusplus #gamedesign #gameprogramming #programming #tafe
No comments:
Post a Comment