Author Topic: AI enemies  (Read 2768 times)

0 Members and 1 Guest are viewing this topic.

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
AI enemies
« on: October 26, 2011, 05:10:25 am »
I want my enemies to have some sort of AI movement. They will have to move toward the player and wander off when they don't see him or at random. They will have to shoot bullets too. I need only 4 enemies per screen. Some enemies shoot, some don't
Has anyone made something similar yet?
I don't want this game to become too heavy for older calculators. Compability is key to success ^-^
If you like my work: why not give me an internet?








Offline Stefan Bauwens

  • Creator of Myst 89 - סטיבן
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1799
  • Rating: +162/-24
  • 68k programmer
    • View Profile
    • Portfolio
Re: AI enemies
« Reply #1 on: October 26, 2011, 06:33:19 am »
I think DualBLDR created a zombie game. http://ourl.ca/13361
But I don't know if they move to the player.


Very proud Ticalc.org POTY winner (2011 68k) with Myst 89!
Very proud TI-Planet.org DBZ winner(2013)

Interview with me

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: AI enemies
« Reply #2 on: October 26, 2011, 09:51:48 am »
I think you are the "missile" and you have to avoid the zombies to reach the smiley. The zombies spawn in ramdomly and follow a random direction with a given speed. The random direction changes liek every 10 steps or so.

My enemies will have to "see" the player's position and then run in that direction. After 20-40 steps or so the direction randomizes and it follows that direction for 20-40 steps. So the enemies run blindly at the player. They do not change direction when the player moves. This is because you have to be able to dodge em. Enemies bounce off walls.
If you like my work: why not give me an internet?








Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: AI enemies
« Reply #3 on: October 26, 2011, 10:45:44 am »
I've been piecing together a sort of AI for Essence, it's been a while but this has a sort of pseudocode that attempts to direct the AI at the player.
It doesn't have the wandering around/running, just blindly running toward the player, but blarg :P
Vy'o'us pleorsdti thl'e gjaemue

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: AI enemies
« Reply #4 on: October 26, 2011, 01:51:26 pm »
Woah that's a huge pseudocode. Maybe this is a little easier:

Code: [Select]
if player at the left
  hspeed=-x
End
if player at the right
  hspeed=x
End
if player above
  vspeed=-x
End
if player below
  vspeed=x
End
And for the random wandering:
Code: [Select]
hspeed=random(0-2)
vspeed=random(0-2)

And for the bouncing:
Code: [Select]
if moving to the left
 if there is a solid tile to the left
  bounce to right
 End
End
if moving to the left
 if there is a solid tile to the left
  bounce to left
 End
End
if moving up
 if there is a solid tile above
  bounce down
 End
End
if moving down
 if there is a solid tile beneath
  bounce up
 End
End

This might work :D
If you like my work: why not give me an internet?