Hello! I'm on my way with my first game, all design and that stuff are done, just coding left. I have successfully watched tutorials around the world wide web with information about Graphics and how to create a successfully thread-synchronization within it.
Like now I have a SurfaceView-class and a Thread-class. The thread-class have this constructor to receive the Game Engine from my SurfaceView-class. Simple code from Thread-class constructor:
public Thread(SurfaceHolder localsurfaceHolder,
Context context,
Handler handler,
SurfacefView localEngine) {
surfaceHolder = localsurfaceHolder;
this.handler = handler;
this.context = context;
engine = localEngine;
}
From my SurfaceView-class in the surfaceCreated-method:
thread = new GameThread(getHolder(), context, new Handler(), this);
And there is my code that will start trigging the thread when the surface is created.
Now to the real deal. Shortly I want a game engine that is totally separated from the view. The problem is; how to achieve this? How should the GameEngine-class constructor look like and where shall I put the drawing/calculations-methods? What does the GameEngine?
Now my GameEngine-class look like:
package com.myname.mygame;
public class GameEngine {
//If im right, a constructor for the engine should be placed here
//How and which parameters shall I change and send with from the view
}
Thanks in advance!