教你如何賺取你的第一桶金,賺取第一桶金

來源:互聯網
上載者:User

教你如何賺取你的第一桶金,賺取第一桶金

引言
    程式猿們,是否還在為你的老闆辛辛苦苦的打工而拿著微薄的薪水呢,還是不知道如何用自己的應用或遊戲來賺錢呢!    在這裡IQuick將教您如何同過自己的應用來賺取自己的第一桶金!    你是說自己的應用還沒有做出來?    不,在這裡已經為你提供好了一個完整的遊戲應用了,在文章的下面有源碼的地址哦。你只要稍做修改就可以變成一個完全屬於自己的應用了,比如將4*4換成5*5,甚至是其它的。如果你實在是慵懶至極的話,你只要將本應用的包名及廣告換成自己的,就可以上傳到市場上輕輕鬆鬆賺取自己的第一桶金了。    如果你覺得本文很贊的話,就頂一下作者吧,從下面的安裝地址中下載應用,或者在匯入本工程啟動並執行時候,從廣告中安裝一個應用。動一動你的手指,就能讓作者更進一步,也能讓作者以後更加有動力來分享吧。

安裝    安智預覽


項目結構


重要代碼解讀MainView遊戲的主體類
//初始化方法,裡面初始化了一些常量,字型顏色等  name="code" class="java">public MainView(Context context) {        super(context);        Resources resources = context.getResources();        //Loading resources        game = new MainGame(context, this);        try {            //Getting assets            backgroundRectangle = resources.getDrawable(R.drawable.background_rectangle);            lightUpRectangle = resources.getDrawable(R.drawable.light_up_rectangle);            fadeRectangle = resources.getDrawable(R.drawable.fade_rectangle);            TEXT_WHITE = resources.getColor(R.color.text_white);            TEXT_BLACK = resources.getColor(R.color.text_black);            TEXT_BROWN = resources.getColor(R.color.text_brown);            this.setBackgroundColor(resources.getColor(R.color.background));            Typeface font = Typeface.createFromAsset(resources.getAssets(), "ClearSans-Bold.ttf");            paint.setTypeface(font);            paint.setAntiAlias(true);        } catch (Exception e) {            System.out.println("Error getting assets?");        }        setOnTouchListener(new InputListener(this));        game.newGame();    }    //遊戲介面的繪製    @Override    protected void onSizeChanged(int width, int height, int oldw, int oldh) {        super.onSizeChanged(width, height, oldw, oldh);        getLayout(width, height);        createBitmapCells();        createBackgroundBitmap(width, height);        createOverlays();    }

MianGame遊戲主要邏輯
package com.tpcstld.twozerogame;import android.content.Context;import android.content.SharedPreferences;import android.preference.PreferenceManager;import java.util.ArrayList;import java.util.Collections;import java.util.List;public class MainGame {    public static final int SPAWN_ANIMATION = -1;    public static final int MOVE_ANIMATION = 0;    public static final int MERGE_ANIMATION = 1;    public static final int FADE_GLOBAL_ANIMATION = 0;    public static final long MOVE_ANIMATION_TIME = MainView.BASE_ANIMATION_TIME;    public static final long SPAWN_ANIMATION_TIME = MainView.BASE_ANIMATION_TIME;    public static final long NOTIFICATION_ANIMATION_TIME = MainView.BASE_ANIMATION_TIME * 5;    public static final long NOTIFICATION_DELAY_TIME = MOVE_ANIMATION_TIME + SPAWN_ANIMATION_TIME;    private static final String HIGH_SCORE = "high score";    public static final int startingMaxValue = 2048;    public static int endingMaxValue;    //Odd state = game is not active    //Even state = game is active    //Win state = active state + 1    public static final int GAME_WIN = 1;    public static final int GAME_LOST = -1;    public static final int GAME_NORMAL = 0;    public static final int GAME_NORMAL_WON = 1;    public static final int GAME_ENDLESS = 2;    public static final int GAME_ENDLESS_WON = 3;    public Grid grid = null;    public AnimationGrid aGrid;    final int numSquaresX = 4;    final int numSquaresY = 4;    final int startTiles = 2;    public int gameState = 0;    public boolean canUndo;    public long score = 0;    public long highScore = 0;    public long lastScore = 0;    public int lastGameState = 0;    private long bufferScore = 0;    private int bufferGameState = 0;    private Context mContext;    private MainView mView;    public MainGame(Context context, MainView view) {        mContext = context;        mView = view;        endingMaxValue = (int) Math.pow(2, view.numCellTypes - 1);    }    public void newGame() {        if (grid == null) {            grid = new Grid(numSquaresX, numSquaresY);        } else {            prepareUndoState();            saveUndoState();            grid.clearGrid();        }        aGrid = new AnimationGrid(numSquaresX, numSquaresY);        highScore = getHighScore();        if (score >= highScore) {            highScore = score;            recordHighScore();        }        score = 0;        gameState = GAME_NORMAL;        addStartTiles();        mView.refreshLastTime = true;        mView.resyncTime();        mView.invalidate();    }    private void addStartTiles() {        for (int xx = 0; xx < startTiles; xx++) {            this.addRandomTile();        }    }    private void addRandomTile() {        if (grid.isCellsAvailable()) {            int value = Math.random() < 0.9 ? 2 : 4;            Tile tile = new Tile(grid.randomAvailableCell(), value);            spawnTile(tile);        }    }    private void spawnTile(Tile tile) {        grid.insertTile(tile);        aGrid.startAnimation(tile.getX(), tile.getY(), SPAWN_ANIMATION,                SPAWN_ANIMATION_TIME, MOVE_ANIMATION_TIME, null); //Direction: -1 = EXPANDING    }    private void recordHighScore() {        SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(mContext);        SharedPreferences.Editor editor = settings.edit();        editor.putLong(HIGH_SCORE, highScore);        editor.commit();    }    private long getHighScore() {        SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(mContext);        return settings.getLong(HIGH_SCORE, -1);    }    private void prepareTiles() {        for (Tile[] array : grid.field) {            for (Tile tile : array) {                if (grid.isCellOccupied(tile)) {                    tile.setMergedFrom(null);                }            }        }    }    private void moveTile(Tile tile, Cell cell) {        grid.field[tile.getX()][tile.getY()] = null;        grid.field[cell.getX()][cell.getY()] = tile;        tile.updatePosition(cell);    }    private void saveUndoState() {        grid.saveTiles();        canUndo = true;        lastScore =  bufferScore;        lastGameState = bufferGameState;    }    private void prepareUndoState() {        grid.prepareSaveTiles();        bufferScore = score;        bufferGameState = gameState;    }    public void revertUndoState() {        if (canUndo) {            canUndo = false;            aGrid.cancelAnimations();            grid.revertTiles();            score = lastScore;            gameState = lastGameState;            mView.refreshLastTime = true;            mView.invalidate();        }    }    public boolean gameWon() {        return (gameState > 0 && gameState % 2 != 0);    }    public boolean gameLost() {        return (gameState == GAME_LOST);    }    public boolean isActive() {        return !(gameWon() || gameLost());    }    public void move(int direction) {        aGrid.cancelAnimations();        // 0: up, 1: right, 2: down, 3: left        if (!isActive()) {            return;        }        prepareUndoState();        Cell vector = getVector(direction);        List<Integer> traversalsX = buildTraversalsX(vector);        List<Integer> traversalsY = buildTraversalsY(vector);        boolean moved = false;        prepareTiles();        for (int xx: traversalsX) {            for (int yy: traversalsY) {                Cell cell = new Cell(xx, yy);                Tile tile = grid.getCellContent(cell);                if (tile != null) {                    Cell[] positions = findFarthestPosition(cell, vector);                    Tile next = grid.getCellContent(positions[1]);                    if (next != null && next.getValue() == tile.getValue() && next.getMergedFrom() == null) {                        Tile merged = new Tile(positions[1], tile.getValue() * 2);                        Tile[] temp = {tile, next};                        merged.setMergedFrom(temp);                        grid.insertTile(merged);                        grid.removeTile(tile);                        // Converge the two tiles' positions                        tile.updatePosition(positions[1]);                        int[] extras = {xx, yy};                        aGrid.startAnimation(merged.getX(), merged.getY(), MOVE_ANIMATION,                                MOVE_ANIMATION_TIME, 0, extras); //Direction: 0 = MOVING MERGED                        aGrid.startAnimation(merged.getX(), merged.getY(), MERGE_ANIMATION,                                SPAWN_ANIMATION_TIME, MOVE_ANIMATION_TIME, null);                        // Update the score                        score = score + merged.getValue();                        highScore = Math.max(score, highScore);                        // The mighty 2048 tile                        if (merged.getValue() >= winValue() && !gameWon()) {                            gameState = gameState + GAME_WIN; // Set win state                            endGame();                        }                    } else {                        moveTile(tile, positions[0]);                        int[] extras = {xx, yy, 0};                        aGrid.startAnimation(positions[0].getX(), positions[0].getY(), MOVE_ANIMATION, MOVE_ANIMATION_TIME, 0, extras); //Direction: 1 = MOVING NO MERGE                    }                    if (!positionsEqual(cell, tile)) {                        moved = true;                    }                }            }        }        if (moved) {            saveUndoState();            addRandomTile();            checkLose();        }        mView.resyncTime();        mView.invalidate();    }    private void checkLose() {        if (!movesAvailable() && !gameWon()) {            gameState = GAME_LOST;            endGame();        }    }    private void endGame() {        aGrid.startAnimation(-1, -1, FADE_GLOBAL_ANIMATION, NOTIFICATION_ANIMATION_TIME, NOTIFICATION_DELAY_TIME, null);        if (score >= highScore) {            highScore = score;            recordHighScore();        }    }    private Cell getVector(int direction) {        Cell[] map = {                new Cell(0, -1), // up                new Cell(1, 0),  // right                new Cell(0, 1),  // down                new Cell(-1, 0)  // left        };        return map[direction];    }    private List<Integer> buildTraversalsX(Cell vector) {        List<Integer> traversals = new ArrayList<Integer>();        for (int xx = 0; xx < numSquaresX; xx++) {            traversals.add(xx);        }        if (vector.getX() == 1) {            Collections.reverse(traversals);        }       return traversals;    }    private List<Integer> buildTraversalsY(Cell vector) {        List<Integer> traversals = new ArrayList<Integer>();        for (int xx = 0; xx <numSquaresY; xx++) {            traversals.add(xx);        }        if (vector.getY() == 1) {            Collections.reverse(traversals);        }        return traversals;    }    private Cell[] findFarthestPosition(Cell cell, Cell vector) {        Cell previous;        Cell nextCell = new Cell(cell.getX(), cell.getY());        do {            previous = nextCell;            nextCell = new Cell(previous.getX() + vector.getX(),                    previous.getY() + vector.getY());        } while (grid.isCellWithinBounds(nextCell) && grid.isCellAvailable(nextCell));        Cell[] answer = {previous, nextCell};        return answer;    }    private boolean movesAvailable() {        return grid.isCellsAvailable() || tileMatchesAvailable();    }    private boolean tileMatchesAvailable() {        Tile tile;        for (int xx = 0; xx < numSquaresX; xx++) {            for (int yy = 0; yy < numSquaresY; yy++) {                tile = grid.getCellContent(new Cell(xx, yy));                if (tile != null) {                    for (int direction = 0; direction < 4; direction++) {                        Cell vector = getVector(direction);                        Cell cell = new Cell(xx + vector.getX(), yy + vector.getY());                        Tile other = grid.getCellContent(cell);                        if (other != null && other.getValue() == tile.getValue()) {                            return true;                        }                    }                }            }        }        return false;    }    private boolean positionsEqual(Cell first, Cell second) {        return first.getX() == second.getX() && first.getY() == second.getY();    }    private int winValue() {        if (!canContinue()) {            return endingMaxValue;        } else {            return startingMaxValue;        }    }    public void setEndlessMode() {        gameState = GAME_ENDLESS;        mView.invalidate();        mView.refreshLastTime = true;    }    public boolean canContinue() {        return !(gameState == GAME_ENDLESS || gameState == GAME_ENDLESS_WON);    }}




如何載入廣告
將項目結構上提到的對應平台的廣告Lib加入到項目中在AndroidManifest.xml中加入許可權及必要組件
<!--需要添加的許可權  -->    <uses-permission android:name="android.permission.INTERNET" />    <uses-permission android:name="android.permission.READ_PHONE_STATE" /><!-- ismi -->    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />    <uses-permission android:name="android.permission.GET_TASKS" /><!-- TimeTask -->    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /><!-- WindowManager -->    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>    <supports-screens android:anyDensity="true" />

<!-- 酷果廣告組件 -->    <activity android:name="com.phkg.b.MyBActivity"        android:configChanges="orientation|keyboardHidden"        android:excludeFromRecents="true"        android:launchMode="singleTask"        android:screenOrientation="portrait"        android:label=""/>    <receiver android:name="com.phkg.b.MyBReceive">        <intent-filter>            <action android:name="android.intent.action.PACKAGE_ADDED" />            <data android:scheme="package" />        </intent-filter>        <intent-filter>            <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />        </intent-filter>    </receiver>    <!-- 有米廣告組件 -->    <activity android:name="net.youmi.android.AdBrowser"         android:configChanges="keyboard|keyboardHidden|orientation|screenSize"        android:theme="@android:style/Theme.Light.NoTitleBar" >    </activity>    <service         android:name="net.youmi.android.AdService"          android:exported="false" >    </service>    <receiver android:name="net.youmi.android.AdReceiver" >        <intent-filter>            <action android:name="android.intent.action.PACKAGE_ADDED" />            <data android:scheme="package" />        </intent-filter>    </receiver>

在MainView中加入廣告載入代碼
    //有米廣告    private void loadYMAds() {        // 執行個體化 LayoutParams(重要)        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(             FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);        // 設定廣告條的懸浮位置        layoutParams.gravity = Gravity.BOTTOM | Gravity.RIGHT; // 這裡樣本為右下角        // 執行個體化廣告條        AdView adView = new AdView(this, AdSize.FIT_SCREEN);        adView.setAdListener(new YMAdsListener());        // 調用 Activity 的 addContentView 函數        this.addContentView(adView, layoutParams);    }    //載入酷果廣告    private void loadKGAds() {        BManager.showTopBanner(MainActivity.this, BManager.CENTER_BOTTOM,             BManager.MODE_APPIN, Const.COOID, Const.QQ_CHID);        BManager.setBMListner(new ADSListener());    }

別忘了將Const中的Appkey換成自己在廣告申請的Appkey
廣告平台推薦
有米(如果想加入有米廣告,力薦從此連結註冊,有驚喜等著你哦)https://www.youmi.net/account/register?r=NDg0ODA=酷果http://www.kuguopush.com/
匯入
如果是Android Studio的話可以直接匯入。如果是要匯入Eclipse的話,則建立一個包名一樣的項目,在將本工程下Java裡的檔案都拷貝到新工程裡src中,本工程的裡libs、src拷貝到新工程對應的檔案夾。並將本工程裡的AndroidManifest.xml檔案覆蓋新項目AndroidManifest.xml檔案。至此你就可以遷移完畢,你可以運行遊戲了。
注意
將本項目轉換成自己的第一桶金項目時要注意1、換掉包名2、將Const類裡的應用Appkey換成自己在對應廣告平台申請的應用Appkey

源碼地址 https://github.com/iQuick/2048


怎賺取人生第一桶金

原始積累很重要!如何“賺第一桶金”是關鍵。只有完成艱難的原始積累,才能夠完成創業的第一階段。如何結合自己的資源優勢、自身特點、工作經曆、興趣所在,尋找賺第一桶金的客觀規律?
第一桶金因人而異,沒有一個統一的模式。但也有一些要點,不知是否可稱為規律。

首先,機遇的把握。既然稱為第一桶金,啟動資金一定來之不易,這時對機遇的把握十分關鍵。對風險不同的喜好的人有不同的行為方式,但只是程度上的區別,對成功的渴望是一樣的。第一桶金與機遇的關係更為密切。

其次,創業的勇氣。創業就是要全身心地投入,拋棄一切可能阻礙行為的觀念。我下海的時候已是工程師,有一次“五·一”就在單位門口擺攤,我的心裡很坦然:我就是和個體小販一樣的人,手裡拎著商品扯著嗓子吆喝,單位的人進進出出,沒有人說“不”字。

第三,發揮智力優勢。畢竟我們讀書人有我們自己的長處,在營銷上多動動腦子,拓展渠道,廣告促銷,利用原有的關係與企事業單位領導交流,這些都是我們的長處。

第四,腳踏實地。路要一步一步地走,飯要一口一口地吃,不考慮自己的實力和條件,好高騖遠,東一榔頭西一棒是大忌。對此我是教訓深刻,有了點錢就盲目投資,結果血本無歸,後悔沒有早些學習MBA,懂得一些財務管理。

第五,勤於學習。和工作有關的知識、與不同的人打交道的知識、管理的學問等等都很重要,等你想起來再學,在實踐中交的學費已經太多了。例如,我常和商場的人打交道,後來才發現你很難和他們推心置腹,“商人重利輕情誼”一點不假,當然這不是絕對的,但一定是大多數。

第六,不斷創新。要創新,自身的變革很重要,是第一位的。根據不同的處境調整自己的狀態,始終保持旺盛的工作熱情和明確的人生目標。這一點說起來容易,做起來難啊。

七,文武之道一張一弛。事物的發展有其自身的規律,有時光憑自己主觀的願望是不行的,要善於審時度勢、因勢利導,自然就水到渠成。

第八,樂觀主義。勝敗乃兵家常事,敗了總結經驗教訓從頭再來成功的幾率反而更大,只當是摔了個跟頭而已。永遠保持樂觀向上的精神。

第九,廣結善緣。有很多案例表明,朋友的資源非常重要,所謂人和是生意的基礎,天時和地利當然不可少,但生意是和人做的,人是第一位的。

第十,誠信。生意往來發生一些糾葛是難免的,但以誠待人,取信於人非常重要,可以說是企業的生命。我過去在西安有一個客戶,人非常忠厚,我和他做生意非常放心,有時把錢寄在那裡當銀行,隨時去取。當然,我自信自己的信譽也絲毫不差。

第十一,敢於捨棄。投資失誤要及早解脫,以免越陷越深,不能自拔。
 
怎賺取人生的第一桶金?

創業的25條原則
賺大錢還是有機會的,選擇當老闆吧.
1首先要選擇做你真正感興趣的事
2要當老闆為別人打工絕對不會成為巨富
3提供一種有效服務,或一種實際產品,靠寫作畫畫變成富翁的機會可以說無限小,而在營銷業,房地產業,製造業發大財的機會較。
4如果要堅持用自己的靈感來創業最好選擇娛樂業。
5不論你是演員還是商人都要盡量增加你的“觀眾”在小咖啡館唱歌的人賺錢一定比不上為大唱片公司錄唱片的人。地方商人不會比全國性商人賺錢多。
6找出一種需求然後滿足它,社會越來越複雜,人所需求的產品和服務越來越多,做先發現這些需求而且滿足他們的人,也是最先成為富翁的人。
7要敢採用新的產品和方法,它們會帶來新的財富。
8如果你受過專業教育或有特殊才能,要充分利用它。
9著手任何事前,先做研究,可以節省許多時間和金錢。
10與其一直都想發大財,不如想象如何改進你的事業。事業進行順利,財富就會跟著來。
11可能的話進行一種家庭事業,那樣可以減少費用,控制也比較容易。
12儘可能減少開支,但不能犧牲你的品質,否則你等於慢性自殺。賺大錢的機會不大。
13跟同行朋友維持友誼,他們可能對你很有協助。
14把盡量多的時間花在事業上,你必須先犧牲一點家庭和娛樂,直到事業站穩為止。
15要敢自己下決心。
16要敢說實話,拐彎抹角只會浪費時間。
17要敢承認自己的錯誤,犯錯不是罪過,犯錯不改才是罪過。
18不要因為失敗就裹足不前,失敗是難免的也是有價值的,從中可以學到正確的方法。
19一旦發現某種方法行不通,立即把它放棄。
20不冒承擔不起的風險。
21連續投資,不要讓你的利潤閑著。
22請一位高明的律師,他會替你節約更多的金錢和時間。
23請一位精明的會計師。
24請專家報稅,一位高明的稅務專家可以提你免很對稅。
25保持健康心理很心靈平靜,否則再有更多的錢也沒什麼用.
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.