Coder Social home page Coder Social logo

csc340finalproject's Introduction

CSC340FinalProject

Final project for CSC 340 (software engineering)

Important!!!

Remember that the engine is still being added and worked on, so do a pull request frequently. Do one before you start writing code, do one before you make a commmit, and before you push. Always!

Adding a new Hero

  • Create a new class in Entities/Hero
  • Make it extend Hero
  • make sure it's main sprite is called "main"
  • start adding your own features!

Example:

public class Knight extends Hero {
  public Knight() {
    super(); // make sure this is here!!
    // seems complicated but its really not! Just copy and paste this, 
    // but change "pathToSprite.png" to the sprite sheet you want to use. Look in assets/
    this.sprites.addAnimtion("main", new Animation("pathToSprite.png", 3, 150, 32)); 
    
    // now you can set the rest of the Hero's properties here!
    // look in the Hero class and Entity class to look at what you can change
  }
  
  public void update() {
    super.update(); // always have this too!
    // this method is called 60 times per second, all extra functionality or abilities you want to add goes here!
  }
  
  public void draw() {
    super.draw(); // always have this too!
    // add anything extra you want to draw around your player too
    // player location is found by getPosition() for a bounding rectangle of the player,
    // or getPosition().getLocation() for a Point object of the location.
  }
  
}

Testing what you added

So you created your own Hero and want to see it in action, here is how:

  • Create a new class in GameSates/TestStates
  • Make it extend MapState
  • MapState has three constructors, choose to implement the constructor with one argument
  • the first line in the constructor should be "super(manager, "level") where level is the map you want to load
  • Create your hero and run a launcher to start your code

I know that is a lot so here is an example:

package GameStates.TestStates;

import Entities.Hero;
import Entities.Heroes.Wizard;
import GameStates.GameStateManager;
import GameStates.MapState;
import Handlers.GameLauncher;

public class SomeLevel extends MapState {
    public static void main(String[] args) {
      // this is code to start your game 
        GameLauncher launcher = new GameLauncher();
        
        // starts the game with your level
        launcher.startGame(new SomeLevel(launcher.getManager()));
    }
    
    public SomeLevel(GameStateManager manger) {
        super(manger, "icelevel");
        // or new Knight();, whatever you created
        player = new Wizard();
        
        // make sure to remember this
        getSpawn();
        // if you want enemies, add this line of code too, most maps have enemies in them
        spawnEnemies();
    }
    public void update(){
        super.update();
        // any other logic you want to add for the level as a whole goes here
    }
    public void draw(Graphics2D g) {
        super.draw(g);
        
        // anything more you want to draw goes here.
        
    }
}

This code is the game just for reference. You can also look at the Wizard class to see how custom actions can be implemented. With this alone you can see your work on the screen! Just make sure you right click your code, then click "run file" to run this main method.

All of the assets are in a folder called assets. So look in there for sprites and maps.

Any questions just email me and I'll help!

csc340finalproject's People

Contributors

spokenbanana avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.