Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
66dd5cf
Update README.md
ofenbach Apr 25, 2018
5743366
Delete .gitignore
ofenbach Apr 25, 2018
c8e5d28
Update README.md
ofenbach Apr 25, 2018
7bb2854
Update README.md
ofenbach Apr 25, 2018
07d01c9
Update README.md
ofenbach Apr 25, 2018
2c97cca
Add files via upload
ofenbach Apr 25, 2018
b2c770f
Create concepts.txt
ofenbach Apr 25, 2018
feed996
new update
ofenbach Apr 28, 2018
f454c8b
Create README.md
ofenbach Apr 28, 2018
918f024
Update README.md
ofenbach Apr 28, 2018
673de13
added #planned features
ofenbach Apr 28, 2018
c4eff12
added #planned features
ofenbach Apr 28, 2018
09ea158
added #todo
ofenbach May 2, 2018
691b26f
improved text
ofenbach May 2, 2018
8d035d7
Update README.md
ofenbach May 2, 2018
5765112
Update README.md
ofenbach May 2, 2018
d13f0ea
Create README.md
ofenbach May 2, 2018
8f0635f
Update README.md
ofenbach May 2, 2018
ef16007
Update Image.java
ofenbach May 7, 2018
99e2fa3
Update Sound.java
ofenbach May 7, 2018
fd137b8
Update Music.java
ofenbach May 7, 2018
cfe40b3
Update Sprite.java
ofenbach May 7, 2018
c12dcf0
Update Camera.java
ofenbach May 7, 2018
2fc7236
Update MainView.java
ofenbach May 7, 2018
bef8c37
Update Screen.java
ofenbach May 7, 2018
d6f0f31
Update Settings.java
ofenbach May 7, 2018
12d4da0
Update Device.java
ofenbach May 7, 2018
0ca9f5e
Update MainActivity.java
ofenbach May 7, 2018
5da2763
Update TouchEvent.java
ofenbach May 7, 2018
54e87a6
Update README.md
ofenbach May 7, 2018
3676594
Update README.md
ofenbach May 7, 2018
0ddbac7
Update README.md
ofenbach May 7, 2018
d61b2b7
Update Image.java
ofenbach May 8, 2018
cfb3829
Update README.md
ofenbach May 8, 2018
393e728
Update ExampleScreen.java
ofenbach May 8, 2018
bacd3ad
Update README.md
ofenbach May 8, 2018
3cc1b32
Update Camera.java
ofenbach May 14, 2018
d51d400
added License
ofenbach May 14, 2018
2dad845
added codestyle explanation
ofenbach May 14, 2018
73b75c7
added new feature
ofenbach May 14, 2018
29157b4
added installation guide
ofenbach May 14, 2018
aa2ca80
improved codestyle
ofenbach May 14, 2018
8f900d6
removed #enums
ofenbach May 16, 2018
a2a38b1
removed #proversion
ofenbach May 16, 2018
a8d3d0f
improved details
ofenbach May 19, 2018
9e6a71f
better format
ofenbach Jul 20, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 0 additions & 55 deletions .gitignore

This file was deleted.

62 changes: 62 additions & 0 deletions CODESTYLE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Code Style

## Naming conventions

* File names: PascalCase
* Folder names: PascalCase
* Class names: PascalCase
* Functions: camelCase
* Local variables: underscore_case
* Constants: SCREAMING_SNAKE_CASE

## Class Style

```Java
class Image {

// Class vars
int example_int, example_int2;
boolean example_bool;

public Image() {}

/* DRAW */
public void draw() {}

/* SCALING */
public void scale() {}
public void scale(double factor) {}

/* EXAMPLE GROUP */
public void exampleFunc() {}
public void exampleFunc2() {

// Calculate something
calculate();
calculateAgain();

// next group
doSomething();
again();

}

...

}
```

* Public functions and members at top, protected in middle, private at bottom
* Class variables at top, then constructor then special functions, divided into groups.
* Often, code is divided by comments.

## Functions

* Function names should be descriptive of what they do and should be a verb ("doing word")
* Functions which return "bool" should be a question eg

```Java
boolean isXGreaterThan5 (int x) {
return x > 5;
}
```
22 changes: 22 additions & 0 deletions License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2018 Tim Ofenbach

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

Selling copies of the Software is forbidden!

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
55 changes: 43 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,43 @@
# catengine
Easy to use 2D Framework for Android.

# use cases
- creating simple 2D games
- animations/movements
- particle
- different screens (intro, menu, game, options etc)
- creating simple apps with animations, movements etc.

# contact
Questions? Email me: tim@ofenba.ch
# catengine developer edition 😼
Welcome to the developer-branch!
From here you can check out some of the new features that aren't available yet.

See full changelog: engine/main/MainActivity.java

# new features 💪
The update is done! Release coming soon.
+ ✅ gravity support
+ ✅ save support
+ ✅ sprite support
+ ✅ automatic positions
+ ✅ better touch functions
+ ✅ improved codestyle

# guide 📖
1. Download the engine folder.
2. Import the folder into your app project (@src).
3. Fix the imports depending on your app/package name.
4. Create GameStart.java to load your screens.
6. Your app now runs catengine developer edition!

# example 👀
The example contains all new features that are available!

# planned features 🤔
Here's a list of features that will be implemented one day:
+ GUI version 😍
+ simple drag&drop to create apps 🖱️
+ simple kid-friendly coding 👶
+ new effects (e.g. particles, explosions, fire)

# donations 💸
If you feel like supporting my work, feel free to donate:

![alt text](https://steemit-production-imageproxy-upload.s3.amazonaws.com/DQmc8NTQJp8vubgKHs2DgFiRx9ie2BZRrpzfj99Nh6PnUn9) 31hwi7KqnCo2L4mmtm7FeQuarggVxMiRy8
![alt text](https://steemit-production-imageproxy-upload.s3.amazonaws.com/DQmUJCKengMc25qYjBUKWodBUkXHb6m9VU47WnSTtwk46Qs) LVtnsswBGixXtBRm6a3nJths3QfABmSDZZ
![alt text](https://steemit-production-imageproxy-upload.s3.amazonaws.com/DQmdnnCcukhq9CAri1LaY9NGERrCNdexdwahAnLo8YFZ52K) 0xE6af1aaB8b26c88b36Af9bd0Fc16ced85EdB13d7

Thank you! ❤️

# contact ✉️
Questions? Email me: tim@ofenba.ch
44 changes: 44 additions & 0 deletions engine/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Installation
1) Download main and framework folder.
2) Import them to your src folder in your android studio project.
3) Fix the imports depending on your package names (android studio will help you).
4) Create GameStart.java and your own screens.
5) Your app runs catengine.

# Documentation

## Image.java
Useful functions:
draw()
scale()
scale(double)
scaleFullscreen()
setAngle(int)
setAlpha(int)
getAngleTo(image): int
collidesWith(image): boolean

## Button.java
Same as Image.java but can register touch.
isPressed(): boolean

## Music.java
Basic functions:
play()
pause()
stop()
delete()

## Sound.java
Basic functions:
play()
stop()
delete()

## Device.java
+ get_screen_width(): int
+ get_screen_height(): int
+ setSavingInt(String, int) <- for saving numbers onto the device
+ setSavingBool(bool) <- for saving bool values onto the device
+ getSavingInt(String): int <- get int value of file (filename: parameter string)
+ getSavingBool(String): bool <-same with bool
27 changes: 27 additions & 0 deletions engine/framework/Button.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package ofenbach.exampleapp.framework; // change this to your package name

import ofenbach.exampleapp.main.TouchEvent; // change this to your package name

/* Same as Image.java but can register touch */
/* @creation: March 2014 */
/* @update: 25.4.2018 */
/* @author: Tim B. Ofenbach */

public class Button extends Image {

public Button(int path) {
super(path);
}

public boolean isPressed() {

// Touch coords
int touchX = TouchEvent.getX();
int touchY = TouchEvent.getY();

// Hitbox check
return (touchX > super.getX() && touchX < super.getX() + super.getWidth() && touchY > super.getY() && touchY < super.getY() + super.getHeight());

}

}
64 changes: 64 additions & 0 deletions engine/framework/CollisionDetection.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package ofenbach.exampleapp.framework; // change this to your package name

import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Rect;

/* used by Image.java to detect collision between two images. */

public class CollisionDetection {

/**
* @param bitmap1 First bitmap
* @param x1 x-position of bitmap1 on screen.
* @param y1 y-position of bitmap1 on screen.
* @param bitmap2 second bitmap
* @param x2 x-position of bitmap2 on screen.
* @param y2 y-position of bitmap2 on screen.
*/

public static boolean isCollisionDetected(Bitmap bitmap1, int x1, int y1, Bitmap bitmap2, int x2, int y2) {

Rect bounds1 = new Rect(x1, y1, x1+bitmap1.getWidth(), y1+bitmap1.getHeight());
Rect bounds2 = new Rect(x2, y2, x2+bitmap2.getWidth(), y2+bitmap2.getHeight());

if (Rect.intersects(bounds1, bounds2)) {
Rect collisionBounds = getCollisionBounds(bounds1, bounds2);

for (int i = collisionBounds.left; i < collisionBounds.right; i++) {

for (int j = collisionBounds.top; j < collisionBounds.bottom; j++) {

int bitmap1Pixel = bitmap1.getPixel(i-x1, j-y1);
int bitmap2Pixel = bitmap2.getPixel(i-x2, j-y2);

if (isFilled(bitmap1Pixel) && isFilled(bitmap2Pixel)) {
return true;
}

}

}

}

return false;

}

private static Rect getCollisionBounds(Rect rect1, Rect rect2) {

int left = (int) Math.max(rect1.left, rect2.left);
int top = (int) Math.max(rect1.top, rect2.top);
int right = (int) Math.min(rect1.right, rect2.right);
int bottom = (int) Math.min(rect1.bottom, rect2.bottom);

return new Rect(left, top, right, bottom);

}

private static boolean isFilled(int pixel) {
return pixel != Color.TRANSPARENT;
}

}
Loading