[HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

33
2.5D RTS Game in HTML5 part 1 Dawid Lijewski [email protected]

description

Presentation from Dawid during the HTML5 Berlin User Group Join the next one here: http://www.meetup.com/Berlin-HTML5-User-Group/

Transcript of [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

Page 1: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

2.5D  RTS  Game  in  HTML5  

part  1  Dawid  Lijewski  

[email protected]  

Page 2: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

Hey!  

•  Dawid  Lijewski  •  InformaBon  &  ComunicaBon  Technology  Engineer  

•  SoJware  Developer  &  Network  Engineer  

•  Graduate  student  (Master-­‐Sc.),  Wrocław  Technology  University,  Computer  Science  

Page 3: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

Few  words  about  me…  

Page 4: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

Few  words  about  new  Berliner…  

•  New  in  Berlin,  live  in  CharloXenburg  since  27th  August  

•  I  fell  in  love  to  Berlin  at  first  sight  

•  Berlin  is  awesome  

Page 5: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

Few  words  about  my  world…  

•  JAVA,  C++  •  IP  Networks  •  I  see  no  problems,  only  challenges  

•  Programming  languages  and  frameworks  are  just  only  tools  in  my  hand,    

•  I  feel  no  hip  toward  anything…except  SAAB’s…  

Page 6: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

Modern  mobiles  are  so  fast…  

Page 7: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

InspiraBon  

Page 8: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

…that’s  Blitzkrieg…  

Page 9: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

2D  Isometric  Canvas/Terrain  

2D/3D  technology  in  Blitzkrieg  

2D  Buildings  (Sprite)  

2D  Flora  (Sprite)  

Units  -­‐  Tanks,  Arty,  Cars  (3D  Model  +  Textures)  

Page 10: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

Isometry  –  Bme  for  boring  math    

Page 11: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

Isometry  is  sBll  2D  surface  

Page 12: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

Isometric  angle  problem  

Page 13: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

SoluBon!  

Page 14: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

Do  not  transform  and  rotate…  

…save  CPU’s  power!  

Page 15: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski
Page 16: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

code  

Page 17: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

Isometric  worlds  –  Diablo  II  

Page 18: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

WebGL  –  logical  and  modern  next  step  

Page 19: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

So  why  not  WebGL?  

•  Security  reasons  •  Compability  with  browsers  

•  I’m  not  3D  modeler..  

…let’s  try  the  canvas  and  classical  2D!  

Page 20: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

2D  Technology  in  RTS  (AoE)  

2D  Isometric  Canvas/Terrain  

2D  Buildings  (Sprite)  

2D  Flora  (Sprite)  

Units  -­‐  Tanks,  Arty,  Cars  (2D  Sprite)  

Page 21: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

Isometric  worlds  –  AoE  II  

Page 22: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

AnimaBon  of  2D  Units,  sprite  sheet  

Page 23: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

What  exactly  is  RTS  Game?  

•  Real-­‐Bme  strategy  (RTS)  is  a  sub-­‐genre  of  strategy  video  game  which  does  not  progress  incrementally  in  turns.  

•  In  an  RTS,  as  in  other  wargames,  the  parBcipants  posiBon  and  maneuver  units  and  structures  under  their  control  to  secure  areas  of  the  map  and/or  destroy  their  opponents'  assets.  

Page 24: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

More  backend  than  frontend  

•  Algorithm  for  sight  detecBon  

•  Pathfinding  algorithm  and  colision  detecBon  

•  Algorithm  for  shooBng  (ArBllery  problem)  

•  Algorithm  for  game  states,  win/lose  condiBons  

•  Algorithm  for  unit  construcBon  

•  Algorithm  for  unit  auto-­‐acBons  and  formaBons  

•  Algorithm  for  AI  

•  Dynamic  enviroment  

Page 25: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

My  Way…  

•  Do  It  from  scratch  • Make  it  efficient  

•  Simple  UI  

•  Simple  graphics  

•  Focus  player  on  tacBcs  rather  than  „click-­‐fest”  

Page 26: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

…my  desBnaBon  

•  Game  for  every  plakorm  •  Game  designed  for  Social  Networks  

•  Different  difficulty  levels  

•  BaXles  must  be  HUGE!  

Page 27: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

AdapBve  Tile  Refresh  

•  John  Carmack’s  invenBon  

•  In  order  to  implement  a  similar  technique,  we  need  to  get  rid  of  the  setTimeout()  in  the  draw()  loop  and  add  four  parameters  to  the  draw()  funcBon:  srcX,  srcY,  destX,  and  destY.  Calling  the  draw()  funcBon  without  passing  any  parameters  should  redraw  the  enBre  canvas;  passing  the  srcX/Y  and  destX/Y  parameters  should  redraw  only  the  area  within  that  boundary.  

Page 28: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

Current  progress  

Page 29: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

Problems…  

•  Framerate  and  animaBons  •  AI  • MulBple  objects  

• MulBple,  simultaneous  changes  in  big  canvas  

•  Complicated  appliance  of  complex  logic  

•  Shadow  casBng  

Page 30: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

Maybe  Bme  for  different  aproach…  

•  Google  Web  Toolkit?  •  Hardware  acceleraBon  of  browsers?  

•  …or…  

Page 31: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

Join  to  me?  

Page 32: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

Thanks  for  your  aXenBon!  

[email protected]  

Page 33: [HTML5 BUG] 2,5D RTS Game in HTML5 by Dawid Lijewski

Sources:  

• Making  Isometric  Social  Real-­‐Time  Games  with  HTML5,  CSS3,  and  Javascript,  Mario  Andrés  Pagella  

• Wikipedia  

•  hXp://gamedev.tutsplus.com/tutorials/implementaBon/creaBng-­‐isometric-­‐worlds-­‐a-­‐primer-­‐for-­‐game-­‐developers/  

•  Google  Images