Skip to content

Commit

Permalink
Update AS config to 2021.3.1.p1 and Fix the Tween error with queue ac…
Browse files Browse the repository at this point in the history
…tions.
  • Loading branch information
scottcgi committed Oct 20, 2022
1 parent 94167a3 commit 8038d3b
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 33 deletions.
7 changes: 7 additions & 0 deletions ChangeLog.md
@@ -1,3 +1,10 @@
## v0.7.1

_`2022.10.20 UTC+8 16:00`_

* Fix the `Tween` error with queue actions.


## v0.7.0

_`2021.8.18 UTC+8 10:42`_
Expand Down
60 changes: 36 additions & 24 deletions Engine/Toolkit/Utils/Tween.c
Expand Up @@ -9,7 +9,7 @@
* CodeStyle: https://github.com/scottcgi/Mojoc/blob/master/Docs/CodeStyle.md
*
* Since : 2016-6-8
* Update : 2021-8-16
* Update : 2022-10-19
* Author : scott.cgi
*/

Expand All @@ -32,6 +32,11 @@ typedef struct
* Target's current running actions.
*/
ArrayList(TweenAction*) current[1];

/**
* A queue action currently is running in current list.
*/
TweenAction* queueAction;
}
Tween;

Expand Down Expand Up @@ -61,6 +66,8 @@ static inline Tween* GetTween()
AArrayList ->Clear(tween->current);
}

tween->queueAction = NULL;

return tween;
}

Expand Down Expand Up @@ -132,20 +139,6 @@ static inline void SetActionValue(TweenAction* action)
}


static void DequeueAction(Tween* tween)
{
// get a queue action to run
TweenAction* action = AArrayQueue_Dequeue(tween->queue, TweenAction*);

if (action != NULL)
{
// add the running queue action into current list
AArrayList_Add(tween->current, action);
SetActionValue(action);
}
}


static void* RunActions(Array(TweenAction*)* actions, void* tweenID)
{
Tween* tween;
Expand Down Expand Up @@ -190,14 +183,17 @@ static void* RunActions(Array(TweenAction*)* actions, void* tweenID)
}
}

DequeueAction(tween);

return tweenID;
}


static void RemoveCurrentActionByIndex(Tween* tween, TweenAction* action, int index)
{
if (action == tween->queueAction)
{
tween->queueAction = NULL;
}

AArrayList->RemoveByLast(tween->current, index);
AArrayList_Add(actionCacheList, action);
}
Expand Down Expand Up @@ -258,6 +254,10 @@ static bool TryRemoveAllActions(void* tweenID)
AArrayList_Add(actionCacheList, action);
}

// if queueAction not NULL it must be in tweenData->current
// so just set NULL
tween->queueAction = NULL;

return true;
}

Expand Down Expand Up @@ -308,6 +308,10 @@ static bool TryCompleteAllActions(void* tweenID, bool isFireOnComplete)
AArrayList_Add(actionCacheList, action);
}

// if queueAction not NULL it must be in tweenData->current
// so just set NULL
tween->queueAction = NULL;

return true;
}

Expand Down Expand Up @@ -340,7 +344,20 @@ static void Update(float deltaSeconds)
for (int i = tweenRunningMap->elementList->size - 1; i > -1; --i)
{
Tween* tween = AArrayIntMap_GetAt(tweenRunningMap, i, Tween*);


// get a queue action to run
if (tween->queueAction == NULL)
{
tween->queueAction = AArrayQueue_Dequeue(tween->queue, TweenAction*);

if (tween->queueAction != NULL)
{
// add the running queue action into current list
AArrayList_Add(tween->current, tween->queueAction);
SetActionValue(tween->queueAction);
}
}

if (tween->current->size == 0)
{
// all actions complete so remove tweenData and push to cache
Expand Down Expand Up @@ -382,13 +399,8 @@ static void Update(float deltaSeconds)
{
action->OnComplete(action);
}

RemoveCurrentActionByIndex(tween, action, j);

if (action->isQueue)
{
DequeueAction(tween);
}
RemoveCurrentActionByIndex(tween, action, j);
}
}
}
Expand Down
7 changes: 2 additions & 5 deletions README.md
@@ -1,7 +1,7 @@
<img src="./Docs/Images/Logo.png" width="176" height="228" alt="Mojoc Logo" title="Mojoc Logo" />


## Mojoc v0.7.0
## Mojoc v0.7.1

Mojoc is an open-source, cross-platform, pure C game engine. It is based on OpenGLES3 and written in C99. It currently works on IOS and Android, but can easily be extended to other platforms, and will support more platforms in the future.

Expand Down Expand Up @@ -39,9 +39,6 @@ Less is more, simple is better, simplify complex ideas.
## Published Games
Mojoc has been used for a cross-platform Android and IOS game.

* **SuperLittleRed** is a bow and arrow shooting game, very challenging for your operation.
* [App Store](https://itunes.apple.com/cn/app/id1242353775)
* [Google Play](https://play.google.com/store/apps/details?id=com.SuperLittleRed)

## Samples
The samples will show all aspects of the Mojoc features. Each platform will provide native building project for native platform editor. For example: Android provides AndroidStudio project, IOS provides XCode project.
Expand All @@ -50,7 +47,7 @@ Currently there is only one sample, which is a simplfied version of the publishe

The compiled and playable apk is here:

* [SuperLittleRed-2.2.0.apk](./Samples/Apk/SuperLittleRed-2.2.0.apk?raw=true)
* [SuperLittleRed-2.2.0.apk](./Samples/Apk/SuperLittleRed-2.2.0.apk?raw=true) is a bow and arrow shooting game, very challenging for your operation.

<img src="./Docs/Images/SuperLittleRed-Sample.gif" width="400" height="225" alt="SuperLittleRed-Sample" title="SuperLittleRed-Sample" />

Expand Down
8 changes: 5 additions & 3 deletions Samples/SuperLittleRed/Android/app/build.gradle
@@ -1,13 +1,14 @@
apply plugin: "com.android.application"

android {
compileSdkVersion 29
buildToolsVersion "30.0.3"
compileSdkVersion 32
buildToolsVersion "33.0.0"
defaultConfig {
applicationId "com.Mojoc.Samples.SuperLittleRed"
minSdkVersion 29
minSdkVersion 30
ndk {
abiFilters "armeabi-v7a", "arm64-v8a"
ndkVersion "25.1.8937393"
}
externalNativeBuild {
cmake {
Expand All @@ -32,6 +33,7 @@ android {
}
productFlavors {
}
namespace 'com.Mojoc.Samples.SuperLittleRed'
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion Samples/SuperLittleRed/Android/build.gradle
Expand Up @@ -6,7 +6,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.0'
classpath 'com.android.tools.build:gradle:7.3.1'
// NOTE: Do not place your application dependencies here; they belong
}

Expand Down

0 comments on commit 8038d3b

Please sign in to comment.