collapse

Welcome!



Welcome to Robot Rebels, an online robot maker community.

Register today to post your projects, ask questions, share knowledge and meet like-minded people from around the world.


The RobotRebel.org Community

Author Topic: ESP8266 on "Staroids"  (Read 1808 times)

Gareth

  • Member
  • ****
  • Posts: 38
ESP8266 on "Staroids"
« on: January 10, 2016, 08:35:05 AM »
In the on-going quest to see how far the ESP8266 Series 12e modules can be stretched, I have devised a game code named "Staroids". The Game is by no way finished, and more will be added in time.

It was a programming exercise, to see if I could mix both a cheap TFT screen and Nintendo Nun-chuck positional controller.

I originally had it wired up to the Nintendo's motion+ accessory, a 3 axis gyro..... however I had a ping moment when I noticed the Nunchuck had extra controls up its sleeve.

Its written using the Arduino IDE and ported to the ESP8266.... The biggest advantage is the ESP is faster that the arduino's atmel chip, this is from my observation of the frame updates to the TFT screen.

My TFT Screen has the markings 2.4" TFT SPI 240*320 TJCTM2404-SPI  with a price of £4.00

To get the ESP talking to the Nun-chuck & TFT screen I am using these libraries :-

#include <Wiichuck.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9340.h>     // please note this is adjusted for the ESP (Arduino uses the ILI9341)

The TFT does not have a buffer area where you can pre-load graphics (maybe that's the way the adafruit library works).

Also you can not seem to be able to read the screen memory locations (again maybe its a limitation of the adafruit library)

With the above two points in mind, I traveled the "store" everything in a 2D array route. It kinda made sense as objects were given a single xy coordinate and this makes it easier to kinda vector build the graphics around it.

To make sense of the playing field and plotting environment all of the objects are sent to screen using  polar coordinate plotting, this makes it easy to scale and launch objects on the correct headings. i.e.

 rx1=rockets[rocketid][1]+10*(rockets[rocketid][6])*(-sin(radians(rockets[rocketid][3]))) ;  // x position
 ry1=rockets[rocketid][2]+10*(rockets[rocketid][6])*(cos(radians(rockets[rocketid][3]))) ;  // y position

For object hit object collisions a rectangular "Hit Box" detect was created, as you can see from the code many brackets are needed to && the virtual hitbox into shape.Its not exact, however in gameplay you don't notice small misshit errors.

 if ((starmatrix[hittest][0]==1)&&((mothershipx<(starmatrix[hittest][1]+starmatrix[hittest][3]))&&((mothershipx>(starmatrix[hittest][1]-starmatrix[hittest][3]))))&& ((mothershipy<(starmatrix[hittest][2]+starmatrix[hittest][3]))  && ((mothershipy>(starmatrix[hittest][2]-starmatrix[hittest][3])))))

The whole thing is controlled by using a Nintendo NunChuck controller . It has pitch&roll position sensors however strangely no Yaw sensor, the joystick and two buttons make up for this though.


Either single missiles can be launched or a salvo of 2 or 3 or 4 can also be loosened by deft Skywalkers.


Scoring is done purely by time (will change shortly).... ie low (millis) score for 5 stars = High score.

Below = 24716 milliseconds.

Conclusion :-

Current code only uses 1/2 of the ESP's memory so room for more game-play, the speed is impressive for the workload needed.

I would like to conduct a test using the same setup using an Arduino just to confirm the speed upgrade that the ESP offers.

I know that in this example does not use the WiFi ability of the ESP ... maybe if enough people cloned this project then thier Highscore could be uploaded to a dedicated web server for example, just for fun.


Smashley

  • Member
  • *
  • Posts: 67
Re: ESP8266 on "Staroids"
« Reply #1 on: January 10, 2016, 02:41:44 PM »
Amazing, thanks for posting this Gareth, just the push i need to get cracking on something with my ESPs  :)

 

* Search


* Recent Topics

Gordon McComb Passes by jinx
[September 18, 2018, 02:12:53 AM]


sdsds by jinx
[September 16, 2018, 04:11:16 AM]


1B1 -- RAN Stack by Protowrxs
[September 12, 2018, 05:35:59 PM]


Picture Topic by Underwooz
[September 05, 2018, 12:27:28 AM]


ESP32 - Stepper - LIDAR - Platform by ZeroMax
[August 25, 2018, 06:48:32 PM]


NASA bot by ossipee
[August 05, 2018, 06:52:36 PM]


Android Adware by Pittmanz
[July 24, 2018, 12:40:23 AM]


Greetings! by Pittmanz
[July 24, 2018, 12:39:20 AM]


Sloooow progress on the I3 clone by KingBeetle
[July 16, 2018, 04:20:59 AM]


MKS Gen L 1.0 by jinx
[July 15, 2018, 03:55:57 AM]


Motor rewinding machine by 1 what
[July 10, 2018, 06:03:46 PM]


All the stories in the forum are most important. by ZeroMax
[July 01, 2018, 09:44:53 PM]


Parallax CR Servo with Built-In Encoder by 1 what
[June 28, 2018, 12:13:32 PM]


He's Back...BoB V3.0 by k120189
[June 21, 2018, 07:03:17 PM]


Funding by MEgg
[June 21, 2018, 04:34:36 PM]

* Recent Posts

Re: Gordon McComb Passes by jinx
[September 18, 2018, 02:12:53 AM]


Gordon McComb Passes by erco
[September 17, 2018, 10:00:37 PM]


Re: sdsds by jinx
[September 16, 2018, 04:11:16 AM]


sdsds by sdsds
[September 15, 2018, 03:55:20 PM]


Re: 1B1 -- RAN Stack by Protowrxs
[September 12, 2018, 05:35:59 PM]


Re: Picture Topic by Underwooz
[September 05, 2018, 12:27:28 AM]


Re: 1B1 -- RAN Stack by tinhead
[August 27, 2018, 04:06:01 PM]


Re: 1B1 -- RAN Stack by Bajdi
[August 27, 2018, 09:58:53 AM]


Re: 1B1 -- RAN Stack by ZeroMax
[August 25, 2018, 06:53:15 PM]


Re: ESP32 - Stepper - LIDAR - Platform by ZeroMax
[August 25, 2018, 06:48:32 PM]


NASA bot by ossipee
[August 05, 2018, 06:52:36 PM]


Updates 20180728 :- new Steppers - Perfboard Migration - wheel inserts by Gareth
[July 28, 2018, 09:57:11 AM]


Re: Android Adware by Pittmanz
[July 24, 2018, 12:40:23 AM]


Re: Greetings! by Pittmanz
[July 24, 2018, 12:39:20 AM]


Re: Sloooow progress on the I3 clone by KingBeetle
[July 16, 2018, 04:20:59 AM]