SlideShare ist ein Scribd-Unternehmen logo
1 von 33
Downloaden Sie, um offline zu lesen
libGDX:	
  Tiled	
  Maps	
  
Jussi	
  Pohjolainen	
  
Tampere	
  University	
  of	
  Applied	
  Sciences	
  
CREATING	
  TILED	
  MAPS	
  
	
  
Tiled	
  Maps	
  
Tiled	
  Editor:	
  Tiled	
  
•  EdiBng	
  tools	
  for	
  stamp,	
  fill	
  and	
  terrain	
  brushes	
  
•  Rectangle,	
  ellipse,	
  polygon	
  and	
  image	
  objects	
  
can	
  be	
  placed	
  
•  Support	
  for	
  orthogonal,	
  isometric	
  and	
  
staggered	
  maps	
  
•  Download:	
  http://www.mapeditor.org/
Isometric	
  (3D	
  effect)	
  
Isometric	
  vs	
  Isometric	
  staggered	
  
Create	
  Blesheet	
  png	
  
CreaBng	
  new	
  Map	
  
Layers	
  
•  Your	
  world	
  may	
  contain	
  layers	
  
•  You	
  can	
  disable	
  and	
  enable	
  layers	
  during	
  
runBme	
  
•  You	
  can	
  add	
  object	
  layers	
  for	
  easy	
  collision	
  
detec@on	
  
USING	
  MAPS	
  
Loading	
  Map	
  
•  To	
  load	
  a	
  map	
  
– TiledMap tiledMap = tiledMap = new
TmxMapLoader().load("runner.tmx");
•  To	
  render	
  a	
  map,	
  use	
  TiledMapRenderer	
  
– TiledMapRenderer tiledMapRenderer = new
OrthogonalTiledMapRenderer(tiledMap);
Render	
  and	
  Camera	
  
@Override
public void render () {
batch.setProjectionMatrix(camera.combined);
// Sets the projection matrix and viewbounds from the given
// camera. If the camera changes, you have to call this method
// again. The viewbounds are taken from the camera's
// position and viewport size as well as the scale.
tiledMapRenderer.setView(camera);
// Render all layers to screen.
tiledMapRenderer.render();
}
MOVE	
  CAMERA	
  
Render	
  and	
  Camera	
  
@Override
public void render () {
batch.setProjectionMatrix(camera.combined);
// move camera (YOU HAVE TO IMPLEMENT THIS)
moveCamera();
// Update camera movement
camera.update();
// Which part of the map are we looking? Use camera's viewport
tiledMapRenderer.setView(camera);
// Render all layers to screen.
tiledMapRenderer.render();
}
moveCamera()
public void moveCamera() {
// Lot of possibilities.
// 1) Just move the camera to some direction:
camera.translate(1,0); // moves x++
// 2) Move to certain point
camera.position.x = 200;
// 3) Move to direction of some sprite
camera.position.x = player.getX();
}
COLLISION	
  DETECTION	
  
Collision	
  Checking	
  
/**
* Checks if player has collided with collectable
*/
private void checkCollisions() {
// Let's get the collectable rectangles layer
MapLayer collisionObjectLayer = (MapLayer)tiledMap.getLayers().get("collectable-rectangles");
// All the rectangles of the layer
MapObjects mapObjects = collisionObjectLayer.getObjects();
// Cast it to RectangleObjects array
Array<RectangleMapObject> rectangleObjects = mapObjects.getByType(RectangleMapObject.class);
// Iterate all the rectangles
for (RectangleMapObject rectangleObject : rectangleObjects) {
Rectangle rectangle = rectangleObject.getRectangle();
if (playerSprite.getBoundingRectangle().overlaps(rectangle)) {
clearCollectable();
}
}
}
MOVING	
  OBJECT	
  
0,0	
  
32px	
  
32px	
  
32,32	
  
32,32	
  
1.	
  Arrow	
  key	
  right	
  pressed	
  
2.	
  Movement	
  x	
  =	
  x	
  +	
  5	
  
37,32	
  
1.	
  Arrow	
  key	
  right	
  pressed	
  
2.	
  Movement	
  x	
  =	
  x	
  +	
  5	
  
3.	
  Crash!	
  
37,32	
  
if	
  x	
  =	
  x	
  +	
  5	
  does	
  not	
  
collide	
  with	
  background	
  
Does	
  37,32	
  collide?	
  
37,32	
  
We	
  need	
  to	
  check	
  
each	
  corner!	
  
69,32	
  !!	
  
69,64	
  37,64	
  
37,32	
  
Check	
  if	
  the	
  next	
  frame	
  
collides	
  with	
  bg.	
  If	
  not,	
  
move	
  to	
  next	
  frame	
  
69,32	
  !!	
  
69,64	
  37,64	
  
37,32	
  
if(Gdx.input.isKeyPressed(Input.Keys.RIGHT)	
  &&	
  	
  
	
  	
  	
  !upRightCollision	
  &&	
  !downRightCollision)	
  {	
  
	
  
	
  	
  	
  	
  //	
  try	
  to	
  move	
  player	
  to	
  right	
  
	
  	
  	
  //	
  this	
  is	
  NOT	
  done,	
  since	
  
	
  	
  	
  //	
  !downRightCollision	
  is	
  false!	
  
	
  	
  	
  	
  playerSprite.translateX(-­‐1	
  *	
  moveAmount);	
  
}	
  
69,32	
  !!	
  
69,64	
  37,64	
  
ConverBng	
  Sprite	
  posiBon	
  to	
  Tiled	
  
Map	
  index	
  
32px	
  
32px	
  
250,120	
  
0	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  1	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  2	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  3	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  4	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  5	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  6	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  7	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  8	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  9	
  
8	
  
7	
  
6	
  
5	
  
4	
  
3	
  
2	
  
1	
  
0	
  
ConverBng	
  Sprite	
  posiBon	
  to	
  Tiled	
  
Map	
  index	
  
32px	
  
32px	
  
250	
  /	
  32	
  =	
  7.8	
  -­‐>	
  7	
  
120	
  /	
  32	
  =	
  3.8	
  -­‐>	
  3	
  
0	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  1	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  2	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  3	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  4	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  5	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  6	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  7	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  8	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  9	
  
8	
  
7	
  
6	
  
5	
  
4	
  
3	
  
2	
  
1	
  
0	
  
isFree	
  -­‐	
  method	
  
private boolean isFree(float x, float y) {
// Calculate coordinates to tile coordinates
// example, (34,34) => (1,1)
int indexX = (int) x / TILE_WIDTH;
int indexY = (int) y / TILE_HEIGHT;
TiledMapTileLayer wallCells = (TiledMapTileLayer)
tiledMap.getLayers().get("wall-layer");
// Is the coordinate / cell free?
if(wallCells.getCell(indexX, indexY) != null) {
// There was a cell, it's not free
return false;
} else {
// There was no cell, it's free
return true;
}
}
Checking	
  all	
  Corners	
  
upleft = isFree(leftXPos, upYPos); // true
downleft = isFree(leftXPos, downYPos); // true
upright = isFree(rightXPos, upYPos); // true
downright = isFree(rightXPos, downYPos); // false
37,32	
  
if(Gdx.input.isKeyPressed(Input.Keys.RIGHT)	
  &&	
  	
  
	
  	
  	
  !upRightCollision	
  &&	
  !downRightCollision)	
  {	
  
	
  
	
  	
  	
  	
  //	
  try	
  to	
  move	
  player	
  to	
  right	
  
	
  	
  	
  //	
  this	
  is	
  NOT	
  done,	
  since	
  
	
  	
  	
  //	
  !downRightCollision	
  is	
  false!	
  
	
  	
  	
  	
  playerSprite.translateX(-­‐1	
  *	
  moveAmount);	
  
}	
  
69,32	
  !!	
  
69,64	
  37,64	
  
getMyCorners	
  
public void getMyCorners(float pX, float pY) {
// calculate all the corners of the sprite
float downYPos = pY;
float upYPos = playerSprite.getHeight() + downYPos;
float leftXPos = pX;
float rightXPos = playerSprite.getWidth() + leftXPos;
// update the attributes
upleft = isFree(leftXPos, upYPos);
downleft = isFree(leftXPos, downYPos);
upright = isFree(rightXPos, upYPos);
downright = isFree(rightXPos, downYPos);
}
movePlayer	
  
private void movePlayer(float delta) {
// moveAmount
float moveAmount = SPEED * delta;
// Is there Room in left? THIS
// modifies the upleft, downleft, upright and upleft attributes!
getMyCorners(playerSprite.getX() + -1 * moveAmount,
playerSprite.getY());
// Move left IF there is room!
if(Gdx.input.isKeyPressed(Input.Keys.LEFT) &&
playerSprite.getX() > TILE_WIDTH &&
upleft && downleft) {
playerSprite.translateX(-1 * moveAmount);
}
...

Weitere ähnliche Inhalte

Was ist angesagt?

スマホもゲーム機も!CRIWARE×UE4 最新機能紹介 - 株式会社CRI・ミドルウェア - GTMF 2018 TOKYO
スマホもゲーム機も!CRIWARE×UE4 最新機能紹介 - 株式会社CRI・ミドルウェア - GTMF 2018 TOKYOスマホもゲーム機も!CRIWARE×UE4 最新機能紹介 - 株式会社CRI・ミドルウェア - GTMF 2018 TOKYO
スマホもゲーム機も!CRIWARE×UE4 最新機能紹介 - 株式会社CRI・ミドルウェア - GTMF 2018 TOKYOGame Tools & Middleware Forum
 
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile Games
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile GamesUnreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile Games
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile GamesEpic Games China
 
第1回 【初心者向け】Unity+Oculus Riftで次世代の3Dゲームを作って感じるワークショップ
第1回 【初心者向け】Unity+Oculus Riftで次世代の3Dゲームを作って感じるワークショップ第1回 【初心者向け】Unity+Oculus Riftで次世代の3Dゲームを作って感じるワークショップ
第1回 【初心者向け】Unity+Oculus Riftで次世代の3Dゲームを作って感じるワークショップYuichi Ishii
 
Javascript under the hood 2
Javascript under the hood 2Javascript under the hood 2
Javascript under the hood 2Thang Tran Duc
 
【Unite Tokyo 2019】ゼロから始めるアラビア語レンダリング
【Unite Tokyo 2019】ゼロから始めるアラビア語レンダリング【Unite Tokyo 2019】ゼロから始めるアラビア語レンダリング
【Unite Tokyo 2019】ゼロから始めるアラビア語レンダリングUnityTechnologiesJapan002
 
Lightweight Xtext Editors as SWT Widgets
Lightweight Xtext Editors as SWT WidgetsLightweight Xtext Editors as SWT Widgets
Lightweight Xtext Editors as SWT Widgetsmeysholdt
 
知らないと損するアプリ開発におけるStateMachineの活用法(full版)
知らないと損するアプリ開発におけるStateMachineの活用法(full版)知らないと損するアプリ開発におけるStateMachineの活用法(full版)
知らないと損するアプリ開発におけるStateMachineの活用法(full版)Ken Morishita
 
OpenVRやOpenXRの基本的なことを調べてみた
OpenVRやOpenXRの基本的なことを調べてみたOpenVRやOpenXRの基本的なことを調べてみた
OpenVRやOpenXRの基本的なことを調べてみたTakahiro Miyaura
 
3DCGMeetup08_MayaRigSystem_mGear
3DCGMeetup08_MayaRigSystem_mGear3DCGMeetup08_MayaRigSystem_mGear
3DCGMeetup08_MayaRigSystem_mGearue_ta
 
【Unite Tokyo 2019】〈七つの大罪〉をゲームで!高品質グラフィックを具現化するための技法と開発最適化のご紹介
【Unite Tokyo 2019】〈七つの大罪〉をゲームで!高品質グラフィックを具現化するための技法と開発最適化のご紹介【Unite Tokyo 2019】〈七つの大罪〉をゲームで!高品質グラフィックを具現化するための技法と開発最適化のご紹介
【Unite Tokyo 2019】〈七つの大罪〉をゲームで!高品質グラフィックを具現化するための技法と開発最適化のご紹介UnityTechnologiesJapan002
 
[AI10] ゲームキャラクターのための人工知能と社会への応用 ~ FINAL FANTASY XV を事例として ~
[AI10] ゲームキャラクターのための人工知能と社会への応用 ~ FINAL FANTASY XV を事例として ~[AI10] ゲームキャラクターのための人工知能と社会への応用 ~ FINAL FANTASY XV を事例として ~
[AI10] ゲームキャラクターのための人工知能と社会への応用 ~ FINAL FANTASY XV を事例として ~de:code 2017
 
Java EE vs Spring Framework
Java  EE vs Spring Framework Java  EE vs Spring Framework
Java EE vs Spring Framework Rohit Kelapure
 
Threads 08: Executores e Futures
Threads 08: Executores e FuturesThreads 08: Executores e Futures
Threads 08: Executores e FuturesHelder da Rocha
 
個人からトリプル A タイトルのゲーム開発者まで。Azure PlayFab で LiveOps しよう
個人からトリプル A タイトルのゲーム開発者まで。Azure PlayFab で LiveOps しよう個人からトリプル A タイトルのゲーム開発者まで。Azure PlayFab で LiveOps しよう
個人からトリプル A タイトルのゲーム開発者まで。Azure PlayFab で LiveOps しようDaisuke Masubuchi
 
Game Creators Conference 2019 Keiji Kikuchi
Game Creators Conference 2019 Keiji KikuchiGame Creators Conference 2019 Keiji Kikuchi
Game Creators Conference 2019 Keiji KikuchiKeiji Kikuchi
 
『게임 매니악스 액션 게임 알고리즘』 - 미리보기
『게임 매니악스 액션 게임 알고리즘』 - 미리보기『게임 매니악스 액션 게임 알고리즘』 - 미리보기
『게임 매니악스 액션 게임 알고리즘』 - 미리보기복연 이
 
Using Entity Command Buffers – Unite Copenhagen 2019
Using Entity Command Buffers – Unite Copenhagen 2019Using Entity Command Buffers – Unite Copenhagen 2019
Using Entity Command Buffers – Unite Copenhagen 2019Unity Technologies
 
【Unite Tokyo 2018】トゥーンシェーダートークセッション#1『リアルタイムトゥーンシェーダー徹底トーク』
【Unite Tokyo 2018】トゥーンシェーダートークセッション#1『リアルタイムトゥーンシェーダー徹底トーク』【Unite Tokyo 2018】トゥーンシェーダートークセッション#1『リアルタイムトゥーンシェーダー徹底トーク』
【Unite Tokyo 2018】トゥーンシェーダートークセッション#1『リアルタイムトゥーンシェーダー徹底トーク』Unity Technologies Japan K.K.
 

Was ist angesagt? (20)

スマホもゲーム機も!CRIWARE×UE4 最新機能紹介 - 株式会社CRI・ミドルウェア - GTMF 2018 TOKYO
スマホもゲーム機も!CRIWARE×UE4 最新機能紹介 - 株式会社CRI・ミドルウェア - GTMF 2018 TOKYOスマホもゲーム機も!CRIWARE×UE4 最新機能紹介 - 株式会社CRI・ミドルウェア - GTMF 2018 TOKYO
スマホもゲーム機も!CRIWARE×UE4 最新機能紹介 - 株式会社CRI・ミドルウェア - GTMF 2018 TOKYO
 
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile Games
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile GamesUnreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile Games
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile Games
 
第1回 【初心者向け】Unity+Oculus Riftで次世代の3Dゲームを作って感じるワークショップ
第1回 【初心者向け】Unity+Oculus Riftで次世代の3Dゲームを作って感じるワークショップ第1回 【初心者向け】Unity+Oculus Riftで次世代の3Dゲームを作って感じるワークショップ
第1回 【初心者向け】Unity+Oculus Riftで次世代の3Dゲームを作って感じるワークショップ
 
Javascript under the hood 2
Javascript under the hood 2Javascript under the hood 2
Javascript under the hood 2
 
【Unite Tokyo 2019】ゼロから始めるアラビア語レンダリング
【Unite Tokyo 2019】ゼロから始めるアラビア語レンダリング【Unite Tokyo 2019】ゼロから始めるアラビア語レンダリング
【Unite Tokyo 2019】ゼロから始めるアラビア語レンダリング
 
Lightweight Xtext Editors as SWT Widgets
Lightweight Xtext Editors as SWT WidgetsLightweight Xtext Editors as SWT Widgets
Lightweight Xtext Editors as SWT Widgets
 
知らないと損するアプリ開発におけるStateMachineの活用法(full版)
知らないと損するアプリ開発におけるStateMachineの活用法(full版)知らないと損するアプリ開発におけるStateMachineの活用法(full版)
知らないと損するアプリ開発におけるStateMachineの活用法(full版)
 
ファンタジー背景グラフィック制作事例(UE4 Environment Art Dive)
ファンタジー背景グラフィック制作事例(UE4 Environment Art Dive)ファンタジー背景グラフィック制作事例(UE4 Environment Art Dive)
ファンタジー背景グラフィック制作事例(UE4 Environment Art Dive)
 
OpenVRやOpenXRの基本的なことを調べてみた
OpenVRやOpenXRの基本的なことを調べてみたOpenVRやOpenXRの基本的なことを調べてみた
OpenVRやOpenXRの基本的なことを調べてみた
 
3DCGMeetup08_MayaRigSystem_mGear
3DCGMeetup08_MayaRigSystem_mGear3DCGMeetup08_MayaRigSystem_mGear
3DCGMeetup08_MayaRigSystem_mGear
 
Unreal Engine最新機能 アニメーション+物理ショーケース!
Unreal Engine最新機能 アニメーション+物理ショーケース!Unreal Engine最新機能 アニメーション+物理ショーケース!
Unreal Engine最新機能 アニメーション+物理ショーケース!
 
【Unite Tokyo 2019】〈七つの大罪〉をゲームで!高品質グラフィックを具現化するための技法と開発最適化のご紹介
【Unite Tokyo 2019】〈七つの大罪〉をゲームで!高品質グラフィックを具現化するための技法と開発最適化のご紹介【Unite Tokyo 2019】〈七つの大罪〉をゲームで!高品質グラフィックを具現化するための技法と開発最適化のご紹介
【Unite Tokyo 2019】〈七つの大罪〉をゲームで!高品質グラフィックを具現化するための技法と開発最適化のご紹介
 
[AI10] ゲームキャラクターのための人工知能と社会への応用 ~ FINAL FANTASY XV を事例として ~
[AI10] ゲームキャラクターのための人工知能と社会への応用 ~ FINAL FANTASY XV を事例として ~[AI10] ゲームキャラクターのための人工知能と社会への応用 ~ FINAL FANTASY XV を事例として ~
[AI10] ゲームキャラクターのための人工知能と社会への応用 ~ FINAL FANTASY XV を事例として ~
 
Java EE vs Spring Framework
Java  EE vs Spring Framework Java  EE vs Spring Framework
Java EE vs Spring Framework
 
Threads 08: Executores e Futures
Threads 08: Executores e FuturesThreads 08: Executores e Futures
Threads 08: Executores e Futures
 
個人からトリプル A タイトルのゲーム開発者まで。Azure PlayFab で LiveOps しよう
個人からトリプル A タイトルのゲーム開発者まで。Azure PlayFab で LiveOps しよう個人からトリプル A タイトルのゲーム開発者まで。Azure PlayFab で LiveOps しよう
個人からトリプル A タイトルのゲーム開発者まで。Azure PlayFab で LiveOps しよう
 
Game Creators Conference 2019 Keiji Kikuchi
Game Creators Conference 2019 Keiji KikuchiGame Creators Conference 2019 Keiji Kikuchi
Game Creators Conference 2019 Keiji Kikuchi
 
『게임 매니악스 액션 게임 알고리즘』 - 미리보기
『게임 매니악스 액션 게임 알고리즘』 - 미리보기『게임 매니악스 액션 게임 알고리즘』 - 미리보기
『게임 매니악스 액션 게임 알고리즘』 - 미리보기
 
Using Entity Command Buffers – Unite Copenhagen 2019
Using Entity Command Buffers – Unite Copenhagen 2019Using Entity Command Buffers – Unite Copenhagen 2019
Using Entity Command Buffers – Unite Copenhagen 2019
 
【Unite Tokyo 2018】トゥーンシェーダートークセッション#1『リアルタイムトゥーンシェーダー徹底トーク』
【Unite Tokyo 2018】トゥーンシェーダートークセッション#1『リアルタイムトゥーンシェーダー徹底トーク』【Unite Tokyo 2018】トゥーンシェーダートークセッション#1『リアルタイムトゥーンシェーダー徹底トーク』
【Unite Tokyo 2018】トゥーンシェーダートークセッション#1『リアルタイムトゥーンシェーダー徹底トーク』
 

Andere mochten auch

libGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationlibGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationJussi Pohjolainen
 
Intro to Building Android Games using libGDX
Intro to Building Android Games using libGDXIntro to Building Android Games using libGDX
Intro to Building Android Games using libGDXJussi Pohjolainen
 
IoT Devices, Which One Is Right for You to Learn?
IoT Devices, Which One Is Right for You to Learn?IoT Devices, Which One Is Right for You to Learn?
IoT Devices, Which One Is Right for You to Learn?Agustaf Ryadi
 
libGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferenceslibGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferencesJussi Pohjolainen
 
IoT Devices, Which One is Right for You to Learn?
IoT Devices, Which One is Right for You to Learn?IoT Devices, Which One is Right for You to Learn?
IoT Devices, Which One is Right for You to Learn?CodePolitan
 
关于 Twitter 以及 Twitter 与 NGO2.0
关于 Twitter 以及 Twitter 与 NGO2.0关于 Twitter 以及 Twitter 与 NGO2.0
关于 Twitter 以及 Twitter 与 NGO2.0刘 勇
 
Where can tell me who I am?
Where can tell me who I am?Where can tell me who I am?
Where can tell me who I am?seltzoid
 
Ies electrical-engineering-paper-2-2005
Ies electrical-engineering-paper-2-2005Ies electrical-engineering-paper-2-2005
Ies electrical-engineering-paper-2-2005Venugopala Rao P
 
China Optical Expo on Barter
China Optical Expo on BarterChina Optical Expo on Barter
China Optical Expo on BarterDaniel Evans
 
Samuel quero laplace
Samuel quero laplaceSamuel quero laplace
Samuel quero laplacesamuelquero
 
The Building Blocks of Great Video
The Building Blocks of Great VideoThe Building Blocks of Great Video
The Building Blocks of Great VideoPhil Nottingham
 
Talv
TalvTalv
Talvpiiak
 

Andere mochten auch (20)

Box2D and libGDX
Box2D and libGDXBox2D and libGDX
Box2D and libGDX
 
libGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationlibGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame Animation
 
Intro to Building Android Games using libGDX
Intro to Building Android Games using libGDXIntro to Building Android Games using libGDX
Intro to Building Android Games using libGDX
 
Moved to Speakerdeck
Moved to SpeakerdeckMoved to Speakerdeck
Moved to Speakerdeck
 
IoT Devices, Which One Is Right for You to Learn?
IoT Devices, Which One Is Right for You to Learn?IoT Devices, Which One Is Right for You to Learn?
IoT Devices, Which One Is Right for You to Learn?
 
libGDX: Scene2D
libGDX: Scene2DlibGDX: Scene2D
libGDX: Scene2D
 
libGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferenceslibGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and Preferences
 
IoT Devices, Which One is Right for You to Learn?
IoT Devices, Which One is Right for You to Learn?IoT Devices, Which One is Right for You to Learn?
IoT Devices, Which One is Right for You to Learn?
 
Java Web Services
Java Web ServicesJava Web Services
Java Web Services
 
esp8266 Wifi 4 PIC
esp8266 Wifi 4 PICesp8266 Wifi 4 PIC
esp8266 Wifi 4 PIC
 
关于 Twitter 以及 Twitter 与 NGO2.0
关于 Twitter 以及 Twitter 与 NGO2.0关于 Twitter 以及 Twitter 与 NGO2.0
关于 Twitter 以及 Twitter 与 NGO2.0
 
Where can tell me who I am?
Where can tell me who I am?Where can tell me who I am?
Where can tell me who I am?
 
Beijing2011
Beijing2011Beijing2011
Beijing2011
 
1886 6445-1-pb
1886 6445-1-pb1886 6445-1-pb
1886 6445-1-pb
 
Ies electrical-engineering-paper-2-2005
Ies electrical-engineering-paper-2-2005Ies electrical-engineering-paper-2-2005
Ies electrical-engineering-paper-2-2005
 
Pppp
PpppPppp
Pppp
 
China Optical Expo on Barter
China Optical Expo on BarterChina Optical Expo on Barter
China Optical Expo on Barter
 
Samuel quero laplace
Samuel quero laplaceSamuel quero laplace
Samuel quero laplace
 
The Building Blocks of Great Video
The Building Blocks of Great VideoThe Building Blocks of Great Video
The Building Blocks of Great Video
 
Talv
TalvTalv
Talv
 

Ähnlich wie libGDX: Tiled Maps

openFrameworks 007 - 3D
openFrameworks 007 - 3DopenFrameworks 007 - 3D
openFrameworks 007 - 3Droxlu
 
Im looking for coding help I dont really need this to be explained.pdf
Im looking for coding help I dont really need this to be explained.pdfIm looking for coding help I dont really need this to be explained.pdf
Im looking for coding help I dont really need this to be explained.pdfcontact41
 
Mashup caravan android-talks
Mashup caravan android-talksMashup caravan android-talks
Mashup caravan android-talkshonjo2
 
I need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdfI need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdfConint29
 
Geometry Shader-based Bump Mapping Setup
Geometry Shader-based Bump Mapping SetupGeometry Shader-based Bump Mapping Setup
Geometry Shader-based Bump Mapping SetupMark Kilgard
 
COMPAPPABCA49085rFunrAP__Practical Number 9 & 10.docx
COMPAPPABCA49085rFunrAP__Practical Number 9 & 10.docxCOMPAPPABCA49085rFunrAP__Practical Number 9 & 10.docx
COMPAPPABCA49085rFunrAP__Practical Number 9 & 10.docxTashiBhutia12
 
The Web map stack on Django
The Web map stack on DjangoThe Web map stack on Django
The Web map stack on DjangoPaul Smith
 
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeksBeginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeksJinTaek Seo
 
-- USING UNITY TRYING TO CREATE A CLICK TO PATH- THAT YOU CLICK ON AND.pdf
-- USING UNITY TRYING TO CREATE A CLICK TO PATH- THAT YOU CLICK ON AND.pdf-- USING UNITY TRYING TO CREATE A CLICK TO PATH- THAT YOU CLICK ON AND.pdf
-- USING UNITY TRYING TO CREATE A CLICK TO PATH- THAT YOU CLICK ON AND.pdfganisyedtrd
 
OpenLayers Feature Frenzy
OpenLayers Feature FrenzyOpenLayers Feature Frenzy
OpenLayers Feature FrenzyAndreas Hocevar
 
OpenGL L07-Skybox and Terrian
OpenGL L07-Skybox and TerrianOpenGL L07-Skybox and Terrian
OpenGL L07-Skybox and TerrianMohammad Shaker
 
How to make a video game
How to make a video gameHow to make a video game
How to make a video gamedandylion13
 
Computer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1bComputer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1bPhilip Schwarz
 
XNA L04–Primitives, IndexBuffer and VertexBuffer
XNA L04–Primitives, IndexBuffer and VertexBufferXNA L04–Primitives, IndexBuffer and VertexBuffer
XNA L04–Primitives, IndexBuffer and VertexBufferMohammad Shaker
 
Opensource gis development - part 4
Opensource gis development - part 4Opensource gis development - part 4
Opensource gis development - part 4Andrea Antonello
 
Mobile Game and Application with J2ME - Collision Detection
Mobile Gameand Application withJ2ME  - Collision DetectionMobile Gameand Application withJ2ME  - Collision Detection
Mobile Game and Application with J2ME - Collision DetectionJenchoke Tachagomain
 
Covering the earth and the cloud the next generation of spatial in sql server...
Covering the earth and the cloud the next generation of spatial in sql server...Covering the earth and the cloud the next generation of spatial in sql server...
Covering the earth and the cloud the next generation of spatial in sql server...Texas Natural Resources Information System
 
Mobile Game and Application with J2ME
Mobile Gameand Application with J2MEMobile Gameand Application with J2ME
Mobile Game and Application with J2MEJenchoke Tachagomain
 
Advance features of C++
Advance features of C++Advance features of C++
Advance features of C++vidyamittal
 

Ähnlich wie libGDX: Tiled Maps (20)

openFrameworks 007 - 3D
openFrameworks 007 - 3DopenFrameworks 007 - 3D
openFrameworks 007 - 3D
 
Im looking for coding help I dont really need this to be explained.pdf
Im looking for coding help I dont really need this to be explained.pdfIm looking for coding help I dont really need this to be explained.pdf
Im looking for coding help I dont really need this to be explained.pdf
 
Maps
MapsMaps
Maps
 
Mashup caravan android-talks
Mashup caravan android-talksMashup caravan android-talks
Mashup caravan android-talks
 
I need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdfI need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdf
 
Geometry Shader-based Bump Mapping Setup
Geometry Shader-based Bump Mapping SetupGeometry Shader-based Bump Mapping Setup
Geometry Shader-based Bump Mapping Setup
 
COMPAPPABCA49085rFunrAP__Practical Number 9 & 10.docx
COMPAPPABCA49085rFunrAP__Practical Number 9 & 10.docxCOMPAPPABCA49085rFunrAP__Practical Number 9 & 10.docx
COMPAPPABCA49085rFunrAP__Practical Number 9 & 10.docx
 
The Web map stack on Django
The Web map stack on DjangoThe Web map stack on Django
The Web map stack on Django
 
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeksBeginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
 
-- USING UNITY TRYING TO CREATE A CLICK TO PATH- THAT YOU CLICK ON AND.pdf
-- USING UNITY TRYING TO CREATE A CLICK TO PATH- THAT YOU CLICK ON AND.pdf-- USING UNITY TRYING TO CREATE A CLICK TO PATH- THAT YOU CLICK ON AND.pdf
-- USING UNITY TRYING TO CREATE A CLICK TO PATH- THAT YOU CLICK ON AND.pdf
 
OpenLayers Feature Frenzy
OpenLayers Feature FrenzyOpenLayers Feature Frenzy
OpenLayers Feature Frenzy
 
OpenGL L07-Skybox and Terrian
OpenGL L07-Skybox and TerrianOpenGL L07-Skybox and Terrian
OpenGL L07-Skybox and Terrian
 
How to make a video game
How to make a video gameHow to make a video game
How to make a video game
 
Computer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1bComputer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1b
 
XNA L04–Primitives, IndexBuffer and VertexBuffer
XNA L04–Primitives, IndexBuffer and VertexBufferXNA L04–Primitives, IndexBuffer and VertexBuffer
XNA L04–Primitives, IndexBuffer and VertexBuffer
 
Opensource gis development - part 4
Opensource gis development - part 4Opensource gis development - part 4
Opensource gis development - part 4
 
Mobile Game and Application with J2ME - Collision Detection
Mobile Gameand Application withJ2ME  - Collision DetectionMobile Gameand Application withJ2ME  - Collision Detection
Mobile Game and Application with J2ME - Collision Detection
 
Covering the earth and the cloud the next generation of spatial in sql server...
Covering the earth and the cloud the next generation of spatial in sql server...Covering the earth and the cloud the next generation of spatial in sql server...
Covering the earth and the cloud the next generation of spatial in sql server...
 
Mobile Game and Application with J2ME
Mobile Gameand Application with J2MEMobile Gameand Application with J2ME
Mobile Game and Application with J2ME
 
Advance features of C++
Advance features of C++Advance features of C++
Advance features of C++
 

Mehr von Jussi Pohjolainen

Mehr von Jussi Pohjolainen (20)

Advanced JavaScript Development
Advanced JavaScript DevelopmentAdvanced JavaScript Development
Advanced JavaScript Development
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
 
libGDX: User Input
libGDX: User InputlibGDX: User Input
libGDX: User Input
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDX
 
Building Android games using LibGDX
Building Android games using LibGDXBuilding Android games using LibGDX
Building Android games using LibGDX
 
Android Threading
Android ThreadingAndroid Threading
Android Threading
 
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesCreating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
 
Creating Games for Asha - platform
Creating Games for Asha - platformCreating Games for Asha - platform
Creating Games for Asha - platform
 
Intro to Asha UI
Intro to Asha UIIntro to Asha UI
Intro to Asha UI
 
Intro to Java ME and Asha Platform
Intro to Java ME and Asha PlatformIntro to Java ME and Asha Platform
Intro to Java ME and Asha Platform
 
Intro to PhoneGap
Intro to PhoneGapIntro to PhoneGap
Intro to PhoneGap
 
Quick Intro to JQuery and JQuery Mobile
Quick Intro to JQuery and JQuery MobileQuick Intro to JQuery and JQuery Mobile
Quick Intro to JQuery and JQuery Mobile
 
JavaScript Inheritance
JavaScript InheritanceJavaScript Inheritance
JavaScript Inheritance
 
JS OO and Closures
JS OO and ClosuresJS OO and Closures
JS OO and Closures
 
Short intro to ECMAScript
Short intro to ECMAScriptShort intro to ECMAScript
Short intro to ECMAScript
 
XAMPP
XAMPPXAMPP
XAMPP
 
Building Web Services
Building Web ServicesBuilding Web Services
Building Web Services
 

Kürzlich hochgeladen

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Kürzlich hochgeladen (20)

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

libGDX: Tiled Maps

  • 1. libGDX:  Tiled  Maps   Jussi  Pohjolainen   Tampere  University  of  Applied  Sciences  
  • 4. Tiled  Editor:  Tiled   •  EdiBng  tools  for  stamp,  fill  and  terrain  brushes   •  Rectangle,  ellipse,  polygon  and  image  objects   can  be  placed   •  Support  for  orthogonal,  isometric  and   staggered  maps   •  Download:  http://www.mapeditor.org/
  • 6. Isometric  vs  Isometric  staggered  
  • 9. Layers   •  Your  world  may  contain  layers   •  You  can  disable  and  enable  layers  during   runBme   •  You  can  add  object  layers  for  easy  collision   detec@on  
  • 11. Loading  Map   •  To  load  a  map   – TiledMap tiledMap = tiledMap = new TmxMapLoader().load("runner.tmx"); •  To  render  a  map,  use  TiledMapRenderer   – TiledMapRenderer tiledMapRenderer = new OrthogonalTiledMapRenderer(tiledMap);
  • 12. Render  and  Camera   @Override public void render () { batch.setProjectionMatrix(camera.combined); // Sets the projection matrix and viewbounds from the given // camera. If the camera changes, you have to call this method // again. The viewbounds are taken from the camera's // position and viewport size as well as the scale. tiledMapRenderer.setView(camera); // Render all layers to screen. tiledMapRenderer.render(); }
  • 14. Render  and  Camera   @Override public void render () { batch.setProjectionMatrix(camera.combined); // move camera (YOU HAVE TO IMPLEMENT THIS) moveCamera(); // Update camera movement camera.update(); // Which part of the map are we looking? Use camera's viewport tiledMapRenderer.setView(camera); // Render all layers to screen. tiledMapRenderer.render(); }
  • 15. moveCamera() public void moveCamera() { // Lot of possibilities. // 1) Just move the camera to some direction: camera.translate(1,0); // moves x++ // 2) Move to certain point camera.position.x = 200; // 3) Move to direction of some sprite camera.position.x = player.getX(); }
  • 17. Collision  Checking   /** * Checks if player has collided with collectable */ private void checkCollisions() { // Let's get the collectable rectangles layer MapLayer collisionObjectLayer = (MapLayer)tiledMap.getLayers().get("collectable-rectangles"); // All the rectangles of the layer MapObjects mapObjects = collisionObjectLayer.getObjects(); // Cast it to RectangleObjects array Array<RectangleMapObject> rectangleObjects = mapObjects.getByType(RectangleMapObject.class); // Iterate all the rectangles for (RectangleMapObject rectangleObject : rectangleObjects) { Rectangle rectangle = rectangleObject.getRectangle(); if (playerSprite.getBoundingRectangle().overlaps(rectangle)) { clearCollectable(); } } }
  • 21. 32,32   1.  Arrow  key  right  pressed   2.  Movement  x  =  x  +  5  
  • 22. 37,32   1.  Arrow  key  right  pressed   2.  Movement  x  =  x  +  5   3.  Crash!  
  • 23. 37,32   if  x  =  x  +  5  does  not   collide  with  background   Does  37,32  collide?  
  • 24. 37,32   We  need  to  check   each  corner!   69,32  !!   69,64  37,64  
  • 25. 37,32   Check  if  the  next  frame   collides  with  bg.  If  not,   move  to  next  frame   69,32  !!   69,64  37,64  
  • 26. 37,32   if(Gdx.input.isKeyPressed(Input.Keys.RIGHT)  &&          !upRightCollision  &&  !downRightCollision)  {            //  try  to  move  player  to  right        //  this  is  NOT  done,  since        //  !downRightCollision  is  false!          playerSprite.translateX(-­‐1  *  moveAmount);   }   69,32  !!   69,64  37,64  
  • 27. ConverBng  Sprite  posiBon  to  Tiled   Map  index   32px   32px   250,120   0                        1                    2                      3                    4                      5                    6                      7                      8                    9   8   7   6   5   4   3   2   1   0  
  • 28. ConverBng  Sprite  posiBon  to  Tiled   Map  index   32px   32px   250  /  32  =  7.8  -­‐>  7   120  /  32  =  3.8  -­‐>  3   0                        1                    2                      3                    4                      5                    6                      7                      8                    9   8   7   6   5   4   3   2   1   0  
  • 29. isFree  -­‐  method   private boolean isFree(float x, float y) { // Calculate coordinates to tile coordinates // example, (34,34) => (1,1) int indexX = (int) x / TILE_WIDTH; int indexY = (int) y / TILE_HEIGHT; TiledMapTileLayer wallCells = (TiledMapTileLayer) tiledMap.getLayers().get("wall-layer"); // Is the coordinate / cell free? if(wallCells.getCell(indexX, indexY) != null) { // There was a cell, it's not free return false; } else { // There was no cell, it's free return true; } }
  • 30. Checking  all  Corners   upleft = isFree(leftXPos, upYPos); // true downleft = isFree(leftXPos, downYPos); // true upright = isFree(rightXPos, upYPos); // true downright = isFree(rightXPos, downYPos); // false
  • 31. 37,32   if(Gdx.input.isKeyPressed(Input.Keys.RIGHT)  &&          !upRightCollision  &&  !downRightCollision)  {            //  try  to  move  player  to  right        //  this  is  NOT  done,  since        //  !downRightCollision  is  false!          playerSprite.translateX(-­‐1  *  moveAmount);   }   69,32  !!   69,64  37,64  
  • 32. getMyCorners   public void getMyCorners(float pX, float pY) { // calculate all the corners of the sprite float downYPos = pY; float upYPos = playerSprite.getHeight() + downYPos; float leftXPos = pX; float rightXPos = playerSprite.getWidth() + leftXPos; // update the attributes upleft = isFree(leftXPos, upYPos); downleft = isFree(leftXPos, downYPos); upright = isFree(rightXPos, upYPos); downright = isFree(rightXPos, downYPos); }
  • 33. movePlayer   private void movePlayer(float delta) { // moveAmount float moveAmount = SPEED * delta; // Is there Room in left? THIS // modifies the upleft, downleft, upright and upleft attributes! getMyCorners(playerSprite.getX() + -1 * moveAmount, playerSprite.getY()); // Move left IF there is room! if(Gdx.input.isKeyPressed(Input.Keys.LEFT) && playerSprite.getX() > TILE_WIDTH && upleft && downleft) { playerSprite.translateX(-1 * moveAmount); } ...