com.blockwithme.hacktors.Main.java Source code

Java tutorial

Introduction

Here is the source code for com.blockwithme.hacktors.Main.java

Source

/*
 * Copyright (C) 2013 Sebastien Diot.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.blockwithme.hacktors;

import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

/**
 * The main class.
 *
 * @author monster
 */
public class Main implements BundleActivator {
    /**
     *
     */
    private static void start() {
        final World world = new World();
        final PlayerConsole console = new PlayerConsole(world);
        final PlayerMobileController controller = new PlayerMobileController(console);
        final Mobile avatar = Mobile.create(controller, MobileType.Human);
        avatar.addItem(Item.create(ItemType.Sword));
        avatar.addItem(Item.create(ItemType.DogEgg));
        avatar.addItem(Item.create(ItemType.Meat));
        avatar.addItem(Item.create(ItemType.Iron));
        final Level level = world.getOrCreateLevel(0);
        final int x = World.X / 2;
        final int y = World.Y / 2;
        final Chunk chunk = level.getOrCreateChunkOf(x, y);
        chunk.setBlock(x, y, Block.EMPTY);
        chunk.setMobile(x, y, avatar);
        controller.setMobile(avatar);
        world.getClock().start();
        System.exit(0);
    }

    /** Starts the game. */
    public static void main(final String[] args) {
        start();
    }

    /** {@inheritDoc} */
    @Override
    public void start(final BundleContext context) throws Exception {
        start();
        LogFactory.getLog(Main.class).info(" **************start(final BundleContext context)****************");
    }

    /** {@inheritDoc} */
    @Override
    public void stop(final BundleContext context) throws Exception {
        // TODO Auto-generated method stub

    }
}