GDC-WM / 2DGame2021

Has a very nice backend structure but no real gameplay (yet?)
MIT License
1 stars 1 forks source link

Possessable AI #3

Open BlastWind opened 3 years ago

BlastWind commented 3 years ago

Movable main character

In UserView, set up camera correctly and do this:

switch(key){
 case 'W': mainCharacter.moveUp(); 
 case 'D': mainCharacter.moveRight();
 case 'S': mainCharacter.moveDown();  
 case 'A': mainCharacter.moveLeft(); 
}

Thoughts on what a possessor is and why we would make a possessor: 1) I'm up late so sorry if these ideas become unsound in 2 days 2) Instead of accessing an NPC or AI actor and then directly calling setPosition on it to shift position, I like using a master Possessor to take control of it and issue canonical commands. This might lead to better modulation, and we write less code when issuing several commands to the same list of actors. E.g.:

Instead of

ZombieActor.setPosition(lastPos - 3, lastPos - 4) 
RandomActor.setPosition(lastPos - 3, lastPos - 4) 
ZombieActor.throwTrap(x, y, fireTrap);  
RandomActor.throwTrap(x, y, fireTrap);  

We can maybe do:

Possessor.possess(ZombieActor, RandomActor); 
Posessor.issueCommandsToAll([
 { type: "throwTrap", params: { x: x, y: y, trapType: fireTrap }, 
 { type: "moveRelatively", params: { dx: -3, dy: -4 } }
])

The problem for this pattern arises when there are actors with many different methods (not enough similar commands).

In Possessor (to be made):

Possessor.possess(Actor toPossess) // possesses an actor, stop all other possessions
Possessor.addPossession(Actor toPossess) // possessor one additional an actor
Possessor.removePossess(Actor toRemovePossess) // stop possessing an actor
Possessor.refresh() // removes all possession
Possessor.issueCommandsToAll(command []) 
Possessor.issueCommands(Actor, command []) 
Possessor.issueCommand(command)
Posessor.setTemporaryMain(Actor) // experimental thoughts, what if we made a function that temporarily sets another character as the main actor (allows player input to move character and centers camera on it)? Maybe we get some ghost abilities that allows us to temporarily control other ghosts but leaves our original body vulnerable to attack? Maybe too much functionality. 
Possessor.revertMain() // give control back to original main character 

Command has schema:

{
 command_type: string; 
 params: Hashmap (aka a dictionary in python or just an object in javascript) 
}
amj0851 commented 3 years ago

Sexy pseudocode made by sexy man - not Andrew