Game Devolpment Help

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
N3RDY
Prole
Posts: 4
Joined: Sat May 14, 2022 8:33 pm

Game Devolpment Help

Post by N3RDY »

I have a lot of questions so here they come:

-How would I add the attack animation, which is on a seperate sprite sheet (when using anim8)?
-How would I make the character move through the map without pressing a key? (I know this is simple, I just forgot since this is one of my earliest projects)
-How would I add an ai who stands in place and attacks when the player is close?
Attachments
Map1.lua
(22.64 KiB) Downloaded 59 times
main.lua
(1.54 KiB) Downloaded 58 times
User avatar
dusoft
Party member
Posts: 492
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: Game Devolpment Help

Post by dusoft »

2. Change character's position in

Code: Select all

love.update
(e.g. x+1, y+2)
3.Detect distance between your NPC and the character and start attack if less than D pixels (or squares ...)
User avatar
milon
Party member
Posts: 472
Joined: Thu Jan 18, 2018 9:14 pm

Re: Game Devolpment Help

Post by milon »

N3RDY wrote: Sun May 15, 2022 8:21 pm -How would I make the character move through the map without pressing a key? (I know this is simple, I just forgot since this is one of my earliest
If it's a basic linear path or other simple ruleset, then dusoft has the correct answer. If it's more complex like navigating a maze, you'll want to look into A* or a similar sort of pathfinding algorithm. There's lots of tutorials on the internet & even a bunch floating around here too.
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
User avatar
dusoft
Party member
Posts: 492
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: Game Devolpment Help

Post by dusoft »

milon wrote: Mon May 16, 2022 5:37 pm If it's more complex like navigating a maze, you'll want to look into A* or a similar sort of pathfinding algorithm.
This one has served me well (just note that it uses reversed Y,X notation):
https://github.com/Yonaba/Jumper
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 52 guests