<commit_before>package com.dtg.gametest;
import android.content.Context;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;


public class GamePanel extends SurfaceView implements SurfaceHolder.Callback
{
    public static final int WIDTH = 1920;
    public static final int HEIGHT = 1080;
    public static final int MOVESPEED = -10;
    private MainThread thread;
    private Player player;
    private Background bg;

    public GamePanel(Context context)
    {
        super(context);
        //add the callback to the surfaceholder to intercept events
        getHolder().addCallback(this);

        thread = new MainThread(getHolder(), this);

        //make gamePanel focusable so it can handle events
        setFocusable(true);
    }

    @Override
    public void surfaceChanged(SurfaceHolder holder, int format, int width, int height){}

    @Override
    public void surfaceDestroyed(SurfaceHolder holder){
        boolean retry = true;
        while(retry)
        {
            try{
                thread.setRunning(false);
                thread.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            retry = false;
        }
    }

    @Override
    public void surfaceCreated(SurfaceHolder holder){

        // Scaled options for images are causing incorrect pixel resolution
        BitmapFactory.Options o = new BitmapFactory.Options();
        o.inScaled = false;
        bg = new Background(BitmapFactory.decodeResource(getResources(), R.drawable.rsz_bg_image, o));
        player = new Player(BitmapFactory.decodeResource(getResources(), R.drawable.pilg_sprites, o), 108, 140, 8);

        //we can safely start the game loop
        thread.setRunning(true);
        thread.start();

    }
    @Override
    public boolean onTouchEvent(MotionEvent event)
    {
        if( event.getAction() == MotionEvent.ACTION_DOWN ) {
            if( !player.getPlaying()) {
                player.setPlaying(true);
            } else {
                System.out.println("++++++++++++++++++++");
                player.setUp(true);
            }
            return true;
        }

        if( event.getAction() == MotionEvent.ACTION_UP ) {
            System.out.println("-------------------");
            player.setUp(false);
            return true;
        }

        return super.onTouchEvent(event);
    }

    public void update()
    {
        if( player.getPlaying() ) {
            player.update();
            bg.update();
        }
    }
    @Override
    public void draw(Canvas canvas)
    {
        final float scaleFactorX = getWidth() / (WIDTH * 1.0f);
        final float scaleFactorY = getHeight() / (HEIGHT * 1.0f);
//        System.out.println("Width: " + getWidth() + " " + scaleFactorX +  "Height: " + getHeight() + " " + scaleFactorY );

        if(canvas!=null) {
            final int savedState = canvas.save();
            canvas.scale(scaleFactorX, scaleFactorY);
//            System.out.println("Canvas X: " + canvas.getWidth());
            bg.draw(canvas);
            player.draw(canvas);
            canvas.restoreToCount(savedState);
        }
    }<commit_msg>removing debug lines<commit_after>package com.dtg.gametest;
import android.content.Context;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;


public class GamePanel extends SurfaceView implements SurfaceHolder.Callback
{
    public static final int WIDTH = 1920;
    public static final int HEIGHT = 1080;
    public static final int MOVESPEED = -10;
    private MainThread thread;
    private Player player;
    private Background bg;

    public GamePanel(Context context)
    {
        super(context);
        //add the callback to the surfaceholder to intercept events
        getHolder().addCallback(this);

        thread = new MainThread(getHolder(), this);

        //make gamePanel focusable so it can handle events
        setFocusable(true);
    }

    @Override
    public void surfaceChanged(SurfaceHolder holder, int format, int width, int height){}

    @Override
    public void surfaceDestroyed(SurfaceHolder holder){
        boolean retry = true;
        while(retry)
        {
            try{
                thread.setRunning(false);
                thread.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            retry = false;
        }
    }

    @Override
    public void surfaceCreated(SurfaceHolder holder){

        // Scaled options for images are causing incorrect pixel resolution
        BitmapFactory.Options o = new BitmapFactory.Options();
        o.inScaled = false;
        bg = new Background(BitmapFactory.decodeResource(getResources(), R.drawable.rsz_bg_image, o));
        player = new Player(BitmapFactory.decodeResource(getResources(), R.drawable.pilg_sprites, o), 108, 140, 8);

        //we can safely start the game loop
        thread.setRunning(true);
        thread.start();

    }
    @Override
    public boolean onTouchEvent(MotionEvent event)
    {
        if( event.getAction() == MotionEvent.ACTION_DOWN ) {
            if( !player.getPlaying()) {
                player.setPlaying(true);
            } else {
                player.setUp(true);
            }
            return true;
        }

        if( event.getAction() == MotionEvent.ACTION_UP ) {
            player.setUp(false);
            return true;
        }

        return super.onTouchEvent(event);
    }

    public void update()
    {
        if( player.getPlaying() ) {
            player.update();
            bg.update();
        }
    }
    @Override
    public void draw(Canvas canvas)
    {
        final float scaleFactorX = getWidth() / (WIDTH * 1.0f);
        final float scaleFactorY = getHeight() / (HEIGHT * 1.0f);
//        System.out.println("Width: " + getWidth() + " " + scaleFactorX +  "Height: " + getHeight() + " " + scaleFactorY );

        if(canvas!=null) {
            final int savedState = canvas.save();
            canvas.scale(scaleFactorX, scaleFactorY);
//            System.out.println("Canvas X: " + canvas.getWidth());
            bg.draw(canvas);
            player.draw(canvas);
            canvas.restoreToCount(savedState);
        }
    }
{'fraction_non_alphanumeric': 0.10759493670886076, 'fraction_numerical': 0.006483482556344551, 'mean_word_length': 2.1179018286814246, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1454141', 'n_tokens_mistral': 1784, 'n_tokens_neox': 1682, 'n_words': 428}