Presentation is loading. Please wait.

Presentation is loading. Please wait.

Www.devoxx4kids.com Greenfoot Workshop Bobby - Snake.

Similar presentations


Presentation on theme: "Www.devoxx4kids.com Greenfoot Workshop Bobby - Snake."— Presentation transcript:

1 www.devoxx4kids.com Greenfoot Workshop Bobby - Snake

2 www.devoxx4kids.com Greenfoot Development Environment based on the Java programming language. Mainly designed to ease the Java language learning Allow to easily create 2D games Greenfoot is freely available on Microsoft Windows, Mac OS X, and Linux. http://www.greenfoot.org/

3 www.devoxx4kids.com The Java language « Object Oriented » Language One of the World’s most used programming language Allow to develop applications running on multiple systems – Windows, Mac, Linux, Android, …

4 www.devoxx4kids.com « Object Oriented » Java applications are made of « Objects » Each Object is composed of two main parts: – A set of internal properties – its « behavior », the actions it can do

5 www.devoxx4kids.com Classes and Objects To describe an object, we will define a class. A class is a kind of « model » allowing to build the objects – We also say that the objects are « instances » of the class

6 www.devoxx4kids.com public class GameElement { private int x; private int y; public GameElement(int initX, int initY) { x = initX; y = initY; } public int getX() { return x; } public int getY() { return y; } public void move(int xMove, int yMove) { x = x + xMove; y = y + yMove; } A Java Class sample

7 www.devoxx4kids.com Bobby-Snake 7

8 www.devoxx4kids.com New scenario 8

9 www.devoxx4kids.com World creation 9

10 www.devoxx4kids.com Snake World 10

11 www.devoxx4kids.com SnakeWorld code 11

12 www.devoxx4kids.com Inspect World 12

13 www.devoxx4kids.com Change the code We will use blocks of 32x32 pixels The game size will be 25 x 20 blocks 13

14 www.devoxx4kids.com Create a Block 14

15 www.devoxx4kids.com Create the Border 15

16 www.devoxx4kids.com Coordinates 16 (0,0)(1,0)(2,0)… (24,0) (0,1)(1,1)(2,1)… (24,1) (0,2)(1,2)(2,2)… (24,2) ………… … (0,19)(1,19)(2,19)…(24,19)

17 www.devoxx4kids.com Display the borders 17

18 www.devoxx4kids.com for loops 18 for ( initialization ; test ; post-processing ) { body ; }

19 www.devoxx4kids.com The game borders 19

20 www.devoxx4kids.com Class SnakeBody 20

21 www.devoxx4kids.com SnakeWorld changes 21

22 www.devoxx4kids.com Movement 22

23 www.devoxx4kids.com If Statement 23

24 www.devoxx4kids.com Limit the Snake size 24

25 www.devoxx4kids.com Change of direction 25

26 www.devoxx4kids.com Manage collisions (1) 26

27 www.devoxx4kids.com Manage collisions (2) 27

28 www.devoxx4kids.com Add Apples (1) 28

29 www.devoxx4kids.com Add Apples (2) 29

30 www.devoxx4kids.com Collision with an apple 30

31 www.devoxx4kids.com Add sounds 31

32 www.devoxx4kids.com Congratulations! You have completed your first Greenfoot game! You can now start to add new features in your game or start creating new games ! 32


Download ppt "Www.devoxx4kids.com Greenfoot Workshop Bobby - Snake."

Similar presentations


Ads by Google