Dylan Poon

"Whoever is trying to bring you down is already below you"

By

In-Depth Blog Post #3: Progress!

In the two weeks since last post, I have been working hard on moving my In-Depth Project forwards, and have a hefty load of content to show for my efforts. The two apps I have made in addition to the last week’s are still simple, but are moving away from ‘proof-of-concept’, and are heading towards some fun, playable, glitch-free games. I also tried to configure my screen recording software so that I could record myself coding (like I proposed initially) but had no luck. For this week, I will be describing the process of what I learned, and include videos of the final products.


Status Update:


 

Animated Movement Test:

Though this next app was a continuation of last week’s movement test app, I had to make drastic changes to the code to add in the factor of a moving animated image. I also learned that each frame in an animation is not many individual images, but rather a collection of images in a row, which is ‘cut’ up into pieces by the code.

private int frameCount = 12;

Above is the line that tells the program to split the spritesheet into 12 parts, giving us 12 frames of animation, which can be looped to create a fluid animation, and in my case, a walking cycle.

In addition to adding animations, I also figured out how to make the app landscape, by going through the AndroidManifest and adding in the line

android:screenOrientation=”landscape”

This one proof of concept app will set the scene for the rest of what I make, as movement and animations will be important in my final product.

Code at the bottom of the post


Snake Game:

Moving on from simpler apps, I decided to learn how to make something playable. Randy recommended that I try to make the classic game “snake”. After working on this project for a couple of days, I finally got the game to begin to work, as well as learned new functions regarding touching the screen. The function is not shown in the video below for gameplay purposes, but I coded the game so that touching the right side of the screen moves the direction of the snake right 90 degrees, while the other side does the opposite. This function can also be incorporated into making buttons in specific places, and not just large portions of the screen.

As always, code is at the bottom of the post!


How to Have a Beautiful Mind:


#2 to ask for clarification whenever you are unclear or in doubt about something the mentor tells you or shows you:

Me: Wait, so this snippet of code actually controls how fast the image moves across the screen, right?

Randy: Yes, just don’t change it too drastically.

After Randy taught me some more about how to position my code I asked for clarification on where and how to place snippets into the code. After hearing it for the second time, I felt much more confident that I would remember this for future projects, as well as got more information on how the function works.

#3 to support a point your mentor makes with additional facts, figures, evidence etc:

When Randy and I discussed setting values for sizes, frames, frames per second and other value related inputs, Randy mentioned that I should be sure that the input of the value is for the correct variable. I affirmed his point by intentionally switching the height and width values to prove to myself that his point was a valuable lesson, as I had previously spent a large amount of time troubleshooting something that I could have easily fixed in 2 seconds. (I forgot to check the height and widths I had set)

#5 to share a personal story that illustrates the conversation topic:

In sort of a joking manner, Randy had me try to create a sprite sheet of his dog walking for an example of how to make a sprite sheet. I did so, and came back the next week, where we applied the animation and made a somewhat silly idea into a working project, which strengthened our communication, and also made the conversions we had much more interesting.

#10 to modify an idea to make it more acceptable to yourself and to make it stronger or more practical:

While my mentor and I were messing with the code of the animation test I made, I initially thought that this was pointless fun. But after sleeping on it, i realized that messing with this code may help me in my final project, and came to realize that it is possible to borrow portions of the code, rearrange the numbers, and create a fully functioning app out of borrowed code. (Not what I am going to do, but may help if I get stuck on a problem)


~ In-Depth is well on it’s way, so I will be working hard to hone my new knowledge! (and also type faster)


Code:


 

Animation Movement Test:

MainActivity.java

package com.dpoon.animatedmovetest;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

public class MainActivity extends Activity {
    GameView gameView;                                   // The view and the sprite sheet animation logic

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        gameView = new GameView(this);                        // Initialize gameView and set it as the view
        setContentView(gameView);
    }

    // Here is our implementation of GameView. It is an inner class.
    // Notice we implement runnable so we have A thread and can override the run method.
    class GameView extends SurfaceView implements Runnable {
        Thread gameThread = null;                                                     // This is our thread
        SurfaceHolder ourHolder;        // We need a SurfaceHolder when we use Paint and Canvas in a thread
        volatile boolean playing;                        // Set and unset when the game is running- or not.
        Canvas canvas;                                                       // A Canvas and a Paint object
        Paint paint;
        long fps;                                               // This variable tracks the game frame rate
        private long timeThisFrame;                               // This is used to help calculate the fps
        Bitmap bitmapBob;                                               // Declare an object of type Bitmap
        boolean isMoving = false;                                              // Bob starts off not moving
        float walkSpeedPerSecond = 250;                             // He can walk at 250 pixels per second
        float bobXPosition = 10;                                       // He starts 10 pixels from the left

        // New for the sprite sheet animation
        private int frameWidth = 90;                       // These values can be anything, as long as the
        private int frameHeight = 150;                          // ratio doesn't distort the sprite too much
        private int frameCount = 12;                       // How many frames are there on the sprite sheet?
        private int currentFrame = 0;                             // Start at the first frame - where else?
        private long lastFrameChangeTime = 0;               // What time was it when we last changed frames
        private int frameLengthInMilliseconds = 100;                     // How long should each frame last

        // A rectangle to define an area of the sprite sheet that represents 1 frame
        private Rect frameToDraw = new Rect( 0, 0, frameWidth, frameHeight);

        // A rect that defines an area of the screen on which to draw
        RectF whereToDraw = new RectF( bobXPosition, 0, bobXPosition + frameWidth, frameHeight);

        // When we initialize (call new()) gameView, this special constructor method runs
        public GameView(Context context) {
            super(context);                                // Ask the SurfaceView class to set up our object.
            ourHolder = getHolder();                                // Initialize ourHolder and paint objects
            paint = new Paint();
            bitmapBob = BitmapFactory.decodeResource(this.getResources(), R.drawable.bobby);        // Load Bob

            // Scale the bitmap to the correct size. Android automatically scales bitmaps based on screen
            bitmapBob = Bitmap.createScaledBitmap(bitmapBob, frameWidth * frameCount, frameHeight, false);

            playing = true;                                        // Set our boolean to true - game on!
        }

        @Override
        public void run() {
            while (playing) {
                long startFrameTime = System.currentTimeMillis();   // Capture the current time in milliseconds
                update();                                                                   // Update the frame
                draw();                                                                       // Draw the frame

                // Calculate the fps. Use the result to time animations and more.
                timeThisFrame = System.currentTimeMillis() - startFrameTime;

                if (timeThisFrame >= 1) { fps = 1000 / timeThisFrame; }
            }
        }

        // Everything that needs to be updated goes in here. In later projects we will
        // have dozens of objects. We will also do other things like collision detection.
        public void update() {
            // If bob is moving (the player is touching the screen)
            // then move him to the right based on his target speed and the current fps.
            if(isMoving){ bobXPosition = bobXPosition + (walkSpeedPerSecond / fps); }
        }

        public void getCurrentFrame(){
            long time  = System.currentTimeMillis();
            if(isMoving) {                                                   // Only animate if bob is moving
                if ( time > lastFrameChangeTime + frameLengthInMilliseconds) {
                    lastFrameChangeTime = time;
                    currentFrame++;
                    if (currentFrame >= frameCount) { currentFrame = 0; }
                }
            }
            //update the left and right values of the source of the next frame on the spritesheet
            frameToDraw.left = currentFrame * frameWidth;
            frameToDraw.right = frameToDraw.left + frameWidth;
        }


        public void draw() {                                                // Draw the newly updated scene
            if (ourHolder.getSurface().isValid()) {     // Make sure our drawing surface is valid or we crash
                canvas = ourHolder.lockCanvas();                               // Lock the canvas ready to draw
                canvas.drawColor(Color.argb(255,  26, 128, 182));                  // Draw the background color
                paint.setColor(Color.argb(255,  249, 129, 0));            // Choose the brush color for drawing
                paint.setTextSize(45);                                            // Make the text a bit bigger
                canvas.drawText("FPS:" + fps, 20, 40, paint);          // Display the current fps on the screen
                whereToDraw.set((int)bobXPosition, 0, (int)bobXPosition + frameWidth, frameHeight); // Draw bob
                getCurrentFrame();
                canvas.drawBitmap(bitmapBob, frameToDraw, whereToDraw, paint);
                ourHolder.unlockCanvasAndPost(canvas);                         // Draw everything to the screen
            }
        }

        public void pause() {                     // If MainActivity is paused/stopped shutdown our thread.
            playing = false;
            try { gameThread.join(); }
            catch (InterruptedException e) { Log.e("Error:", "joining thread"); }
        }

        public void resume() {                         // If MainActivity is started theb start our thread.
            playing = true;
            gameThread = new Thread(this);
            gameThread.start();
        }

        // The SurfaceView class implements onTouchListener, so we can override this method.
        @Override
        public boolean onTouchEvent(MotionEvent motionEvent) {
            switch (motionEvent.getAction() & MotionEvent.ACTION_MASK) {
                case MotionEvent.ACTION_DOWN:                                  // Player has touched the screen
                    isMoving = true;                         // Set isMoving so Bob is moved in the update method
                    break;
                case MotionEvent.ACTION_UP:                            // Player has removed finger from screen
                    isMoving = false;                                        // Set isMoving so Bob does not move
                    break;
            }
            return true;
        }
    }                                                      // This is the end of our GameView inner class

    @Override
    protected void onResume() {                   // This method executes when the player starts the game
        super.onResume();
        gameView.resume();                                    // Tell the gameView resume method to execute
    }

    @Override
    protected void onPause() {                     // This method executes when the player quits the game
        super.onPause();
        gameView.pause();                                      // Tell the gameView pause method to execute
    }
}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.dpoon.animatedmovetest">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
            android:screenOrientation="landscape"
            >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Snake Game:

MainActivity.java

package com.dpoon.snake;

import android.app.Activity;
import android.graphics.Point;
import android.os.Bundle;
import android.view.Display;

public class MainActivity extends Activity {
    SnakeEngine snakeEngine;                                        // Declare an instance of SnakeEngine

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Display display = getWindowManager().getDefaultDisplay(); // Get the pixel dimensions of the screen

        Point size = new Point();                              // Initialize the result into a Point object
        display.getSize(size);

        snakeEngine = new SnakeEngine(this, size);        // Create a new instance of the SnakeEngine class

        setContentView(snakeEngine);                           // Make snakeEngine the view of the Activity
    }
    @Override
    protected void onResume() {                                          // Start the thread in snakeEngine
        super.onResume();
        snakeEngine.resume();
    }

    @Override
    protected void onPause() {                                          // Stop the thread in snakeEngine
        super.onPause();
        snakeEngine.pause();
    }

}

SnakeEngine.java

package com.dpoon.snake;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.media.AudioManager;
import android.media.SoundPool;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

import java.util.Random;

class SnakeEngine extends SurfaceView implements Runnable {
    private Thread thread = null;                                 // Our game thread for the main game loop
    private Context context;                                         // To hold a reference to the Activity

    private SoundPool soundPool;                                                // for plaing sound effects
    int eat_bob;
    int snake_crash;

    public enum Heading {UP, RIGHT, DOWN, LEFT}                            // For tracking movement Heading
    private Heading heading = Heading.RIGHT;                               // Start by heading to the right
    private int screenX;                                               // To hold the screen size in pixels
    private int screenY;
    private int snakeLength;                                                       // How long is the snake
    private int bobX;                                                               // Where is Bob hiding?
    private int bobY;
    private int blockSize;                                         // The size in pixels of a snake segment
    private final int NUM_BLOCKS_WIDE = 40;                    // The size in segments of the playable area
    private int numBlocksHigh;
    private long nextFrameTime;                                          // Control pausing between updates
    private final long FPS = 10;                                     // Update the game 10 times per second
    private final long MILLIS_PER_SECOND = 1000;                 // There are 1000 milliseconds in a second
    private int score;                                              // How many points does the player have
    private int[] snakeXs;                                  // The location in the grid of all the segments
    private int[] snakeYs;
    private volatile boolean isPlaying;    // Everything we need for drawing is the game currently playing?
    private Canvas canvas;                                                        // A canvas for our paint
    private SurfaceHolder surfaceHolder;                                          // Required to use canvas
    private Paint paint;                                                       // Some paint for our canvas
    public SnakeEngine(Context context, Point size) {
        super(context);

        context = context;

        screenX = size.x;
        screenY = size.y;

        blockSize = screenX / NUM_BLOCKS_WIDE;                      // Work out how many pixels each block is
        numBlocksHigh = screenY / blockSize;     // How many blocks of the same size will fit into the height

        soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);                      // Set the sound up
        eat_bob = soundPool.load(context, R.raw.eat_bob, 1);              // Prepare the two sounds in memory
        snake_crash = soundPool.load(context, R.raw.snake_crash, 1);

        surfaceHolder = getHolder();                                        // Initialize the drawing objects
        paint = new Paint();

        snakeXs = new int[200];                // If you score 200 you are rewarded with a crash achievement!
        snakeYs = new int[200];

        newGame();                                                                          // Start the game
    }

    @Override
    public void run() {
        while (isPlaying) {

            if(updateRequired()) {// Update 10 times a second
                update();
                draw();
            }
        }
    }

    public void pause() {
        isPlaying = false;
        try {
            thread.join();
        } catch (InterruptedException e) {
            // Error
        }
    }

    public void resume() {
        isPlaying = true;
        thread = new Thread(this);
        thread.start();
    }
    public void newGame() {
        snakeLength = 1;                                                 // Start with a single snake segment
        snakeXs[0] = NUM_BLOCKS_WIDE / 2;
        snakeYs[0] = numBlocksHigh / 2;
        spawnBob();                                                               // Get Bob ready for dinner
        score = 0;                                                                         // Reset the score
        nextFrameTime = System.currentTimeMillis();          // Setup nextFrameTime so an update is triggered
    }
    public void spawnBob() {
        Random random = new Random();
        bobX = random.nextInt(NUM_BLOCKS_WIDE - 1) + 1;
        bobY = random.nextInt(numBlocksHigh - 1) + 1;
    }
    private void eatBob(){
        snakeLength++;                                             // Got him! Increase the size of the snake
        spawnBob();                                                                             //replace Bob
        score = score + 1;                                                                 //add to the score
        soundPool.play(eat_bob, 1, 1, 0, 0, 1);
    }
    private void moveSnake(){
        for (int i = snakeLength; i > 0; i--) {                                              // Move the body
            snakeXs[i] = snakeXs[i - 1];        // Start at back and move to position of segment in front of it
            snakeYs[i] = snakeYs[i - 1];        // Exclude the head because the head has nothing in front of it
        }

        switch (heading) {                                        // Move the head in the appropriate heading
            case UP:
                snakeYs[0]--;
                break;
            case RIGHT:
                snakeXs[0]++;
                break;
            case DOWN:
                snakeYs[0]++;
                break;
            case LEFT:
                snakeXs[0]--;
                break;
        }
    }
    private boolean detectDeath(){
        boolean dead = false;                                                          // Has the snake died?
        if (snakeXs[0] == -1) dead = true;                                             // Hit the screen edge
        if (snakeXs[0] >= NUM_BLOCKS_WIDE) dead = true;
        if (snakeYs[0] == -1) dead = true;
        if (snakeYs[0] == numBlocksHigh) dead = true;

        for (int i = snakeLength - 1; i > 0; i--) {                                          // Eaten itself?
            if ((i > 4) && (snakeXs[0] == snakeXs[i]) && (snakeYs[0] == snakeYs[i])) {
                dead = true;
            }
        }

        return dead;
    }
    public void update() {
        if (snakeXs[0] == bobX && snakeYs[0] == bobY) {                 // Did the head of the snake eat Bob?
            eatBob();
        }

        moveSnake();

        if (detectDeath()) {
            soundPool.play(snake_crash, 1, 1, 0, 0, 1);                                           //start again
            newGame();
        }
    }
    public void draw() {
        if (surfaceHolder.getSurface().isValid()) {                               // Get a lock on the canvas
            canvas = surfaceHolder.lockCanvas();
            canvas.drawColor(Color.argb(255, 26, 128, 182));      // Fill the screen with Game Code School blue
            paint.setColor(Color.argb(255, 255, 255, 255));   // Set color of the paint to draw the snake white
            paint.setTextSize(90);                                                        // Scale the HUD text
            canvas.drawText("Score:" + score, 10, 70, paint);

            for (int i = 0; i < snakeLength; i++) {                       // Draw the snake one block at a time
                canvas.drawRect(snakeXs[i] * blockSize, (snakeYs[i] * blockSize),
                        (snakeXs[i] * blockSize) + blockSize, (snakeYs[i] * blockSize) + blockSize, paint);
            }


            paint.setColor(Color.argb(255, 255, 0, 0));           // Set the color of the paint to draw Bob red
            canvas.drawRect(bobX * blockSize, (bobY * blockSize),                                   // Draw Bob
                    (bobX * blockSize) + blockSize, (bobY * blockSize) + blockSize, paint);


            surfaceHolder.unlockCanvasAndPost(canvas);  // Unlock canvas and reveal the graphics for this frame
        }
    }
    public boolean updateRequired() {
        if(nextFrameTime <= System.currentTimeMillis()){                    // Are we due to update the frame
            // Tenth of a second has passed. Setup when the next update will be triggered
            nextFrameTime =System.currentTimeMillis() + MILLIS_PER_SECOND / FPS;
            return true;                      // Return true so that the update and draw functions are executed
        }
        return false;
    }
    @Override
    public boolean onTouchEvent(MotionEvent motionEvent) {
        switch (motionEvent.getAction() & MotionEvent.ACTION_MASK) {
            case MotionEvent.ACTION_UP:
                if (motionEvent.getX() >= screenX / 2) {
                    switch(heading){
                        case UP:
                            heading = Heading.RIGHT;
                            break;
                        case RIGHT:
                            heading = Heading.DOWN;
                            break;
                        case DOWN:
                            heading = Heading.LEFT;
                            break;
                        case LEFT:
                            heading = Heading.UP;
                            break;
                    }
                } else {
                    switch(heading){
                        case UP:
                            heading = Heading.LEFT;
                            break;
                        case LEFT:
                            heading = Heading.DOWN;
                            break;
                        case DOWN:
                            heading = Heading.RIGHT;
                            break;
                        case RIGHT:
                            heading = Heading.UP;
                            break;
                    }
                }
        }
        return true;
    }

}

By

In-Depth Blog Post #2: The Next Steps

It has been two weeks since the start of the second In-Depth Project! I have been working hard in the background to create some simple “proof of concept” apps to begin to learn to code as well as following tutorials to learn the coding language. Initially, I did say that I wanted to film a lengthy amount of video of myself coding, but the file corrupted, and I only have 5 minutes of un-sped up footage (out of what should have been 3 hours) which unluckily ended up being footage of myself trying to use the screen recording program. So, I will just explain what I did and include the products of what I have worked on.


 

Status Update:


My First App:

The first app I made was a simple image, which needed me to set variables and tell the engine what information to import into the app. It also taught me about coordinates on an app screen, hex codes for colors, and how not to have any errors in the code.

img-20190202-wa0000

Though unimpressive, the app took me around an hour to get working, and two more to perfect. I managed to place a circle, rectangle, a line, a hard to see dot, some text, and an image of “Bob” onto the screen.

(Code at the bottom of this post)


Movement Testing:

After getting that app to work, and meeting with my mentor again, I set out to make movement happen on the screen. However, I was a bit too arrogant when setting out to make it work, and after many hours of confusion, I turned to a resource that my mentor, Randy, had given me. I read through Javascript for Dummies for a couple of hours, and managed to get the program to partially work. When I saw Randy again, we reviewed what I had learned, as well as skimmed through my rough code to refine and remove the errors.

That is the product of a weekend with too much free time!

(Code at the bottom of this post)


How to Have a Beautiful Mind:


How to agree:

In Edward De Bono’s How To Have a Beautiful Mindit is stated that “a discussion should be a genuine attempt to explore a subject”, which applies nicely to the In-Depth Project, as well as the idea of seeking a mentor for the betterment of oneself (pg.5). Applying this directly to my project, I have found that my mentor’s teaching style differed from what I was normally used to. He tended to leave much of the questions I had about what it was like to code up to me to decide, and liked experience based learning, while I wanted to take a more direct path towards my goal. However, I realized that his past experiences and “logic bubble” must have been different than mine, as he began coding when computers first began to pop up in households, while I have been surrounded by technology my whole life. There must have been no answer to the question I asked him when he would have had the same question, and I have realized that answering the question on my own may be beneficial in some way. Taking this into consideration, I have found common ground in both wanting me to progress towards my goal, as well as towards answering my question. This was one example of agreement between Randy and I.

How to disagree:

While looking over and confirming the projects Randy and I would be working on, I pointed out that one of the projects seemed to be redundant, as it was simply an almost identical copy of another project. After discussing why there were two similar projects, my mentor still believed that the project would benefit me more if I did it. However, I found that this may waste an extra mentoring session, which would be very important due to the magnitude of my In-Depth selection. To avoid ruining my relations with my mentor, I “politely and gently rather than rudely and aggressively” presented my opinion, and left the conversation open for a later discussion, when either of our views may have changed on this topic (pg.26).

How to differ:

During my last meeting with Randy, we had a small difference when discussing the most efficient way to code an frames per second counter. I believed that it could be easily done without setting variables, since this was the way that I had done it previously. However, when my mentor stated that it could be, and should be done with variables, we differed, and expressed our opinions. Though both were technically correct, my mentor’s way of creating an fps counter was much more efficient, and utilized the same method as other parts of the code, meaning I could memorize less information. So, this difference was not regarding opinion, but rather regarded the better or more factual way of working more efficiently.


~ This is just the start of another In-Depth, and I will be sure to make the most of it!


 

Code:


 

My First App:

package com.dpoon.graphicsdemo;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.widget.ImageView;

public class MainActivity extends Activity {
    ImageView ourView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        draw();
        setContentView(ourView);
    }
    public void draw(){
        Bitmap blankBitmap;
        blankBitmap = Bitmap.createBitmap(600,600,Bitmap.Config.ARGB_8888);
        Canvas canvas;
        canvas = new Canvas(blankBitmap);

        ourView = new ImageView(this);
        ourView.setImageBitmap(blankBitmap);

        Paint paint;
        paint = new Paint();

        canvas.drawColor(Color.argb(255, 255, 255, 255));
        Bitmap bitmapBob;
        bitmapBob = BitmapFactory.decodeResource(this.getResources(), R.drawable.bob);
        canvas.drawBitmap(bitmapBob, 500, 50, paint);
        paint.setColor(Color.argb(255,  26, 128, 182));
        canvas.drawLine(50,50,250,250,paint);
        canvas.drawText("TALONS is fun!", 50, 50, paint);
        canvas.drawPoint(40,50,paint);
        canvas.drawCircle(350,250,100,paint);
        paint.setColor(Color.argb(255,  249, 129, 0));
        canvas.drawRect(50,450,500,550,paint);
    }
}

Movement Test:

package com.dpoon.movetest;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
public class MainActivity extends Activity {
    GameView gameView; 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        gameView = new GameView(this);
        setContentView(gameView);
    }

    class GameView extends SurfaceView implements Runnable {
        Thread gameThread = null; 
        SurfaceHolder ourHolder;
        volatile boolean playing;
        Canvas canvas;
        Paint paint;
        long fps;
        private long timeThisFrame;
        Bitmap bitmapBob;
        boolean isMoving = false;
        float walkSpeedPerSecond = 150;
        float bobXPosition = 10;                                      

        // When we initialize (call new()) gameView, this special constructor method runs.
        public GameView(Context context) {                                          
            super(context);                           
            ourHolder = getHolder();                       
            paint = new Paint();
            bitmapBob = BitmapFactory.decodeResource(this.getResources(), R.drawable.bob); 
            playing = true;                                         
        }

        @Override
        public void run() {
            while (playing) {
                long startFrameTime = System.currentTimeMillis(); 
                update();                                                               
                draw();                                                                  

                // Calculate the fps. Use the result to time animations and more.
                timeThisFrame = System.currentTimeMillis() - startFrameTime;

                if (timeThisFrame > 0) { fps = 1000 / timeThisFrame; }
            }
        }
            if(isMoving){ bobXPosition = bobXPosition + (walkSpeedPerSecond / fps); }
        }

        public void draw() {                                          
            if (ourHolder.getSurface().isValid()) {     
                canvas = ourHolder.lockCanvas();                           
                canvas.drawColor(Color.argb(255,  26, 128, 182));            
                paint.setColor(Color.argb(255,  249, 129, 0));    
                paint.setTextSize(45);                         
                canvas.drawText("FPS:" + fps, 20, 40, paint); 
                canvas.drawBitmap(bitmapBob, bobXPosition, 200, paint);  
                ourHolder.unlockCanvasAndPost(canvas);                
            }
        }
        public void pause() {
            playing = false;

            try { gameThread.join(); }
            catch (InterruptedException e) { Log.e("Error:", "joining thread"); }
        }
        public void resume() {
            playing = true;
            gameThread = new Thread(this);
            gameThread.start();
        }
        @Override
        public boolean onTouchEvent(MotionEvent motionEvent) {             
            switch (motionEvent.getAction() & MotionEvent.ACTION_MASK) {
                case MotionEvent.ACTION_DOWN:                          
                    isMoving = true;            
                    break;
                case MotionEvent.ACTION_UP:                
                    isMoving = false;                           
                    break;
            }
            return true;
        }
    }                                               
    @Override
    protected void onResume() {             
        super.onResume();
        gameView.resume();                                
    }
    @Override
    protected void onPause() {               
        super.onPause();
        gameView.pause();               
    }
}

 

By

ZIP: Final DOL

1. What is your inquiry question? What initially drew you to this question? Did your question stay the same, or did it change overtime? Why?

Question: What makes a good persuasive essay?

After writing an expository essay in class, I was interested in essay writing, but also wanted to learn how to be more convincing in a debate. After reading an article on why persuasion is a needed skill in life, I thought about learning to make a good verbal argument. However, with essay writing still in the back of my mind, I decided to combine the two, and look into persuasive writing. I chose this question specifically because I wanted to learn more about essay writing in general, but also wanted to work at one of my goals, which was to get better at public speaking, and feel confident while doing so. However, I realized recently that the reason I was not confident was due to not feeling confident in my points. So by pursuing persuasive writing, I wanted to learn how to make better points, as well as exercise my writing skills. After getting time to research and work in class, my question has stayed mostly the same, but I found myself drifting away from learning how to be more convincing, and more towards learning essay structure and how to make the essay convincing.

2. What skills have you expanded on / learned during the inquiry process? How are these skills applicable to your success as a student?

I have learned lots about essay writing during the duration of this project. I have greatly expanded on my formal essay writing skills, as well as gained a better grasp on how to improve my writing. Specifically, I learned that the order points are placed in can alter the psychological impact that your essay gives. Placing a paragraph on counter points too soon in the piece gives the impression that you have researched only the counter points to your arguments, and that you simply want to ‘shoot’ them down, rather than constructively and respectfully disagree and present your own opinion. The skills I have improved and learned in this ZIP project will help me in future expository essays, but extend father into the future. Perhaps during a job interview or university application, I will need to learn how to be persuasive, and sell myself as a person. By learning how to be persuasive, I believe I have increased my chances of ‘success’ in the future.

3. What did you learn about / what is your answer to this inquiry question? Remember to be specific and provide direct evidence from your research.

I learned about how to write an essay persuasively, but on the side, have learned about the psychology of first impressions. Though my main topic does not directly connect with psychology, first impressions play a role in persuading people. First impressions are the image of you that a person gets when meeting another person for the first time, but in this context, is what the reader thinks of you when they read your writing. According to the “principle of likeability” and the “principle of authority” people are more likely to be persuaded if they either like you, or if you have some sort of higher authority. By harnessing this in writing, a persuasive essay can go from “this has some good points” to “I agree”. By making the reader feel familiar with you, though they may or may not know you personally, or making the reader understand that you have more qualified knowledge, you can change the outcome of a reader’s opinion after reading your piece. So, to get better at writing persuasively, you need to understand who you are writing for, adapt the context of your writing to that audience, and write as formally or informally as it is required to adapt to the “principles of persuasion”.

4. In what ways does your final learning artifact demonstrate your learning / answer to your inquiry question? How does it connect to your chosen curricular competencies? Consider listing your competencies and including images, links, or excerpts from your work to demonstrate this.

My final learning artifact, being a list of tips shows my learning though displaying what I have learned clearly and explicitly. It answers my question directly, by stating multiple points that contribute to making a good persuasive essay. The list demonstrates my learning by showing that I have done specific research, and have been able to interpret multiple sources and compile them into a cohesive whole. The competencies I chose also connect to my final artifact.

“Recognize how different forms, formats, structures and features of texts enhance and shape meaning and impact”:

My inquiry question revolves around using psychological principles to “enhance and shape meaning” of an opinionated expository essay. In my list, I recognized that the structure of the essay changes depending on the wanted impact on the reader, as well as that the placement of certain points can change the ‘take away’ of a reader.

“Express and support an opinion with evidence”:

I included in my list that one should “make sure that your argument is supported by details from credible sources” as well as “include facts from scientific studies, or other opinions on the topic to create the impression that the argument is valid and has solid proof behind it.” In addition, my list includes that your opinion should be expressed clearly so that the reader knows where you stand regarding the topic.

“Assess and refine texts to improve clarity and impact”:

Since the entire point of my project was to understand how writing persuasively changes and “improves clarity and impact”, my list includes many points that clearly display how to change the impact of a text.

5. What resources did you find useful during your inquiry and why were they useful? (Cite at least four resources you consulted, with links, and write a brief 50-100 response as to was important to your learning).

https://www.ukessays.com/essays/psychology/influence-the-psychology-of-persuasion-psychology-essay.php:

This one resource I found around halfway through the inquiry process contributed to my list greatly, as it not only told the reader tips on persuasive writing, but actively used them in it’s own writing.

https://www.psychologytoday.com/ca/blog/201212/the-6-principles-persuasion

This was the first article I found regarding the “6 principles of persuasion”, and ended up being a main pillar that I based my work around, and connected much of my other research to these 6 principles.

Chapter 10. Persuasion

When I found this website before proposing the project, I did not understand it as much as I do now, but it influenced my decision to make a list as a final product. As the project progressed, I understood more of what the methods implied and was able to compile a large portion of my information from here.

https://writtent.com/blog/17-powerful-persuasive-writing-techniques/

This article helped me get off the ground at first, as it contained straightforward information that made sense, and connected some of the writing tips to other psychological research I had found.

6. What new questions do you have about your inquiry? What motivates you or excites you about these questions?

Going through this inquiry makes me wonder about the psychological impacts that go into what I initially wanted to do, which was look at how to be more persuasive in verbal form rather than in writing. Though I would want to move into that right away, I understand that learning takes time, and would feel a bit uncomfortable going straight into learning how to debate. Instead, a much more intriguing question would be “what are the differences in the psychological techniques between writing and speaking persuasively.” Since I want to eventually strengthen my public speaking skills, I want to be able to transition through a middle ground question, and in the future, become confident in my skills.

By

In-Depth Blog Post #1: A New Beginning

I have loved to play games all my life. From my first DS, to the games I play now, I have always wondered how they are made. So, for this year’s In-Depth project, I want to learn how to code a simple mobile game using JavaScript.

Ever since I picked up the DS that I got for Christmas years ago, gaming has been a major part of my life. However, I took them for granted much of the time, not realizing how much time and effort is poured into each and every game I have seen, played, and enjoyed. The main reason for doing this project is to experience the workload of creating a functional game firsthand, and to then be able to appreciate what game designers and coders do. By specifically pursuing 2D Android games, I will be able to understand the type of work that goes into these games, without being too hard for me. In addition, the games will need to use assets to function as a game, and since I cannot take images, sounds or music from the internet, I will make my own, making this a project to additionally strengthen my drawing skills, composition skills, and most importantly, my creativity. The final reason I want to code games is for myself, and my friends. I want to be able to not only code a game one time to enjoy for myself and others, but many times, reapplying the skills I have learned from this experience to have fun! So, my reasons for wanting to do this project are to learn a new skill/coding language, build an appreciation for the effort it takes to develop apps and games, as well as hone my art, music, and creativity, all while having something to take pride in.

At the time I am writing this blog post, I have a mentor, who has worked at a coding studio. He has plenty of experience with JavaScript, (the language I am learning) and is currently retired but still loves coding as a hobby. We have already met twice, and he has given me a basic overview of what I will be doing, as well as all the programs I will need on my computer to code, so I am all ready to start coding!

In-Depth looks promising this year, and I am excited to get back into one of the highlights of TALONS! Let’s jump right into it!

By

ZIP Journal #3

Question: What makes a good persuasive essay?

Take a moment to reflect on your inquiry plan. Do you need to make any revisions to your original plan? If so, why?

After receiving my expository essay with feedback on it, I have decided to analyze it for some of the persuasive writing techniques I have found. This will however, set back my initial plan to begin writing by a few days. So, I will work on this in place of part of “researching essay topic”, and analyze my essay for two days, then go back to researching the topic. I will also be changing my final learning artifact to something similar to last year’s ZIP project. Instead of writing an essay, I will be creating a compiled list of these tips, with a sentence to a paragraph under each tip to exemplify my learning. At the end of the tips I will also write a smaller text instead of an essay. The reason for these changes is because reading over a past recent work will allow me to find the areas I have used each writing tip, as well as work on the ones that I do not see within the essay.

By

ZIP Journal #2

Question: What makes a good persuasive essay?

What is one specific source of information that you have found valuable in your inquiry question? How has it proved valuable?

Source: https://www.ukessays.com/essays/psychology/influence-the-psychology-of-persuasion-psychology-essay.php

The essay I found online in the above link is very helpful, as it not only explains the concepts that I am trying to learn, but also uses them in the writing. Additionally, it uses the PQS format clearly, and uses clear examples to explain each principle. The essay also contains information specifically on the use of persuasion in persuasive essays, which is exactly what I have been looking for in a source. After writing this, I will be going back to my expository essay to look for some of the principles that I now know.

The source has proved to valuable as a concrete structure for PQS, as well as how to organize an essay with more than 3 body paragraphs. The essay exemplifies how to transition from one body paragraph to the next, and makes the reader think that the author of the essay is correct, meaning they used the principle of authority. Though the language is slightly colloquial, the essay in general contains useful information, compiled into one clear source.

By

ZIP Journal #1

Question: What makes a good persuasive essay?

Record a journal entry of how you used one of our in-class focus blocks. What did you accomplish during this time? What did you struggle with? What might be your next step in you next focus block? Set a goal.

In the time of the first two blocks of ZIP, I have begun to research my topic, and have just scratched the surface of what i intend to research. So far, I have found some psychological principals that generally apply to face to face conversations, however, some, if not most, can be applied to essay writing, specifically, persuasive essay writing.

On the first day, I mainly looked for articles that explain the psychology behind being convincing, and found a couple of articles that gave general tips on how to convince others. After noting down the tips that seemed like they could apply to persuasive writing, I compared them to what I could find on how to improve persuasive writing.

Next focus block, I plan to look back on some past persuasive essays that I can find on my computer, or sample essays on the internet, and look for traces of what I found in my research.

Notes:

6 Principles of Persuasion

Authority, Likability, Reciprocity, Consistency, Consensus, Scarcity

2 of the six seem to apply to writing at first glance.

Authority may come from writing in an authoritative way, or including qualifications in the writing.

Consistency requires knowing the other person and making them agree by assimilating their prior views on the topic.

Consensus uses the power of social influence to convince people to agree and ‘fit in’.

How to write more persuasively

Understand who the writing is for. (Consistency) Research the topic using multiple (Consensus) credible (Authority) sources.

Write the hook and thesis clearly so that the reader believes that your view is credible. (Authority)

Support your claims with quotes, statistics, and evidence. (Authority/Consensus)


Sources:

https://www.psychologytoday.com/ca/blog/201212/the-6-principles-persuasion

https://writtent.com/blog/17-powerful-persuasive-writing-techniques/

https://writtent.com/blog/9-sure-fire-copywriting-formulas-grow-audience/

 

 

By

ZIP Proposal

This year for ZIP, I wanted to continue with my question from last year which was “what are things to look for in writing that make the piece more concise?”, but also wanted to cover more ground to further improve my writing skills. Since we just covered writing expository essays, I wanted to write a persuasive essay. However, that seemed a bit too plain, so I will be delving deeper into the psychological aspect of persuasive writing. My question this year is “what makes a good persuasive essay?”. In this inquiry process, I will be looking closer at how our minds are changed, and how I can improve my ability to make an argument that is convincing, clear and concise. Since I struggle with being convincing and making a good argument, I thought that applying it to my writing would help me learn more on how I can improve my public speaking.

As mentioned before, I find that it is hard for me to make a clear statement and back it up with evidence, so my knowledge of this topic is very simple and basic. I do not know any elements or strategies used in a good argument. However, I do find that organizing my writing into clear and concise paragraphs is easier for me to comprehend. By making my inquiry writing based, it will be easier for me to understand how to be more persuasive. Conveniently, persuasive essays are made for persuading, and will help me understand the concepts I want to learn.

Last year, quite a few people did questions related to my current inquiry, including how advertising works. Those people may be very helpful as I can take some information from there to apply to my own project. Additionally, since I am writing an essay, I can have other people read and suggest edits to the work. To learn how to write persuasively, I can also turn to some textbooks on how to write persuasive essays, but also can use the internet as a resource for samples of essays, learning how to write them, as well as finding psychological techniques to make my writing better.

To show my learning, I am going to be writing a persuasive essay on a chosen topic. Before giving the viewer the essay, I will ask their opinion on the topic, then as them to read over the essay. Then I will ask if their minds were changed in any way. I will also be displaying a list of some of the tactics I have learned and applied to the writing piece. Hopefully, I will change their view of the topic in some way, meaning that I have been successful in my research.

Schedule:

Jan 1st – 14th: Research Persuasive Essay Writing

Jan 15th – 20th: Research Essay Topic and Draft

Jan 21st – 27th: Write Essay

Jan 28th or 29th: Present!

By

A Wizard of EarthSea Style Analysis

Question: What stood out about Le Guin’s overall writing style in chapter 1 of this novel?

When reading Ursula Le Guin’s A Wizard of EarthSea, the things that stood out most to me were the direct-to-the-point writing style, the slightly passive nature of her choice to write in the 3rd person, as well as the descriptions in her writing. When reading the first chapter of this book, the reader is presented with a direct summary of the person that the main character will become, as well as where he started. She tells us the story through direct points in Duny’s life that matter to the story, leaving out details that would not add to the story or character. Le Guin also tells us the story using essay-like language that transitions into a very fantasy-writing-type sentence, such as “This was Duny’s first step on the way he was to follow all his life, the way of magery, the way that led him at last to hunt a shadow over land and sea to the lightless coasts of death’s kingdom.” pg. 5. The first bit to that quote seems like something out a book review, but the middle to the end of the sentence becomes mystical and much more descriptive than expected. This type of sentence structure is used a couple of times throughout the first chapter, creating a mysterious feeling that engages the reader into wanting to know more, as well as reinforcing the 3rd person point of view that Le Guin writes in. Her third person point of view’s writing, as mentioned before, is written like an essay, using language such as ‘this’, ‘as’ and ‘when’ to start sentences. The outstanding part of using the essay-like language is how Le Guin then adds in description unexpectedly, seen when “Some of the band stopped when they felt the land grow rough underfoot, but others pressed right on, seeking the phantom village, following dim wavering shapes that fled just out of reach before them.” pg.13. This sentence seems like it would be a short sentence with not much description, ending at the first comma, but gives us a vivid picture in our heads of what is happening in the novel. Frequent but not overused usage of the unexpected descriptions allows the reader to see what is happening in the world, without knowing every detail. This contributes to the mystical sense that the writing gives us. Overall, Le Guin’s novel takes advantage of being direct, writing in the 3rd person and giving good descriptions to stand out from other fantasy novels.

By

A Wizard of EarthSea Anticipation Blog Post

Statement: It is possible to hide from the consequences of bad decisions.

It is not possible to evade repercussions of bad decisions. This is because the memory that you now have of the bad decision is now present, being a direct consequence of the decision. Since the memory is present, and you recognize that the decision was bad, you now have a negative consequence of a bad decision in the form of guilt. In most cases, a bad decision will also come back to haunt a person in not only a mental form, but also a physical form. This may manifest itself as other people being negatively impacted physically or mentally, such as if you made a decision to steal something, where the person stolen from has lost a physical item, or may feel sad about losing something precious. This is a direct consequence, and though you may be unaffected my the initial consequence, one bad action may lead to another in retaliation. Even though the consequence is not direct, and may not occur, it is still likely that the indirect consequence will affect you in some way. The fact that you have recognized a bad decision in the form of guilt, and that others may retaliate, it is near impossible to escape a bad decision.

css.php