{"id":19635714,"url":"https://github.com/codepath/android_simple_game_engine","last_synced_at":"2025-04-28T08:30:48.087Z","repository":{"id":9421481,"uuid":"11292382","full_name":"codepath/android_simple_game_engine","owner":"codepath","description":"Simple 2D Android Game Framework","archived":false,"fork":false,"pushed_at":"2018-02-18T20:16:49.000Z","size":506,"stargazers_count":32,"open_issues_count":0,"forks_count":13,"subscribers_count":14,"default_branch":"master","last_synced_at":"2023-08-14T17:44:53.241Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codepath.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-07-09T19:50:18.000Z","updated_at":"2023-03-12T15:22:08.000Z","dependencies_parsed_at":"2022-09-16T14:02:08.646Z","dependency_job_id":null,"html_url":"https://github.com/codepath/android_simple_game_engine","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codepath%2Fandroid_simple_game_engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codepath%2Fandroid_simple_game_engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codepath%2Fandroid_simple_game_engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codepath%2Fandroid_simple_game_engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codepath","download_url":"https://codeload.github.com/codepath/android_simple_game_engine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224101976,"owners_count":17256065,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T12:26:38.103Z","updated_at":"2024-11-11T12:26:39.019Z","avatar_url":"https://github.com/codepath.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"android_simple_game_engine\n==========================\n\nSimple 2D Android Game Framework.\n\n## Warning\n\n**This repository is not currently maintained and is a simple proof of concept. Feel free to improve this code but keep in mind that this is likely not to work for anything beyond the most of basic use cases.**\n\n## Usage\n\nChange the \"main\" game activity to extend from `GameActivity`:\n\n```java\npublic class MyGameActivity extends GameActivity {\n  \n\t@Override\n\tprotected void onCreate(Bundle savedInstanceState) {\n\t\tsuper.onCreate(savedInstanceState);\n\t\tMyGamePanel panel = new MyGamePanel(this);\n\t \tsetContentView(panel);\n\t}\n\n}\n```\n\n### GamePanel\n\nCreate the game panel which will manage the various aspects of your game (input =\u003e update state =\u003e render):\n\n```java\npublic class MyGamePanel extends AbstractGamePanel {\n\tpublic MyGamePanel(Context context) {\n\t\tsuper(context);\n\t}\n\n\t// This method is called when the game first launches. Use this to\n\t// initialize variables and set starting values.\n\tpublic void onStart() {\n\t\t// Initialize your game\n\t}\n\n\t// This method is called once a \"tick\" to redraw the canvas,\n\t// so you can do things like draw the game actors.\n\tpublic void redrawCanvas(Canvas canvas) {\n\t\t// Draw things here using the canvas\n\t}\n\n\t// This method is called once a \"tick\", and it is a good place to\n\t// implement the game logic.\n\tpublic void onTimer() {\n\t\t// Game Logic Here\n\t}\n\n\t// This method is called whenever a keyboard button is pressed\n\t// within your game. The keyCode represents the key the actual key pushed.\n\t// You can check which keyCode using 'KeyEvent' constants.\n\t// i.e keyCode == KeyEvent.KEYCODE_N\n\t@Override\n\tpublic boolean onKeyDown(int keyCode, KeyEvent event) {\n\t\tLog.d(\"GameActivity\", keyCode);\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic boolean onTouchEvent(MotionEvent event) {\n\t\tLog.d(\"GameActivity\", event.getX() + \", \" + event.getY());\n    return true;\n\t}\n}\n```\n\n### Creating your Actors\n\nAnything object nside a game world that behaviors or logic is called an Actor. A player or an enemy or a ship, et al.\nTo create an actor, simply create a class extending from one of the actor base types. \nThere are a few base types available for an Actor:\n\n * `Actor` - Simplest type which provides \"enabled\" and \"visible\" properties as well as a few key methods.\n * `SimpleMovingActor` - Basic actor with x+y coordinates, width and height and velocity supported.\n * `SpriteMovingActor` - Extends from `SimpleMovingActor`, bitmap based (rather than painted) actors.\n * `AnimatedMovingActor`- Extends from `SpriteMovingActor`, animated (multiple frame) sprite based actors.\n \nCreating the actor just looks like:\n\n```java\npublic class HeroActor extends SimpleMovingActor {\n\tpublic HeroActor(int x, int y) {\n    // x, y and then width,height of actor\n\t\tsuper(x, y, 25, 25);\n\t}\n  \n  // Setup the color and style of the \"paint\" for the actor.\n\t@Override\n\tpublic void stylePaint(Paint paint) {\n\t\tpaint.setColor(Color.GREEN);\n\t\tpaint.setStyle(Paint.Style.FILL);\n\t\t// p.setStyle(Paint.Style.STROKE);\n\t\t// p.setStrokeWidth(5);\n\t}\n  \n  // Specify how to draw the actor on the panel\n  // getRect() returns the rectangle containing the actor\n  // getPaint() returns the primary paint to use when drawing the actor\n\t@Override\n\tpublic void draw(Canvas canvas) {\n\t  canvas.drawRect(getRect(), getPaint());\n\t}\n}\n```\n\nYou can then add an actor to the panel:\n\n```java\npublic class MyGamePanel extends AbstractGamePanel {\n\n  HeroActor player;\n\n\tpublic MyGamePanel(Context context) {\n\t\tsuper(context);\n\t}\n\n\t// This method is called when the game first launches. Use this to\n\t// initialize variables and set starting values.\n\tpublic void onStart() {\n    // sets initial position of actor\n\t\tplayer = new HeroActor(50, 50);\n\t}\n\n\t// This method is called once a \"tick\" to redraw the canvas,\n\t// so you can do things like draw the game actors.\n\tpublic void redrawCanvas(Canvas canvas) {\n\t\tplayer.draw(canvas);\n\t}\n\n\t// This method is called once a \"tick\", and it is a good place to\n\t// implement the game logic.\n\tpublic void onTimer() {\n\t\tif (player.something()) {\n      // do something\n    } else {\n      // something else\n    }\n\t}\n\n}\n```\n\nNow the actor will be painted on the board.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodepath%2Fandroid_simple_game_engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodepath%2Fandroid_simple_game_engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodepath%2Fandroid_simple_game_engine/lists"}