Page 1 of 1

Programming game objects - help

Posted: September 24th, 2013, 12:54 am
by FlyingSauce
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?

Re: Programming game objects - help

Posted: September 24th, 2013, 2:47 am
by albinopapa
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.

Re: Programming game objects - help

Posted: September 24th, 2013, 4:14 am
by Kiluad
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.

Re: Programming game objects - help

Posted: September 25th, 2013, 6:03 am
by Psychoman
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.

Re: Programming game objects - help

Posted: September 25th, 2013, 8:50 pm
by albinopapa
Classes are what you need to learn about, then polymorphism, which is in intermediate lesson 9 I believe.