move to AS

This commit is contained in:
shakurov.airat committed 2017-01-10 17:43:06 +05:00
1 parent ec1d8a4332
commit 3f8caf2574
136 files changed
+3861

No files matched your search

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 962 B

After

Width:  |  Height:  |  Size: 962 B

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 759 B

After

Width:  |  Height:  |  Size: 759 B

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 1022 B

After

Width:  |  Height:  |  Size: 1022 B

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 564 B

After

Width:  |  Height:  |  Size: 564 B

Regular → Executable
View File
File mode changed.
Regular → Executable
View File
File mode changed.
Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 102 B

After

Width:  |  Height:  |  Size: 102 B

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File
File mode changed.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File
File mode changed.
Regular → Executable
View File
File mode changed.
Regular → Executable
View File
File mode changed.
Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Regular → Executable
View File
File mode changed.
Regular → Executable
View File
File mode changed.
Regular → Executable
View File
File mode changed.
Regular → Executable
View File
File mode changed.
Regular → Executable
View File
File mode changed.
Regular → Executable
View File
File mode changed.
Regular → Executable
View File
File mode changed.
Regular → Executable
View File
File mode changed.
Regular → Executable
View File
File mode changed.
Regular → Executable
View File
File mode changed.
Regular → Executable
View File
File mode changed.
Regular → Executable
View File
File mode changed.
Regular → Executable
View File
File mode changed.
Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 142 KiB

After

Width:  |  Height:  |  Size: 142 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 125 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 137 KiB

After

Width:  |  Height:  |  Size: 137 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 125 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 140 KiB

After

Width:  |  Height:  |  Size: 140 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 148 KiB

After

Width:  |  Height:  |  Size: 148 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 155 KiB

After

Width:  |  Height:  |  Size: 155 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 147 KiB

After

Width:  |  Height:  |  Size: 147 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 147 KiB

After

Width:  |  Height:  |  Size: 147 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 151 KiB

After

Width:  |  Height:  |  Size: 151 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 150 KiB

After

Width:  |  Height:  |  Size: 150 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 134 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 217 KiB

After

Width:  |  Height:  |  Size: 217 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 177 KiB

After

Width:  |  Height:  |  Size: 177 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Regular → Executable
View File
File mode changed.
Regular → Executable
View File
File mode changed.
Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 480 KiB

After

Width:  |  Height:  |  Size: 480 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 362 KiB

After

Width:  |  Height:  |  Size: 362 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 433 KiB

After

Width:  |  Height:  |  Size: 433 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 370 KiB

After

Width:  |  Height:  |  Size: 370 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 464 KiB

After

Width:  |  Height:  |  Size: 464 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 532 KiB

After

Width:  |  Height:  |  Size: 532 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 611 KiB

After

Width:  |  Height:  |  Size: 611 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 509 KiB

After

Width:  |  Height:  |  Size: 509 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 503 KiB

After

Width:  |  Height:  |  Size: 503 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 553 KiB

After

Width:  |  Height:  |  Size: 553 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 597 KiB

After

Width:  |  Height:  |  Size: 597 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 474 KiB

After

Width:  |  Height:  |  Size: 474 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

+77
View File
@@ -0,0 +1,77 @@
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
LPATH := $(call my-dir)
ENGINE_PATH = $(SalmonEnginePathCygwin)
#BOOST_PATH = $(LibsPathCygwin)/boost_1_47_0
BOOST_PATH = $(LibsPathCygwin)/boost_1_52_0
OGG_PATH = $(LibsPathCygwin)/libogg-1.3.0
VORBIS_PATH = $(LibsPathCygwin)/libvorbis-1.3.2
SQUIRREL_PATH = $(LibsPathCygwin)/sqplus
LIBPNG_PATH = $(LibsPathCygwin)/libpng_1.4.1_android
ZIP_PATH = $(LibsPathCygwin)/julienr-libzip-android/jni
#====== ENGINE AND LIBS =====================
include $(ENGINE_PATH)/Android_Salmon_Engine.mk
#================= THE GAME =======================
LOCAL_PATH:= $(LPATH)
include $(CLEAR_VARS)
LOCAL_CFLAGS := -DTARGET_ANDROID -std=gnu++11 --std=c++11
LOCAL_STATIC_LIBRARIES := boost
LOCAL_STATIC_LIBRARIES += squirrel
LOCAL_STATIC_LIBRARIES += png_lib
LOCAL_STATIC_LIBRARIES += zip
LOCAL_SHARED_LIBRARIES := SalmonEngine
LOCAL_SHARED_LIBRARIES += gnustl_shared
LOCAL_C_INCLUDES := $(ENGINE_PATH)
LOCAL_C_INCLUDES += $(BOOST_PATH)
LOCAL_C_INCLUDES += $(VORBIS_PATH)/include
LOCAL_C_INCLUDES += $(VORBIS_PATH)/include/vorbis
LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib
LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib/books
LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib/modes
LOCAL_C_INCLUDES += $(OGG_PATH)/include
LOCAL_C_INCLUDES += $(OGG_PATH)/include/ogg
LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/include
LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/sqplus
LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/squirrel
LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/sqstdlib
LOCAL_C_INCLUDES += $(LIBPNG_PATH)
LOCAL_C_INCLUDES += $(ZIP_PATH)
LOCAL_MODULE := gl2jni
LOCAL_SRC_FILES := main_code.cpp
LOCAL_SRC_FILES += android_api.cpp
LOCAL_SRC_FILES += menucode.cpp
LOCAL_SRC_FILES += gamecode.cpp
LOCAL_SRC_FILES += loadingcode.cpp
LOCAL_SRC_FILES += creditscode.cpp
LOCAL_LDLIBS := -lGLESv2
LOCAL_LDLIBS += -llog -Wl,-s
include $(BUILD_SHARED_LIBRARY)
+3
View File
@@ -0,0 +1,3 @@
APP_STL := gnustl_static
APP_CPPFLAGS += -fexceptions
APP_CPPFLAGS += -frtti
+179
View File
@@ -0,0 +1,179 @@
[Project]
FileName=DoubleHitBalls.dev
Name=DoubleHitBalls
UnitCount=13
Type=1
Ver=1
ObjFiles=
Includes=C:\Workplace\Projects\Engine;C:\Workplace\android-ndk-r6b\platforms\android-8\arch-arm\usr\include;C:\Workplace\libs\boost_1_47_0;C:\Workplace\libs\openal;C:\Workplace\libs\libvorbis-1.3.2\include;C:\Workplace\libs\libogg-1.3.0\include
Libs=
PrivateResource=
ResourceIncludes=
MakeIncludes=
Compiler=-DTARGET_ANDROID_@@_
CppCompiler=-DTARGET_ANDROID_@@_
Linker=
IsCpp=1
Icon=
ExeOutput=
ObjectOutput=
OverrideOutput=0
OverrideOutputName=DoubleHitBalls.exe
HostApplication=
Folders=
CommandLine=
UseCustomMakefile=0
CustomMakefile=
IncludeVersionInfo=0
SupportXPThemes=0
CompilerSet=0
CompilerSettings=0000000000000000000000
[Unit1]
FileName=main_code.cpp
CompileCpp=1
Folder=DoubleHitBalls
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit2]
FileName=main_code.h
CompileCpp=1
Folder=DoubleHitBalls
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit3]
FileName=menucode.cpp
CompileCpp=1
Folder=DoubleHitBalls
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit4]
FileName=menucode.h
CompileCpp=1
Folder=DoubleHitBalls
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[VersionInfo]
Major=0
Minor=1
Release=1
Build=1
LanguageID=1033
CharsetID=1252
CompanyName=
FileVersion=
FileDescription=Developed using the Dev-C++ IDE
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=
AutoIncBuildNr=0
[Unit5]
FileName=gamecode.h
CompileCpp=1
Folder=DoubleHitBalls
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit6]
FileName=gamecode.cpp
CompileCpp=1
Folder=DoubleHitBalls
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit7]
FileName=game_area_interface.h
CompileCpp=1
Folder=DoubleHitBalls
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit8]
FileName=creditscode.cpp
CompileCpp=1
Folder=DoubleHitBalls
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit9]
FileName=creditscode.h
CompileCpp=1
Folder=DoubleHitBalls
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit10]
FileName=loadingcode.cpp
CompileCpp=1
Folder=DoubleHitBalls
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit11]
FileName=loadingcode.h
CompileCpp=1
Folder=DoubleHitBalls
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit12]
FileName=android_api.cpp
CompileCpp=1
Folder=DoubleHitBalls
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit13]
FileName=android_api.h
CompileCpp=1
Folder=DoubleHitBalls
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
+10
View File
@@ -0,0 +1,10 @@
#include "android_api.h"
#include "main_code.h"
JNIEXPORT void JNICALL Java_fishrungames_doublehitballs_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height)
{
JniInitApp<TAndroidApplication>(width, height, 480.f, 320.f);
}
+25
View File
@@ -0,0 +1,25 @@
#ifndef ANDROID_API_H_INCLUDED
#define ANDROID_API_H_INCLUDED
#include <jni.h>
#include <android/log.h>
#include <GLES/gl.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include "boost/shared_ptr.hpp"
#include "main_code.h"
#include "include/Engine.h"
using namespace SE;
extern "C"
{
JNIEXPORT void JNICALL Java_fishrungames_doublehitballs_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height);
};
#endif
+79
View File
@@ -0,0 +1,79 @@
#include "creditscode.h"
#include "include/Engine.h"
#include "main_code.h"
const int TGameCredits::CONST_STATE_APPEARING = 0;
const int TGameCredits::CONST_STATE_APPEARED = 1;
const int TGameCredits::CONST_STATE_DISAPPEARING = 2;
const int TGameCredits::CONST_STATE_DISAPPEARED = 3;
const float TGameCredits::CONST_APPEAR_TIME = 150.f;
TGameCredits::TGameCredits()
: TGameAreaAncestor()
, StateTimer(0)
, State(CONST_STATE_DISAPPEARED)
{
}
void TGameCredits::Draw()
{
float transparency = StateTimer/CONST_APPEAR_TIME;
RenderUniform1f("Transparency", transparency);
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList["main_menu_bkg_left"]);
Renderer->DrawRect(vec2(0, 0.f), vec2(480.f, 320.f));
const vec2 creditsPos(140.f, 130.f);
const vec2 creditsHalfSize(128.f, 128.f);
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[CONST_CREDITS_TEXTURE]);
Renderer->DrawRect(creditsPos-creditsHalfSize, creditsPos+creditsHalfSize);
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[CONST_LOGO_SMALL_TEXTURE]);
Renderer->DrawRect(vec2(240.f-128.f+15.f, 320.f-64.f), vec2(240.f+128.f+15.f, 320.f));
CheckGlError("Draw TGameCredits");
}
void TGameCredits::Update(cardinal dt)
{
if (State == CONST_STATE_APPEARING)
{
StateTimer += dt;
if (StateTimer >= CONST_APPEAR_TIME)
{
StateTimer = CONST_APPEAR_TIME;
State = CONST_STATE_APPEARED;
}
}
else if (State == CONST_STATE_DISAPPEARING)
{
StateTimer -= dt;
if (StateTimer <= 0.f)
{
StateTimer = 0.f;
State = CONST_STATE_DISAPPEARED;
}
}
}
void TGameCredits::OnTapDown(vec2 p)
{
Application->GoFromCreditsToMenu();
}
void TGameCredits::StartAppear()
{
State = CONST_STATE_APPEARING;
}
void TGameCredits::StartDisappear()
{
State = CONST_STATE_DISAPPEARING;
}
+34
View File
@@ -0,0 +1,34 @@
#ifndef CREDITSCODE_H_INCLUDED
#define CREDITSCODE_H_INCLUDED
#include "game_area_interface.h"
using namespace SE;
class TGameCredits : public TGameAreaAncestor
{
static const int CONST_STATE_APPEARING;
static const int CONST_STATE_APPEARED;
static const int CONST_STATE_DISAPPEARING;
static const int CONST_STATE_DISAPPEARED;
static const float CONST_APPEAR_TIME;
int State;
float StateTimer;
public:
TGameCredits();
virtual void Draw();
virtual void Update(cardinal dt);
virtual void OnTapDown(vec2 p);
void StartAppear();
void StartDisappear();
};
#endif
+23
View File
@@ -0,0 +1,23 @@
#ifndef GAME_AREA_INTERFACE_H_INCLUDED
#define GAME_AREA_INTERFACE_H_INCLUDED
#include "include/Engine.h"
using namespace SE;
class TGameAreaAncestor
{
public:
virtual void Draw() { }
virtual void Update(cardinal) { }
virtual void OnTapUp(vec2) { }
virtual void OnTapDown(vec2) { }
virtual void OnFling(vec2) { }
virtual void OnScroll(vec2) { }
virtual ~TGameAreaAncestor() { } //By default destructor is not virtual
};
#endif
+1560
View File
File diff suppressed because it is too large. Load diff
+205
View File
@@ -0,0 +1,205 @@
#ifndef GAMECODE_H_INCLUDED
#define GAMECODE_H_INCLUDED
#include "include/Engine.h"
#include "game_area_interface.h"
#include <list>
using namespace SE;
const int CONST_BRICKSTATE_VISIBLE = 3;
const int CONST_BRICKSTATE_DISAPPEAR = 2;
const int CONST_BRICKSTATE_INVISIBLE = 1;
const int CONST_BRICKSTATE_APPEAR = 0;
const float CONST_BRICK_DISAPPEAR_TIME = 200.f;
const float CONST_BRICK_APPEAR_TIME = 200.f;
const int CONST_BRICKMATRIX_WIDTH = 12;
const int CONST_BRICKMATRIX_HEIGHT = 13;
const float CONST_BRICK_WIDTH = 37.5f;
const float CONST_BRICK_HEIGHT = 0.5f*CONST_BRICK_WIDTH;
const float CONST_BRICK_SHIFT_X = 15.f;
const float CONST_BRICK_SHIFT_Y = -16.f;
const float CONST_BONUS_APPEAR_TIME = 400.f;
const float CONST_BONUS_FALL_SPEED = 100.f;
const float CONST_BONUS_GOTHROUGH_TIME = 8000.f;
const float CONST_BONUS_CATCH_DISTANCE_X = 65.f;
const float CONST_BONUS_CATCH_DISTANCE_Y = 20.f;
const float CONST_BONUS_FLOOR_TIME = 8000.f;
const float CONST_BONUS_FLOOR_APPEAR_SPEED = 50.f;
const int CONST_BONUS_TYPE_MULTIPLIER = 0;
const int CONST_BONUS_TYPE_GOTHROUGH = 1;
const int CONST_BONUS_TYPE_FLOOR = 2;
class TBrick
{
protected:
int InitialLocked;
int Locked; //0, 1 or 2
int State;
float StateTimer;
vec4 Color;
public:
TBrick();
void SetVisible(vec4 color, int locked);
void SetInvisible();
void TryDrawAppear(int ipos, int jpos);
void Update(cardinal dt);
vec2 GetPosFrom(int ipos, int jpos);
vec4 GetColor();
void Appear(vec4 color, int locked);
void Appear();
void Hit();
void Disappear();
int GetLocked();
bool CanReact();
};
class TBonusFalling
{
protected:
float Lifetime;
vec2 Pos;
std::string TexName;
int BonusType; //0 - multiplier, 1 - Go-through, 2 - floor
public:
TBonusFalling(vec2 pos);
vec2 GetPos();
int GetType();
void Draw();
void Update(cardinal dt);
};
struct TBall
{
vec2 Pos;
vec2 Velocity;
vec4 Color;
std::list<vec2> TalePos;
vec2 BallInBlock;
vec2 PrevBallInBlock;
TBall(vec2 pos, vec2 velocity, vec4 color);
vec2 GetPos();
vec2 GetVelocityVector();
void Go();
void ReflectToLeft();
void ReflectToRight();
void ReflectToUp();
void ReflectToDown();
void TryReflectOnReflector(vec2 refPos);
void Update(cardinal dt);
};
typedef std::pair<vec4, std::string> PairColorTexture;
struct TBlockInstansingList
{
//color-texture ---> and list of triangles for this color
std::list<std::pair<PairColorTexture, TTriangleList>> ColorBlockList;
};
struct TBallInstancingList
{
std::map<int, TTriangleList> BallAndGlowList;
};
class TGameLevel : public TGameAreaAncestor
{
protected:
std::string BkgTexture;
std::string LevelScreenTexture;
std::string LevelFileName;
vec2 ReflectorPos;
int LevelState;
bool PrevLevelStateIsStandby;
float StateTimer;
TBrick BlockMatrix[CONST_BRICKMATRIX_WIDTH][CONST_BRICKMATRIX_HEIGHT];
TBlockInstansingList BlockInstansingList;
bool TapInBackBtnArea(const vec2& pos);
void ReloadBlockInstansingList();
void SetFinished();
void SetFinishFreeze();
void DrawBuffer();
void DrawPauseButtons();
void DrawBallInstancingList();
bool RenderBufferReady;
float OutScale;
float OutScaleVelocity;
void TryGoToMenu();
std::list<TBonusFalling> BonusFallingList;
std::list<TBall> BallList;
TBallInstancingList BallInstancingList;
vec4 BallColor;
void ReloadBallInstancingList();
void RefreshBallInstancingList();
void UpdateBallList(cardinal dt);
void MultiplyBalls(vec2 pos, vec2 velocity);
vec2 GetBlock(const vec2& pos);
void InitLevel();
float BonusGothroughTimer;
float BonusFloorTimer;
float BonusFloorPosY;
vec4 ParseColor(const std::string& s);
void ReloadLevel();
public:
TGameLevel();
~TGameLevel();
void FillWithFile(const std::string& filename);
void SetStandBy();
void SetLoading(const std::string& bkg, const std::string& levelscreen);
bool IsLoaded();
virtual void Draw();
void SetPause();
bool IsPaused();
void ReleasePause();
virtual void Update(cardinal dt);
virtual void OnTapDown(vec2 pos);
virtual void OnTapUp(vec2 pos);
virtual void OnFling(vec2 slideSpeed);
virtual void OnScroll(vec2 shift);
};
#endif
+16
View File
@@ -0,0 +1,16 @@
#include "loadingcode.h"
#include "include/Engine.h"
#include "main_code.h"
void TGameLoading::Draw()
{
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[CONST_LOADING_TEXTURE]);
Renderer->DrawRect(vec2(240.f - 128.f, 10.f), vec2(240.f + 128.f, 10.f + 64.f));
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[CONST_LOGO_SMALL_TEXTURE]);
Renderer->DrawRect(vec2(480.f - 256.f+50.f, 320.f - 64.f), vec2(480.f+50.f, 320.f));
CheckGlError();
}
+15
View File
@@ -0,0 +1,15 @@
#ifndef LOADINGCODE_H_INCLUDED
#define LOADINGCODE_H_INCLUDED
#include "game_area_interface.h"
using namespace SE;
class TGameLoading : public TGameAreaAncestor
{
public:
virtual void Draw();
};
#endif
+475
View File
@@ -0,0 +1,475 @@
#include "main_code.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include "include/Engine.h"
#include "menucode.h"
#include "main_code.h"
boost::signal<void (vec2)> OnTapUpSignal;
boost::signal<void (vec2)> OnTapDownSignal;
boost::signal<void (vec2)> OnFlingSignal;
boost::signal<void (vec2)> OnScrollSignal;
boost::signal<void ()> OnDrawSignal;
const std::string CONST_BLOCK_TEXTURE1 = "block1";
const std::string CONST_BLOCK_TEXTURE2 = "block2";
const std::string CONST_BLOCK_TEXTURE3 = "block3";
const std::string CONST_BONUS_GOTHROUGH_TEXTURE = "bonus_gothrough";
const std::string CONST_BONUS_MULTIPLIER_TEXTURE = "bonus_multiplier";
const std::string CONST_BONUS_FLOOR_TEXTURE = "bonus_floor";
const std::string CONST_BALL_TEXTURE = "ball";
const std::string CONST_BALLGLOW_TEXTURE = "ball_glow";
const std::string CONST_REFLECTOR_TEXTURE = "reflector";
const std::string CONST_WALL_LEFT_TEXTURE = "wall_left";
const std::string CONST_WALL_RIGHT_TEXTURE = "wall_right";
const std::string CONST_WALL_UP_TEXTURE = "wall_up";
const std::string CONST_WALL_BONUS_TEXTURE = "wall_bonus";
const std::string CONST_BACK_BTN_TEXTURE = "back_btn";
const std::string CONST_SLIDE_UP_BTN_TEXTURE = "slide_up_btn";
const std::string CONST_TAP_TO_CONTINUE_BTN_TEXTURE = "tap_to_continue_btn";
const std::string CONST_LOADING_TEXTURE = "loading";
const std::string CONST_LOGO_SMALL_TEXTURE = "logo_small";
const std::string CONST_CREDITS_TEXTURE = "credits";
const float CONST_CREDITS_SHOW_TIME = 150.f;
TAndroidApplication* Application;
void TAndroidApplication::InnerInit()
{
Application = this;
#ifdef TARGET_WIN32
#ifdef NDEBUG
ST::PathToResources = "resources/";
#else
ST::PathToResources = "../../../assets/";
#endif
#endif
#ifdef TARGET_IOS
ST::PathToResources = "assets/";
#endif
if (Console != NULL)
{
*Console<<"APP INIT\n";
}
srand (static_cast<cardinal>(time(NULL)));
GameState = CONST_GAMESTATE_PRELOADING;
StateTimer = 0.f;
ResourceManager->ShaderManager.AddShader("DefaultShader", "shader1vertex.txt", "shader1fragment.txt");
ResourceManager->ShaderManager.AddShader("FrameShader", "frameshader_vertex.txt", "frameshader_fragment.txt");
ResourceManager->ShaderManager.AddShader("BrickShader", "brickshader_vertex.txt", "brickshader_fragment.txt");
Renderer->PushShader("DefaultShader");
ResourceManager->TexList.AddTexture(CONST_LOADING_TEXTURE + ".png", CONST_LOADING_TEXTURE);
ResourceManager->TexList.AddTexture(CONST_LOGO_SMALL_TEXTURE + ".png", CONST_LOGO_SMALL_TEXTURE);
ResourceManager->TexList.AddTexture("console_bkg.bmp");
ResourceManager->FrameManager.AddFrameRenderBuffer("LevelBuffer", 512, 512);
OnDrawSignal.connect(boost::bind(&TGameLoading::Draw, boost::ref(GameLoading)));
Inited = true;
Renderer->SetOrthoProjection();
Renderer->SetFullScreenViewport();
}
void TAndroidApplication::InnerDeinit()
{
Inited = false;
Loaded = false;
if (Console != NULL)
{
*Console<<"APP DEINIT\n";
}
OnTapUpSignal.disconnect(boost::bind(&TGameLevel::OnTapUp, boost::ref(GameLevel), _1));
OnTapUpSignal.disconnect(boost::bind(&TGameMenu::OnTapUp, boost::ref(Menu), _1));
OnFlingSignal.disconnect(boost::bind(&TGameLevel::OnFling, boost::ref(GameLevel), _1));
OnFlingSignal.disconnect(boost::bind(&TGameMenu::OnFling, boost::ref(Menu), _1));
OnScrollSignal.disconnect(boost::bind(&TGameLevel::OnScroll, boost::ref(GameLevel), _1));
OnScrollSignal.disconnect(boost::bind(&TGameMenu::OnScroll, boost::ref(Menu), _1));
OnTapDownSignal.disconnect(boost::bind(&TGameLevel::OnTapDown, boost::ref(GameLevel), _1));
OnTapDownSignal.disconnect(boost::bind(&TGameMenu::OnTapDown, boost::ref(Menu), _1));
OnTapDownSignal.disconnect(boost::bind(&TGameCredits::OnTapDown, boost::ref(GameCredits), _1));
OnDrawSignal.disconnect(boost::bind(&TGameLoading::Draw, boost::ref(GameLoading)));
OnDrawSignal.disconnect(boost::bind(&TGameMenu::Draw, boost::ref(Menu)));
OnDrawSignal.disconnect(boost::bind(&TGameLevel::Draw, boost::ref(GameLevel)));
OnDrawSignal.disconnect(boost::bind(&TGameCredits::Draw, boost::ref(GameCredits)));
}
void TAndroidApplication::InnerOnTapDown(vec2 p)
{
OnTapDownSignal(vec2(p.v[0], p.v[1]));
}
void TAndroidApplication::InnerOnTapUp(vec2 p)
{
OnTapUpSignal(vec2(p.v[0], p.v[1]));
}
void TAndroidApplication::InnerOnMove(vec2 shift)
{
OnScrollSignal(shift);
}
void TAndroidApplication::OnFling(vec2 v)
{
}
void TAndroidApplication::ApplySignalsToMenu()
{
OnTapUpSignal.connect(boost::bind(&TGameMenu::OnTapUp, boost::ref(Menu), _1));
OnFlingSignal.connect(boost::bind(&TGameMenu::OnFling, boost::ref(Menu), _1));
OnScrollSignal.connect(boost::bind(&TGameMenu::OnScroll, boost::ref(Menu), _1));
OnTapDownSignal.connect(boost::bind(&TGameMenu::OnTapDown, boost::ref(Menu), _1));
}
void TAndroidApplication::DisapplySignalsToMenu()
{
OnTapUpSignal.disconnect(boost::bind(&TGameMenu::OnTapUp, boost::ref(Menu), _1));
OnFlingSignal.disconnect(boost::bind(&TGameMenu::OnFling, boost::ref(Menu), _1));
OnScrollSignal.disconnect(boost::bind(&TGameMenu::OnScroll, boost::ref(Menu), _1));
OnTapDownSignal.disconnect(boost::bind(&TGameMenu::OnTapDown, boost::ref(Menu), _1));
}
void TAndroidApplication::ApplySignalsToGame()
{
OnTapUpSignal.connect(boost::bind(&TGameLevel::OnTapUp, boost::ref(GameLevel), _1));
OnFlingSignal.connect(boost::bind(&TGameLevel::OnFling, boost::ref(GameLevel), _1));
OnScrollSignal.connect(boost::bind(&TGameLevel::OnScroll, boost::ref(GameLevel), _1));
OnTapDownSignal.connect(boost::bind(&TGameLevel::OnTapDown, boost::ref(GameLevel), _1));
}
void TAndroidApplication::DisapplySignalsToGame()
{
OnTapUpSignal.disconnect(boost::bind(&TGameLevel::OnTapUp, boost::ref(GameLevel), _1));
OnFlingSignal.disconnect(boost::bind(&TGameLevel::OnFling, boost::ref(GameLevel), _1));
OnScrollSignal.disconnect(boost::bind(&TGameLevel::OnScroll, boost::ref(GameLevel), _1));
OnTapDownSignal.disconnect(boost::bind(&TGameLevel::OnTapDown, boost::ref(GameLevel), _1));
}
void TAndroidApplication::ApplySignalsToCredits()
{
OnTapDownSignal.connect(boost::bind(&TGameCredits::OnTapDown, boost::ref(GameCredits), _1));
}
void TAndroidApplication::DisapplySignalsToCredits()
{
OnTapDownSignal.disconnect(boost::bind(&TGameCredits::OnTapDown, boost::ref(GameCredits), _1));
}
void TAndroidApplication::LoadResources()
{
TextureNamesToLoad.clear();
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("main_menu_bkg_left.png", "main_menu_bkg_left"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("main_menu_bkg_right.png", "main_menu_bkg_right"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("select_level.png", "select_level"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("shutterstock1.png", "shutterstock1"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("shutterstock2.png", "shutterstock2"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("shutterstock3.png", "shutterstock3"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("shutterstock4.png", "shutterstock4"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("shutterstock5.png", "shutterstock5"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("shutterstock6.png", "shutterstock6"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("shutterstock7.png", "shutterstock7"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("shutterstock8.png", "shutterstock8"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("shutterstock9.png", "shutterstock9"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("shutterstock10.png", "shutterstock10"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("shutterstock11.png", "shutterstock11"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("shutterstock12.png", "shutterstock12"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("levelshot1.png", "levelshot1"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("levelshot2.png", "levelshot2"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("levelshot3.png", "levelshot3"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("levelshot4.png", "levelshot4"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("levelshot5.png", "levelshot5"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("levelshot6.png", "levelshot6"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("levelshot7.png", "levelshot7"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("levelshot8.png", "levelshot8"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("levelshot9.png", "levelshot9"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("levelshot10.png", "levelshot10"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("levelshot11.png", "levelshot11"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("levelshot12.png", "levelshot12"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("game_end.png", "game_end"));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_BLOCK_TEXTURE1 + ".png", CONST_BLOCK_TEXTURE1));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_BLOCK_TEXTURE2 + ".png", CONST_BLOCK_TEXTURE2));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_BLOCK_TEXTURE3 + ".png", CONST_BLOCK_TEXTURE3));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_BONUS_GOTHROUGH_TEXTURE + ".png", CONST_BONUS_GOTHROUGH_TEXTURE));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_BONUS_MULTIPLIER_TEXTURE + ".png", CONST_BONUS_MULTIPLIER_TEXTURE));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_BONUS_FLOOR_TEXTURE + ".png", CONST_BONUS_FLOOR_TEXTURE));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_BALL_TEXTURE + ".png", CONST_BALL_TEXTURE));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_BALLGLOW_TEXTURE + ".png", CONST_BALLGLOW_TEXTURE));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_WALL_LEFT_TEXTURE + ".png", CONST_WALL_LEFT_TEXTURE));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_WALL_RIGHT_TEXTURE + ".png", CONST_WALL_RIGHT_TEXTURE));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_WALL_UP_TEXTURE + ".png", CONST_WALL_UP_TEXTURE));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_WALL_BONUS_TEXTURE + ".png", CONST_WALL_BONUS_TEXTURE));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_REFLECTOR_TEXTURE + ".png", CONST_REFLECTOR_TEXTURE));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_BACK_BTN_TEXTURE + ".png", CONST_BACK_BTN_TEXTURE));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_SLIDE_UP_BTN_TEXTURE + ".png", CONST_SLIDE_UP_BTN_TEXTURE));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_TAP_TO_CONTINUE_BTN_TEXTURE + ".png", CONST_TAP_TO_CONTINUE_BTN_TEXTURE));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>(CONST_CREDITS_TEXTURE + ".png", CONST_CREDITS_TEXTURE));
#ifdef TARGET_IOS
ResourceManager->SoundManager.LoadMusicLooped("level1ogg.ogg");
#else
ResourceManager->SoundManager.LoadMusic("level1ogg.ogg");
#endif
ResourceManager->FontManager.AddFont("droid_sans14", "droid_sans14_font_bitmap.png", "droid_sans14_font_charmap.txt");
ResourceManager->FontManager.PushFont("droid_sans14");
TryLoadSavedGame();
}
void TAndroidApplication::TryLoadSavedGame()
{
std::string fileName = GetFilePathUserData("progress.txt");
FILE* file = fopen(fileName.c_str(), "r");
if (file != NULL)
{
char line[100];
char* r;
r = fgets(line, 100, file);
if (r != NULL)
{
Menu.SetMenuItemCount(toint(r));
}
fclose(file);
}
}
void TAndroidApplication::TrySaveGame()
{
std::string fileName = GetFilePathUserData("progress.txt");
std::string s = tostr(Menu.GetMenuItemCount());
FILE* file = fopen(fileName.c_str(), "w");
if (file != NULL)
{
fputs(s.c_str(), file);
fflush(file);
fclose(file);
}
}
void TAndroidApplication::InnerDraw()
{
glDisable(GL_DEPTH_TEST);
OnDrawSignal();
}
void TAndroidApplication::InnerUpdate(cardinal dt)
{
if (GameState == CONST_GAMESTATE_PRELOADING)
{
StateTimer += dt/1000.f;
if (StateTimer >= 1.f)
{
LoadResources();
GameState = CONST_GAMESTATE_LOADING;
StateTimer = 0.f;
}
}
else if (GameState == CONST_GAMESTATE_LOADING)
{
StateTimer += dt/1000.f;
if (StateTimer >= 1.f)
{
StateTimer -= 1.f;
}
if (TextureNamesToLoad.size() != 0)
{
ResourceManager->TexList.AddTexture(TextureNamesToLoad.begin()->first, TextureNamesToLoad.begin()->second);
TextureNamesToLoad.erase(TextureNamesToLoad.begin());
}
else
{
GameState = CONST_GAMESTATE_MENU;
ApplySignalsToMenu();
OnDrawSignal.disconnect(boost::bind(&TGameLoading::Draw, boost::ref(GameLoading)));
OnDrawSignal.connect(0, boost::bind(&TGameMenu::Draw, boost::ref(Menu)));
StateTimer = 0.f;
Loaded = true;
}
}
else if (GameState == CONST_GAMESTATE_LEVEL)
{
GameLevel.Update(dt);
}
else if (GameState == CONST_GAMESTATE_MENU)
{
Menu.Update(dt);
}
else if (GameState == CONST_GAMESTATE_FROM_MENU_TO_LEVEL)
{
GameLevel.Update(dt);
if (GameLevel.IsLoaded())
{
GameState = CONST_GAMESTATE_LEVEL;
OnDrawSignal.disconnect(boost::bind(&TGameMenu::Draw, boost::ref(Menu)));
//CONNECT SLOT
DisapplySignalsToMenu();
ApplySignalsToGame();
}
}
else if (GameState == CONST_GAMESTATE_FROM_MENU_TO_CREDITS)
{
Menu.Update(dt);
GameCredits.Update(dt);
StateTimer -= dt;
if (StateTimer <= 0.f)
{
GameState = CONST_GAMESTATE_CREDITS;
OnDrawSignal.disconnect(boost::bind(&TGameMenu::Draw, boost::ref(Menu)));
ApplySignalsToCredits();
StateTimer = 0.f;
}
}
else if (GameState == CONST_GAMESTATE_CREDITS)
{
GameCredits.Update(dt);
}
else if (GameState == CONST_GAMESTATE_FROM_CREDITS_TO_MENU)
{
Menu.Update(dt);
GameCredits.Update(dt);
StateTimer -= dt;
if (StateTimer <= 0.f)
{
GameState = CONST_GAMESTATE_MENU;
StateTimer = 0.f;
ApplySignalsToMenu();
OnDrawSignal.disconnect(boost::bind(&TGameCredits::Draw, boost::ref(GameCredits)));
}
}
}
void TAndroidApplication::GoFromMenuToGame(int level)
{
//#ifndef TARGET_IOS
ResourceManager->SoundManager.PlayMusicLooped("level1ogg.ogg");
//#endif
GameLevel.FillWithFile(ST::PathToResources + "level"+tostr(level+1)+".txt");
GameLevel.SetLoading("shutterstock" + tostr(level+1), "levelshot"+tostr(level+1));
GameState = CONST_GAMESTATE_FROM_MENU_TO_LEVEL;
OnDrawSignal.connect(1, boost::bind(&TGameLevel::Draw, boost::ref(GameLevel)));
DisapplySignalsToMenu();
}
void TAndroidApplication::GoFromGameToMenu()
{
//#ifndef TARGET_IOS
ResourceManager->SoundManager.StopMusic("level1ogg.ogg");
//#endif
TrySaveGame();
DisapplySignalsToGame();
ApplySignalsToMenu();
GameState = CONST_GAMESTATE_MENU;
OnDrawSignal.disconnect(boost::bind(&TGameLevel::Draw, boost::ref(GameLevel)));
}
void TAndroidApplication::GoFromMenuToCredits()
{
GameState = CONST_GAMESTATE_FROM_MENU_TO_CREDITS;
StateTimer = CONST_CREDITS_SHOW_TIME;
GameCredits.StartAppear();
OnDrawSignal.connect(1, boost::bind(&TGameCredits::Draw, boost::ref(GameCredits)));
DisapplySignalsToMenu();
}
void TAndroidApplication::GoFromCreditsToMenu()
{
GameState = CONST_GAMESTATE_FROM_CREDITS_TO_MENU;
StateTimer = CONST_CREDITS_SHOW_TIME;
GameCredits.StartDisappear();
OnDrawSignal.connect(0, boost::bind(&TGameMenu::Draw, boost::ref(Menu)));
DisapplySignalsToCredits();
}
void TAndroidApplication::MarkSetGameLevelPause()
{
OnDrawSignal.connect(0, boost::bind(&TGameMenu::Draw, boost::ref(Menu)));
}
void TAndroidApplication::MarkReleaseGameLevelPause()
{
OnDrawSignal.disconnect(boost::bind(&TGameMenu::Draw, boost::ref(Menu)));
}
void TAndroidApplication::OpenNextLevel()
{
Menu.OpenNextLevel();
}
bool TAndroidApplication::IsLoaded()
{
return Loaded;
}
bool TAndroidApplication::IsInited()
{
return Inited;
}
+153
View File
@@ -0,0 +1,153 @@
#ifndef MAIN_CODE_H_INCLUDED
#define MAIN_CODE_H_INCLUDED
#ifdef TARGET_ANDROID
#include "android_api.h"
#endif
#ifdef TARGET_WIN32
#define NOMINMAX 1
#include <Windows.h>
#undef NOMINMAX
#endif
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "boost/shared_ptr.hpp"
#include "boost/thread/thread.hpp"
#include "boost/assign.hpp"
#include "boost/bind.hpp"
#include "include/Engine.h"
#include "boost/signal.hpp"//Signal must be included after asio
#include "gamecode.h"
#include "menucode.h"
#include "creditscode.h"
#include "loadingcode.h"
using namespace SE;
extern boost::signal<void (vec2)> OnTapUpSignal;
extern boost::signal<void (vec2)> OnTapDownSignal;
extern boost::signal<void (vec2)> OnFlingSignal;
extern boost::signal<void (vec2)> OnScrollSignal;
extern boost::signal<void ()> OnDrawSignal;
extern const std::string CONST_BLOCK_TEXTURE1;
extern const std::string CONST_BLOCK_TEXTURE2;
extern const std::string CONST_BLOCK_TEXTURE3;
extern const std::string CONST_BONUS_GOTHROUGH_TEXTURE;
extern const std::string CONST_BONUS_MULTIPLIER_TEXTURE;
extern const std::string CONST_BONUS_FLOOR_TEXTURE;
extern const std::string CONST_BALL_TEXTURE;
extern const std::string CONST_BALLGLOW_TEXTURE;
extern const std::string CONST_WALL_LEFT_TEXTURE;
extern const std::string CONST_WALL_RIGHT_TEXTURE;
extern const std::string CONST_WALL_UP_TEXTURE;
extern const std::string CONST_WALL_BONUS_TEXTURE;
extern const std::string CONST_REFLECTOR_TEXTURE;
extern const std::string CONST_BACK_BTN_TEXTURE;
extern const std::string CONST_SLIDE_UP_BTN_TEXTURE;
extern const std::string CONST_TAP_TO_CONTINUE_BTN_TEXTURE;
extern const std::string CONST_BACK_BTN_TEXTURE;
extern const std::string CONST_SLIDE_UP_BTN_TEXTURE;
extern const std::string CONST_TAP_TO_CONTINUE_BTN_TEXTURE;
extern const std::string CONST_LOADING_TEXTURE;
extern const std::string CONST_LOGO_SMALL_TEXTURE;
extern const std::string CONST_CREDITS_TEXTURE;
const int CONST_GAMESTATE_LEVEL = 1;
const int CONST_GAMESTATE_MENU = 0;
const int CONST_GAMESTATE_FROM_MENU_TO_LEVEL = 2;
const int CONST_GAMESTATE_FROM_MENU_TO_CREDITS = 3;
const int CONST_GAMESTATE_CREDITS = 4;
const int CONST_GAMESTATE_FROM_CREDITS_TO_MENU = 5;
const int CONST_GAMESTATE_LOADING = 6;
const int CONST_GAMESTATE_PRELOADING = 7;
class TAndroidApplication : public TApplication
{
protected:
TGameMenu Menu;
TGameLevel GameLevel;
TGameCredits GameCredits;
TGameLoading GameLoading;
int GameState;
float StateTimer;
void TryLoadSavedGame();
void TrySaveGame();
bool Inited;
std::vector<std::pair<std::string, std::string> > TextureNamesToLoad;
void ApplySignalsToMenu();
void DisapplySignalsToMenu();
void ApplySignalsToGame();
void DisapplySignalsToGame();
void ApplySignalsToCredits();
void DisapplySignalsToCredits();
public:
bool Loaded;
TAndroidApplication() : TApplication(), Loaded(false), Inited(false) { }
virtual void InnerInit();
virtual void InnerDeinit();
virtual void InnerDraw();
virtual void InnerUpdate(cardinal dt);
void GoFromMenuToGame(int level);
void GoFromGameToMenu();
void GoFromMenuToCredits();
void GoFromCreditsToMenu();
void MarkSetGameLevelPause();
void MarkReleaseGameLevelPause();
void OpenNextLevel();
bool IsLoaded();
bool IsInited();
void LoadResources();
virtual void InnerOnTapDown(vec2 p);
virtual void InnerOnTapUp(vec2 p);
virtual void InnerOnMove(vec2 shift);
virtual void OnFling(vec2 v);
};
extern TAndroidApplication* Application;
#endif
+207
View File
@@ -0,0 +1,207 @@
#include "menucode.h"
#include "main_code.h"
const float CONST_SPEED_NEG_ACCELERATION_K = 0.03f;
const float CONST_MENU_POS_K = 0.25f;
const float CONST_MENU_WINDOW_DISTANCE = 240.f + 40.f;
const float CONST_SHIFT_ON_SIDE = 0.f;
TGameMenu::TGameMenu()
: MenuSpeed(0)
, MenuPos(0)
, HoldToTap(false)
, MenuItemCount(1)
, SelectedGame(-1)
{
}
void TGameMenu::Draw()
{
CheckGlError("Draw TGameMenu");
RenderUniform1i("sel", 0);
RenderUniform1f("Transparency", 1.f);
float bkgShift = MenuPos*0.1f - 100.f;
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["main_menu_bkg_left"]);
Renderer->DrawRect(vec2(bkgShift,0.f), vec2(480.f+bkgShift,320.f));
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["main_menu_bkg_right"]);
Renderer->DrawRect(vec2(480.f+bkgShift,0.f), vec2(960.f+bkgShift,320.f));
if (SelectedGame == 0)
{
RenderUniform1i("sel", 1);
}
else
{
RenderUniform1i("sel", 0);
}
for (int i=0; i<MenuItemCount; i++)
{
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["levelshot"+tostr(i+1)]);
Renderer->DrawRect(vec2(160.f+MenuPos+CONST_MENU_WINDOW_DISTANCE*i,80.f), vec2(160.f+240.f+MenuPos+CONST_MENU_WINDOW_DISTANCE*i, 240.f));
}
if (MenuItemCount == 12)
{
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["game_end"]);
Renderer->DrawRect(vec2(160.f+MenuPos+CONST_MENU_WINDOW_DISTANCE*12,160.f - 64.f), vec2(160.f+256.f+MenuPos+CONST_MENU_WINDOW_DISTANCE*12, 160.f + 64.f));
}
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["select_level"]);
Renderer->DrawRect(vec2(240.f-128.f, 241.f), vec2(240.f+128.f, 305.f));
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["logo_small"]);
Renderer->DrawRect(vec2(240.f-128.f+15.f, 0.f), vec2(240.f+128.f+15.f, 64.f));
CheckGlError("Draw TGameMenu 2");
}
void TGameMenu::Update(cardinal dt)
{
if (HoldToTap)
return;
float k;
MenuPos = MenuPos + MenuSpeed*dt/1000.f;
int menuItemToShowCount;
if (MenuItemCount == 12)
{
menuItemToShowCount = 13;
}
else
{
menuItemToShowCount = MenuItemCount;
}
float acc;
if (MenuItemCount == 1)
{
k = 3;
}
else
{
k = fabs( - MenuPos - ((menuItemToShowCount-1)*CONST_MENU_WINDOW_DISTANCE*0.5f)) / ((MenuItemCount-1)*CONST_MENU_WINDOW_DISTANCE*0.5f);
}
acc = -MenuSpeed * CONST_SPEED_NEG_ACCELERATION_K * k;
float xleft = (- MenuPos + CONST_SHIFT_ON_SIDE - (menuItemToShowCount-1)*CONST_MENU_WINDOW_DISTANCE);
if (xleft < 0)
{
xleft = 0;
}
acc += xleft*CONST_MENU_POS_K;
float xright = (MenuPos - CONST_SHIFT_ON_SIDE);
if (xright < 0)
{
xright = 0;
}
acc -= xright*CONST_MENU_POS_K;
if ((MenuSpeed + acc*dt) * MenuSpeed < 0) //Check if MenuSpeed changes direction
{
MenuSpeed = 0;
}
else
{
MenuSpeed += acc*dt;
}
}
void TGameMenu::OnTapDown(vec2 pos)
{
if (pos.v[1]<64.f && pos.v[0]>=265.f-128.f && pos.v[0]<=265.f+128.f)
{
Application->GoFromMenuToCredits();
return;
}
vec2 realPos = pos - vec2(MenuPos, 0);
if (realPos.v[1] >= 80.f && realPos.v[1] <= 240.f)
{
float x = realPos.v[0] - 160.f;
int p = 0;
while (x >280.f)
{
x -= 280.f;
p++;
}
if (x <= 240.f && x >= 0.f && (p<MenuItemCount))
{
SelectedGame = p;
return;
}
}
SelectedGame = -1;
}
void TGameMenu::OnTapUp(vec2 pos)
{
HoldToTap = false;
if (SelectedGame != -1)
{
MenuPos = -CONST_MENU_WINDOW_DISTANCE*SelectedGame-40.f;
Application->GoFromMenuToGame(SelectedGame);
SelectedGame = -1;
}
}
void TGameMenu::OnFling(vec2 slideSpeed)
{
HoldToTap = false;
MenuSpeed = slideSpeed.v[0];
}
void TGameMenu::OnScroll(vec2 shift)
{
MenuPos = MenuPos - shift.v[0];
}
void TGameMenu::OpenNextLevel()
{
if (MenuItemCount < 12)
{
MenuItemCount++;
}
}
int TGameMenu::GetMenuItemCount()
{
return MenuItemCount;
}
void TGameMenu::SetMenuItemCount(int menuItemCount)
{
MenuItemCount = menuItemCount;
}
+40
View File
@@ -0,0 +1,40 @@
#ifndef MENUCODE_H_INCLUDED
#define MENUCODE_H_INCLUDED
#include "include/Engine.h"
#include "game_area_interface.h"
using namespace SE;
class TGameMenu : public TGameAreaAncestor
{
protected:
float MenuSpeed;
float MenuPos;
bool HoldToTap;
int MenuItemCount;
int SelectedGame;
public:
TGameMenu();
virtual void Draw();
virtual void Update(cardinal dt);
virtual void OnTapDown(vec2 pos);
virtual void OnTapUp(vec2 pos);
virtual void OnFling(vec2 slideSpeed);
virtual void OnScroll(vec2 shift);
void OpenNextLevel();
int GetMenuItemCount();
void SetMenuItemCount(int menuItemCount);
};
#endif
Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

Regular → Executable
View File
File mode changed.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

View File
File mode changed.
Regular → Executable
View File
File mode changed.
Regular → Executable
View File
File mode changed.
View File
File mode changed.
View File
File mode changed.
View File
File mode changed.
View File
File mode changed.
View File
File mode changed.
View File
File mode changed.
View File
File mode changed.
View File
File mode changed.
View File
File mode changed.
Regular → Executable
View File
File mode changed.
Loaded 100 of 136 files, more files were not shown because too many files have changed in this diff. Show more