Lecture 6: Basic Entities TEALS MINECRAFT PROJECT.

Slides:



Advertisements
Similar presentations
Computer Science 320 Clumping in Parallel Java. Sequential vs Parallel Program Initial setup Execute the computation Clean up Initial setup Create a parallel.
Advertisements

OO Programming in Java Objectives for today: Overriding the toString() method Polymorphism & Dynamic Binding Interfaces Packages and Class Path.
Practice Session 7 Synchronization Liveness Deadlock Starvation Livelock Guarded Methods Model Thread Timing Busy Wait Sleep and Check Wait and Notify.
Fields, Constructors, Methods
Multithreaded Programs in Java. Tasks and Threads A task is an abstraction of a series of steps – Might be done in a separate thread – Java libraries.
Introduction to Object-Oriented Programming CS 21a: Introduction to Computing I First Semester,
Road Map Introduction to object oriented programming. Classes
Loops We have been using loops since week 2, our void draw(){ } is a loop A few drawbacks of draw() –It is endless –There is only one draw() –It updates.
Copyright 2010 by Pearson Education 1 Assignment 11: Critters.
“is a”  Define a new class DerivedClass which extends BaseClass class BaseClass { // class contents } class DerivedClass : BaseClass { // class.
VIDEO GAME PROGRAMMING Video Game Programming Junior – DigiPutt INSTRUCTOR TEACHER’S ASSISTANT.
Copyright © 2015 – Curt Hill Minecraft Blocks Properties and Methods.
EEC-693/793 Applied Computer Vision with Depth Cameras Lecture 13 Wenbing Zhao
Introduction to Object-Oriented Programming
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Threading Eriq Muhammad Adams J
Game Maker Terminology
1 ball, 2 ball, red ball, blue ball By Melissa Dalis Professor Susan Rodger Duke University June 2011.
“The perfect project plan is possible if one first documents a list of all the unknowns.” Bill Langley.
Conditions and loops Day 4 Computer Programming through Robotics CPST 410 Summer 2009.
Design of Bio-Medical Virtual Instrumentation Tutorial 2.
© Glenn Rowe AC Lab 3 An adventure game.
Data Structure for Behavior-Based Machine Learning/Path Planning Zachary Dawson A: Humanoids 5/7/13.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops Susan Rodger Duke University July 2011.
Java Thread and Memory Model
AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate.
Computer Game Design ActionScript is… Object-oriented programming Everything you do in ActionScript does something to some object* Some objects.
Animation in Minecraft Movement within Movement Copyright © 2015 – Curt Hill.
Lesson 2: Reading a program. Remember: from yesterday We learned about… Precise language is needed to program Actors and Classes Methods – step by step.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Hacking Minecraft on the Raspberry Pi using Python
CHAPTER 14 Classes, Objects, and Games XNA Game Studio 4.0.
Inheritance Type/Subtype Relationship. Inheritance Idea: An object B of one type, termed child class, inherits from another object A of another type,
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
Classes, Interfaces and Packages
1 / 71 COP 3503 FALL 2012 SHAYAN JAVED LECTURE 4 Programming Fundamentals using Java 1.
Lecture 3: Blocks 1 TEALS MINECRAFT PROJECT. MINECRAFT BLOCKS Blocks form the terrain & buildings in the Minecraft world. Blocks can change appearance,
1.1: Objects and Classes msklug.weebly.com. Agenda: Attendance Let’s get started What is Java? Work Time.
Object Orientated Programming in Perl Simulated Models of Termites.
CPS 100e 5.1 Inheritance and Interfaces l Inheritance models an "is-a" relationship  A dog is a mammal, an ArrayList is a List, a square is a shape, …
Hacking Minecraft on the Raspberry Pi using Python Lesson 2 1.
CONDITIONALS CITS1001. Scope of this lecture if statements switch statements Source ppts: Objects First with Java - A Practical Introduction using BlueJ,
Creating a Simple Game in Scratch Barb Ericson Georgia Tech May 2009.
Lecture 8: Collections, Comparisons and Conversions. Svetla Boytcheva AUBG, Spring COS 240 Object-Oriented Languages.
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
Task 1 and Task 2. Variables in Java Programs Variables start with lower case letter Variables are descriptive of what they store Variables are one word.
EEC-693/793 Applied Computer Vision with Depth Cameras
Modern Programming Tools And Techniques-I
EEC-693/793 Applied Computer Vision with Depth Cameras
Obj: Introduction to Alice
TEALS Minecraft Project
Java Programming: Guided Learning with Early Objects
TEALS Minecraft Project
Introduction to Alice Alice is named in honor of
EEC-693/793 Applied Computer Vision with Depth Cameras
Introduction to Alice Alice is named in honor of
Chapter 10 Algorithms.
Introduction to Alice Alice is named in honor of
TEALS Minecraft Project
CIS 488/588 Bruce R. Maxim UM-Dearborn
Multithreaded Programming
Introduction to Alice Alice is named in honor of
Game Loop Update & Draw.
Introduction to Alice Alice is named in honor of
EEC-693/793 Applied Computer Vision with Depth Cameras
TEALS Minecraft Project
Chapter 10 Algorithms.
U3L8 Creating Functions with Parameters
Presentation transcript:

Lecture 6: Basic Entities TEALS MINECRAFT PROJECT

A NEW MINECRAFT OBJECT: ENTITIES So far, you've learned about two different kinds of Minecraft objects: items and blocks. For the rest of this project, you'll work with entities. Entities Have Unique State Each entity instance has its own state (health, items, damage, and so forth) Even items are a type of entity ( EntityItem )

ENTITY BASICS – ENTITY HIERARCHY Entity Robot EntityAgeableEntityFlyingEntityMob EntityCreature EntityLiving EntityAnimal EntityTameable Robot

ENTITY BASICS – ENTITY HIERARCHY Entity Robot EntityAgeableEntityFlyingEntityMob EntityCreature EntityLiving EntityAnimal EntityTameable

ENTITY BASICS – ENTITY HIERARCHY Entity EntityAgeableEntityFlyingEntityMob EntityCreature EntityLiving EntityAnimal EntityTameable Robot

ENTITY BASICS – ENTITY HIERARCHY Entity EntityAgeableEntityFlyingEntityMob EntityCreature EntityLiving EntityAnimal EntityTameable Robot

ENTITY BASICS – ENTITY HIERARCHY Entity EntityAgeableEntityFlyingEntityMob EntityCreature EntityLiving EntityAnimal EntityTameable Robot

ENTITY BASICS – ENTITY HIERARCHY Entity EntityAgeableEntityFlyingEntityMob EntityCreature EntityLiving EntityAnimal EntityTameable Robot

ENTITY BASICS – ENTITY HIERARCHY Entity EntityAgeableEntityFlyingEntityMob EntityCreature EntityLiving EntityAnimal EntityTameable Robot

ENTITY BASICS – ENTITY HIERARCHY Entity EntityAgeableEntityFlyingEntityMob EntityCreature EntityLiving EntityAnimal EntityTameable Robot

ENTITY BASICS – ENTITY HIERARCHY Entity EntityAgeableEntityFlyingEntityMob EntityCreature EntityLiving EntityAnimal EntityTameable Robot

ENTITY BASICS – ENTITY HIERARCHY Entity Robot EntityAgeableEntityFlyingEntityMob EntityCreature EntityLiving EntityAnimal EntityTameable

ENTITY BASICS – ENTITY HIERARCHY Entity Robot EntityAgeableEntityFlyingEntityMob EntityCreature EntityLiving EntityAnimal EntityTameable

EntityAITasks

-Add behaviors to EntityLiving entities

EntityAITasks -Add behaviors to EntityLiving entities -Derive from EntityAIBase

EntityAITasks -Add behaviors to EntityLiving entities -Derive from EntityAIBase -Run with a specified priority

EntityAITasks -Add behaviors to EntityLiving entities -Derive from EntityAIBase -Run with a specified priority -Are named EntityAIXXX, where XXX is the description of the task

EntityAITasks -Add behaviors to EntityLiving entities -Derive from EntityAIBase -Run with a specified priority -Are named EntityAIXXX, where XXX is the description of the task Example Tasks -EntityAIWander — move from current location to a random spot occasionally -EntityAIPanic — run around frantically for a period of time -EntityAIFleeSun — try to move to a darker spot -EntityAIWatchClosest — look at closest nearby entity -EntityAIAvoidEntity — avoid another entity -EntityAIEatGrass — find grass. Eat grass.

THE GAME LOOP All tasks are executed in the "game loop". The Minecraft game loop runs 20 times every second. Thus, one Minecraft "tick" is 50ms (50 milliseconds) long. In one tick, every animated thing in Minecraft is updated.

THE GAME LOOP If all tasks finish before the tick is over (less than 50ms), the game sits idle until the tick is done. If all tasks take longer than 50ms to complete, then the world slows down as it struggles to get all the work done. Hopefully this rarely happens. The game can address this situation by doing one of two things: 1.Reduce the number of entities and blocks loaded at any time 2.Increase the performance of the task code This is why you often see the world fade in and out in the distance — the game is managing how many things it has to keep track of at the same time.

THE GAME LOOP You can adjust some of the Minecraft world workload by starting up the game, and going into options, then video settings. How can changing these settings reduce the work done in a single tick?

EntityAITask FUNCTIONS EntityAITask classes have four primary methods to implement: // Returns true if the task should be executed. public boolean shouldExecute(); // Called when the task begins execution. public void startExecuting(); // Returns true if an already-executing task should continue. public boolean continueExecuting(); // Called once per tick (20 times per second) public void updateTask();

EntityAITask CODE package tealsmc.anything; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.ai.EntityAIBase; public class EntityAIExampleTask extends EntityAIBase { private EntityLiving entity; // Target Entity public EntityAIExampleTask (EntityLiving entity) { this.entity = entity; public boolean shouldExecute() { // This abstract method must be implemented. return true; }

EntityAITask CODE package tealsmc.anything; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.ai.EntityAIBase; public class EntityAIExampleTask extends EntityAIBase { private EntityLiving entity; // Target Entity public EntityAIExampleTask (EntityLiving entity) { this.entity = entity; public boolean shouldExecute() { // This abstract method must be implemented. return true; }

EntityAITask CODE package tealsmc.anything; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.ai.EntityAIBase; public class EntityAIExampleTask extends EntityAIBase { private EntityLiving entity; // Target Entity public EntityAIExampleTask (EntityLiving entity) { this.entity = entity; public boolean shouldExecute() { // This abstract method must be implemented. return true; }

EntityAITask CODE package tealsmc.anything; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.ai.EntityAIBase; public class EntityAIExampleTask extends EntityAIBase { private EntityLiving entity; // Target Entity public EntityAIExampleTask (EntityLiving entity) { this.entity = entity; public boolean shouldExecute() { // This abstract method must be implemented. return true; }

EntityAITask CODE package tealsmc.anything; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.ai.EntityAIBase; public class EntityAIExampleTask extends EntityAIBase { private EntityLiving entity; // Target Entity public EntityAIExampleTask (EntityLiving entity) { this.entity = entity; public boolean shouldExecute() { // This abstract method must be implemented. return true; }

EntityAITask CODE package tealsmc.anything; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.ai.EntityAIBase; public class EntityAIExampleTask extends EntityAIBase { private EntityLiving entity; // Target Entity public EntityAIExampleTask (EntityLiving entity) { this.entity = entity; public boolean shouldExecute() { // This abstract method must be implemented. return true; }

EntityAITask CODE package tealsmc.anything; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.ai.EntityAIBase; public class EntityAIExampleTask extends EntityAIBase { private EntityLiving entity; // Target Entity public EntityAIExampleTask (EntityLiving entity) { this.entity = entity; public boolean shouldExecute() { // This abstract method must be implemented. return true; }

USING EntityAITask package tealsmc.anything; import net.minecraft.entity.EntityLiving; import net.minecraft.world.World; public class ExampleEntity extends EntityLiving; { public ExampleEntity (World world) { super(world); tasks.addTask (1, new EntityAIExampleTask(this)); }

USING EntityAITask package tealsmc.anything; import net.minecraft.entity.EntityLiving; import net.minecraft.world.World; public class ExampleEntity extends EntityLiving; { public ExampleEntity (World world) { super(world); tasks.addTask (1, new EntityAIExampleTask(this)); }

USING EntityAITask package tealsmc.anything; import net.minecraft.entity.EntityLiving; import net.minecraft.world.World; public class ExampleEntity extends EntityLiving; { public ExampleEntity (World world) { super(world); tasks.addTask (1, new EntityAIExampleTask(this)); }

USING EntityAITask package tealsmc.anything; import net.minecraft.entity.EntityLiving; import net.minecraft.world.World; public class ExampleEntity extends EntityLiving; { public ExampleEntity (World world) { super(world); tasks.addTask (1, new EntityAIExampleTask(this)); }

USING EntityAITask package tealsmc.anything; import net.minecraft.entity.EntityLiving; import net.minecraft.world.World; public class ExampleEntity extends EntityLiving; { public ExampleEntity (World world) { super(world); tasks.addTask (1, new EntityAIExampleTask(this)); }

USING EntityAITask package tealsmc.anything; import net.minecraft.entity.EntityLiving; import net.minecraft.world.World; public class ExampleEntity extends EntityLiving; { public ExampleEntity (World world) { super(world); tasks.addTask (1, new EntityAIExampleTask(this)); }

USING EntityAITask package tealsmc.anything; import net.minecraft.entity.EntityLiving; import net.minecraft.world.World; public class ExampleEntity extends EntityLiving; { public ExampleEntity (World world) { super(world); tasks.addTask (1, new EntityAIExampleTask(this)); }

OTHER ENTITY FIELDS // Entity World Position double posX, posY, posZ; // The world in which the entity is located World worldObj; // Whether the entity is dead boolean isDead; // Whether the entity is in water boolean inWater;

OTHER ENTITY METHODS // Drops items on the ground at the entities location. EntityItem dropItem (Item item, int amount); // Sets the entities location to the specified x, y and z. void moveEntity (double x, double y, double z); // Resize the entity if it's resizeable. void setSize (float width, float height); // Called when the entity collides with a player. void onCollideWithPlayer (EntityPlayer player);

ROBOTS Robots are entities with special properties that you will use as a base for entities you create in the entity labs. Robots: look like rectangular prisms with solid colors and outlines, short-circuit and take 5 damage for every second they're in water, play sounds similar to the iron golem, attack in groups (if something harms or obstructs a robot, nearby robots will all attack the offending entity).

ROBOT HIERARCHY Entity Robot EntityMob EntityCreature EntityLiving

ROBOT HIERARCHY Entity Robot EntityMob EntityCreature EntityLiving - Moves around the world

ROBOT HIERARCHY Entity Robot EntityMob EntityCreature EntityLiving - Moves around the world - Can move on its own - May attack

ROBOT HIERARCHY Entity Robot EntityMob EntityCreature EntityLiving - Moves around the world - Can move on its own - May attack - Advanced attack behaviors - Aware of light levels - Can wield tools and weapons - Advanced pathfinding abilities

ROBOT HIERARCHY Entity Robot EntityMob EntityCreature EntityLiving - Moves around the world - Can move on its own - May attack - Advanced attack behaviors - Aware of light levels - Can wield tools and weapons - Advanced pathfinding abilities Base for lab entities

SPAWNING ROBOTS Once you’ve coded up a robot, you can summon them in game by typing /robot For lab 6, we'll be creating a leaf-converter robot of type "leafbot", so to summon a new leafbot, type the following command any time in the game: /robot leafbot

LAB 6: LEAF-CONVERTER ROBOT In Lab 6, you will create your first Minecraft entity: a leaf-converter robot. You will program this robot to (1) wander around the map on its own, and (2) randomly convert nearby blocks into leaves.