Include a launch.json and tasks.json example files

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 4e7e6be7a8
commit 8651ee65cf
  1. BIN
      C++ProjectTemplate
  2. BIN
      a.out
  3. BIN
      dirtblock.png
  4. BIN
      grass.png
  5. 69
      main.cpp
  6. 6191
      olcPixelGameEngine.h

Binary file not shown.

BIN
a.out

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 541 B

@ -1,94 +1,35 @@
//--------------------------------------------------------------------------------------------------
// Collect the Balls Game
//--------------------------------------------------------------------------------------------------
// Purpose of the game is to figure out how to program.
// The goal of the game, is to simply to collect balls until a score or time limit has been reached.
//--------------------------------------------------------------------------------------------------
// created by Rune; with massive help from sigonasr2 on Javidx9's One Lone Coder Discord server
//--------------------------------------------------------------------------------------------------
#define OLC_PGE_APPLICATION
#include <iostream>
#include "pixelGameEngine.h" // use this for drawing stuff to screen
using namespace olc;
//--------------------------------------------------------------------------------------------------
// class
//--------------------------------------------------------------------------------------------------
class BallGame : public olc::PixelGameEngine
{
public:
BallGame()
{
sAppName = "Rectangle Collision";
sAppName = "Example";
}
public:
struct Rectangle{
vd2d pos;
vd2d size;
};
vd2d pos = {0,0};
Rectangle r1 = {{64,64},{16,16}};
Rectangle r3 = {{128,64},{16,16}};
Rectangle r2 = {pos,{8,8}};
//--------------------------------------------------------------------------------------------------
// Create stuff for game
//--------------------------------------------------------------------------------------------------
bool OnUserCreate() override
{
return true;
}
//--------------------------------------------------------------------------------------------------
// main game function
//--------------------------------------------------------------------------------------------------
bool OnUserUpdate(float fElapsedTime) override
{
Clear(VERY_DARK_CYAN);
if (GetKey(A).bHeld) {
r2.pos.x-=20*fElapsedTime;
}
if (GetKey(D).bHeld) {
r2.pos.x+=20*fElapsedTime;
}
if (GetKey(W).bHeld) {
r2.pos.y-=20*fElapsedTime;
}
if (GetKey(S).bHeld) {
r2.pos.y+=20*fElapsedTime;
}
if (Collision(r1,r2)) {
FillRect(r1.pos,r1.size,YELLOW);
} else {
FillRect(r1.pos,r1.size,RED);
for (int i=0;i<ScreenWidth();i++) {
for (int j=0;j<ScreenHeight();j++) {
Draw({i,j},Pixel(rand()%255,rand()%255,rand()%255));
}
}
if (Collision(r3,r2)) {
FillRect(r3.pos,r1.size,YELLOW);
} else {
FillRect(r3.pos,r1.size,GREEN);
}
FillRect(r2.pos,r2.size,BLUE);
return true;
}
bool Collision(Rectangle r1,Rectangle r2) {
return abs(r1.pos.x-r2.pos.x)<r1.size.x&&abs(r1.pos.y-r2.pos.y)<r1.size.y;
}
bool Collision2(Rectangle r1,Rectangle r2) {
return abs(r1.pos.x-r2.pos.x)<r1.size.x&&abs(r1.pos.y-r2.pos.y)<r1.size.y;
}
};
//--------------------------------------------------------------------------------------------------
int main()
{
BallGame game;

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save