Programming game objects - help

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
FlyingSauce
Posts: 6
Joined: September 23rd, 2013, 12:12 am

Programming game objects - help

Post by FlyingSauce » September 24th, 2013, 12:54 am

I basically want to program things like NPCs and walls without programming each individual NPC and its locations, and each individual wall and its locations. What I mean is making NPCs without making poop1, poop2, poop3, poop4, poop5, and poop6 all under the same structure. What if I wanted to use something like a map editor, or an ingame world builder? How would I do this?

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Programming game objects - help

Post by albinopapa » September 24th, 2013, 2:47 am

A bit complicated to answer really. Map editor you would still have to define what a wall is, provide a method for drawing the wall. You would need to incorporate file I/O to read and write the map characteristics such as a bitmap type file for the background, and obstructions. The editor would need to hold states of the blocks such as interactivity like walls would not allow player to move through, doors would be portals that teleport to another part of the map or another map.

NPC's AI would need to be programmed individually unless you have a type of NPC such as a sentry the routine would be the same for the sentry's but maybe different starting and ending points of patrol or different waypoints for patrol.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
Kiluad
Posts: 15
Joined: September 17th, 2013, 6:57 pm

Re: Programming game objects - help

Post by Kiluad » September 24th, 2013, 4:14 am

I suggest keep following the tutorials. :P

poo1 poo2 etc, is switched to arrays shortly after. which gives you more power over them, without so much lanky code.

Psychoman
Posts: 36
Joined: June 13th, 2013, 2:12 pm

Re: Programming game objects - help

Post by Psychoman » September 25th, 2013, 6:03 am

If you watched first intermediate lesson , you can do a thing like describe the same(general) features of a character in a class and extend it to describe some new features(specific) of a character.About the wall the thing is almost the same , but if you have the same wall you just need only 1 class.

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Programming game objects - help

Post by albinopapa » September 25th, 2013, 8:50 pm

Classes are what you need to learn about, then polymorphism, which is in intermediate lesson 9 I believe.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

Post Reply