Skip to content
This repository has been archived by the owner on Feb 16, 2022. It is now read-only.

Commit

Permalink
Alpha presentation (#26)
Browse files Browse the repository at this point in the history
* Add back button in game scene

* Fix a few errors

* Include Lindsey's new backgrounds

* Fixing level select issue

* Reverse unnecessary changes in alpha-presentation
  • Loading branch information
foxhatleo authored Apr 10, 2021
1 parent d745d28 commit 7f11c63
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 7 deletions.
6 changes: 6 additions & 0 deletions assets/config/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@
},
"menubutton": {
"file": "textures/menubutton.png"
},
"bg-level1": {
"file": "textures/level-backgrounds/level1.png"
},
"bg-level2": {
"file": "textures/level-backgrounds/level2.png"
}
},
"jsons": {
Expand Down
1 change: 1 addition & 0 deletions assets/levels/level1.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"background": "bg-level1",
"colors": [
[244, 78, 59],
[251, 158, 0],
Expand Down
1 change: 1 addition & 0 deletions assets/levels/level2.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"background": "bg-level2",
"colors": [
[244, 78, 59],
[251, 158, 0],
Expand Down
1 change: 1 addition & 0 deletions assets/levels/level3.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"background": "bg-level1",
"colors": [
[244, 78, 59],
[251, 158, 0],
Expand Down
Binary file added assets/textures/level-backgrounds/level1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/textures/level-backgrounds/level2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion build-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {

}
dependencies {
classpath "com.android.tools.build:gradle:4.1.2"
classpath 'com.android.tools.build:gradle:4.1.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
Binary file added build-android/keystore.jks
Binary file not shown.
4 changes: 3 additions & 1 deletion cugl/lib/render/shaders/SpriteShader.frag
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ float edgeThreshold = 100.0;
float splatFalloffSize = .8;
float splatCutoffSize = .2;
vec4 defaultColor = vec4(0,0,0,0);
vec2 iResolution = uViewport;
vec2 iResolution;



Expand Down Expand Up @@ -343,6 +343,8 @@ void main(void) {


//Ben's code here to end:
iResolution = uViewport;

// uv are screen coordinates, uniformly scaled to go from 0..1 vertically
vec2 uv = outPosition.xy / iResolution.yy;

Expand Down
4 changes: 4 additions & 0 deletions source/PPApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ void PanicPainterApp::update(float timestep) {
if (_gameplay.getPauseRequest()) {
// TODO: Change this to pause screen when it's done.
_currentScene = LEVEL_SCENE;
_level.resetState();
}
else if (_gameplay.isComplete()) {
_currentScene = LEVEL_SCENE;
_level.resetState();
}
break;
}
Expand All @@ -104,6 +106,7 @@ void PanicPainterApp::update(float timestep) {
//_menu.dispose();
_currentScene = LEVEL_SCENE;
_menu.resetState();
_level.resetState();
}
break;
}
Expand All @@ -113,6 +116,7 @@ void PanicPainterApp::update(float timestep) {
//_menu.init(_assets);
_currentScene = MENU_SCENE;
_level.resetState();
_menu.resetState();
}
else if (_level.getState() == SELECTED) {
//_level.dispose();
Expand Down
37 changes: 32 additions & 5 deletions source/scenes/gameplay/PPGameScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ void GameScene::loadLevel(const char *levelName) {
_palette.reset();
_action.reset();

_complete = nullptr;

// Find Level file.
const json_t levelJson = _assets->get<JsonValue>(levelName);

Expand All @@ -36,15 +38,15 @@ void GameScene::loadLevel(const char *levelName) {
Rect safeArea = Application::get()->getSafeBounds();

auto background = PolygonNode::allocWithTexture(_assets->get<Texture>
("background"));
(levelJson->has("background") ? levelJson->getString("background") : "background"));
background->setContentSize(Application::get()->getDisplaySize());
addChild(background);
// Clear canvases.
_canvases.clear();
for (uint i = 0, j = _state.numQueues(); i < j; i++) {
vec<ptr<Canvas>> queue;
for (int i2 = (int) (_state.numCanvases(i)) - 1; i2 >= 0; i2--) {
auto bound = Application::get()->getSafeBounds();
auto bound = safeArea;
bound.origin.x += PALETTE_WIDTH * bound.size.width;
bound.size.width *= (1 - PALETTE_WIDTH);
bound.size.height *= (1 - TIMER_HEIGHT);
Expand All @@ -62,9 +64,33 @@ void GameScene::loadLevel(const char *levelName) {
_canvases.push_back(queue);
}

auto gtBound = Application::get()->getSafeBounds();
_backBtn = PolygonNode::allocWithTexture
(_assets->get<Texture>("backbutton"));
_backBtn->setScale(1.9f *
(safeArea.size.height * TIMER_HEIGHT) / _backBtn->getContentWidth());
_backBtn->setAnchor(Vec2::ANCHOR_TOP_RIGHT);
_backBtn->setPosition(safeArea.size.width, safeArea.size.height);
// We manually define interactive area because there is that trail of paint
// in the button texture that shouldn't be interactive.
_backBtnArea = _backBtn->getBoundingBox();
_backBtnArea.translate(
0,
_backBtnArea.size.height - _backBtnArea.size.height * 0.75f);
_backBtnArea.scale(1, 0.75f);
#ifdef VIEW_DEBUG
// This draws the back button area above.
auto n = PolygonNode::alloc(_backBtnArea);
n->setAnchor(Vec2::ANCHOR_BOTTOM_LEFT);
n->setPosition(_backBtnArea.origin);
n->setContentSize(_backBtnArea.size);
addChild(n);
#endif

auto gtBound = safeArea;
gtBound.origin.y += (1 - TIMER_HEIGHT) * gtBound.size.height;
gtBound.size.height *= TIMER_HEIGHT;
gtBound.size.width -=
gtBound.getMaxX() - _backBtn->getBoundingBox().getMinX();
_globalTimer = GlobalTimer::alloc(_assets, gtBound);

// change position to keep it to the left of the screen.
Expand All @@ -87,6 +113,8 @@ void GameScene::loadLevel(const char *levelName) {

_action = make_shared<ActionController>(_state, _canvases);

addChild(_backBtn);

}

void GameScene::update(float timestep) {
Expand All @@ -100,8 +128,7 @@ void GameScene::update(float timestep) {

auto &input = InputController::getInstance();
if (input.justReleased() && input.isJustTap() &&
Rect(0, this->getSize().height - 120, 120, 120)
.contains(input.currentPoint())) {
InputController::inScene(input.currentPoint(), _backBtnArea)) {
_pauseRequest = true;
}

Expand Down
3 changes: 3 additions & 0 deletions source/scenes/gameplay/PPGameScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class GameScene final : public Scene2 {

ptr<ActionController> _action;

ptr<PolygonNode> _backBtn;
Rect _backBtnArea;

// Boolean indicating level is complete
ptr<Timer> _complete;

Expand Down

0 comments on commit 7f11c63

Please sign in to comment.