Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Android Game Dev Framework

Featured Replies

So I was a tad inspired by Nillervision for trying to help his kid get into game programming and motivating him instead of mentioning the many pitfalls you can come across . So I got to work on a fairly simple Android game development framework which his kid can learn eventually or anyone else who may be interested in it once it's finished. That takes quite a lot of the hard work out of developing mobile games. Here is some examples a long with a screenshot of an example game.

 

Create Game Object

package com.rizodev.theandroidgameframework;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import com.rizodev.theandroidgameframework.interfaces.GameObj;



/**
 * You can easily create a new game object
 * by implementing GameObj
 */
public class Player implements GameObj {
    //New Bitmap
    private Bitmap player;
    //X / Y
    private int x,y;

    public Player(Context context)
    {
        //Get player image
        player =  BitmapFactory.decodeResource(context.getResources(), R.drawable.player);
    }

    @[member="OverRide"]
    public void update() {
    //Update code for the object goes here
        //Example code may be moving the object to the right
     //Object moves to right at a speed of 13

        x+=13;
    }

    @[member="OverRide"]
    public Bitmap getBitmap() {
        return player;
    }

    @[member="OverRide"]
    public void setX(int x) {
    this.x = x;
    }

    @[member="OverRide"]
    public void setY(int y) {
    this.y = y;
    }

    @[member="OverRide"]
    public int getX() {
        return x;
    }

    @[member="OverRide"]
    public int getY() {
        return y;
    }
}

Creating a New View

 

Below is a simple View using the Framework all you have to do is extend the Game class

package com.rizodev.theandroidgameframework;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import com.rizodev.theandroidgameframework.core.Game;
import com.rizodev.theandroidgameframework.core.Graphics;


/**
 * Game Views consist of just 2 required methods and a constructor
 * The game loop and threads are automatically 
 * created in the Game class all you have to worry about is
 * update() and render()
 * Created by steve on 9/25/15.
 */
public class MyView extends Game {

    public MyView(Context context) {
        super(context);
    }

    @[member="OverRide"]
    public void update() {
    //All updating takes place here
    }

    @[member="OverRide"]
    public void render(Canvas canvas) {
       //All drawing takes place here
  }

}

Lets Draw Something On Screen Using Our Game Object

package com.rizodev.theandroidgameframework;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import com.rizodev.theandroidgameframework.core.Game;
import com.rizodev.theandroidgameframework.core.Graphics;


/**
 * Game Views consist of just 2 required methods and a constructor
 * The game loop and threads are automatically 
 * created in the Game class all you have to worry about is
 * update() and render()
 * Created by steve on 9/25/15.
 */
public class MyView extends Game {
       //Reference our game object Player
     Player player;    
     //Reference the frameworks graphics class
     Graphics g; 

    public MyView(Context context) {
        super(context);
       //New instance of created Game Object
      player = new Player();
      //Call static method getGraphicsManager
      g = Graphics.getGraphicsManager();
    }

    @[member="OverRide"]
    public void update() {
    //Call objects update method
     player.update();
    }

    @[member="OverRide"]
    public void render(Canvas canvas) {
      //Create new paint
       Paint p = new Paint();
      //Clear last frame
      canvas.drawColor(Color.argb(255, 0, 0, 0));
      //Draw the player on the canvas
      g.drawImage(player,player.getX(),player.getY(),canvas,p);

  }

}

to see the game framework in action here is an example android game built using the framework

 

Screenshot from 2015-09-25 12:53:59.png

 

 

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.