Pages: [1]   Go Down
Author Topic: Basic "Tag" Game  (Read 438 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey everyone,

I am currently working on a basic game using a 2x16 parallax LCD screen and an Adruino Uno. So far i have the player character able to move up down right and left using 4 if statements and input from a controller I made on a bread board. Next i would like to make a monster npc that chases the player. I have made many programs like this before and am basing the code for my Adurino project after one I made in java script. I can easily make a single monster that chases the player around, again using about 4 if statements to control its movement and then one to detect when they are touching. However I haven't figured out how to add additional monsters using the same "brains" but having their own separate variables without adding more of the same code just with different variables. I did a little Minecraft modding before and I'm looking for something kind of like an entity files, where each 1 of the NPCs rendered can call on their file to know how to behave. If you need more info let me know. Any help at all would be great!
 
Thank you very much!
~aaaelite21
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Arduino is programmed in C++. That means classes. Create a monster class, and multiple instances of that class.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Wouldn't that just limit the number of monsters that could be spawned? For the sake of the game I was hoping to make it a Farly large number as I plan on getting a bigger screen soon. Or could a loop of some sort control the number of instance or "spawning" of that class?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 603
Posts: 33408
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Wouldn't that just limit the number of monsters that could be spawned
No why should it? It takes less memory to do that than to duplicate the code.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Awesome!!! Thank you very much!!!
Logged

Pages: [1]   Go Up
Jump to: