Cesco [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=16399 Happy Birthday, Giorgio Moroder <p> <table><tr><td> <a href="/bbs/?pid=75571#p"> <img src="/bbs/thumbs/pico8_happybirthdaygiorgiomoroder-1.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=75571#p"> happybirthdaygiorgiomoroder</a><br><br> by <a href="/bbs/?uid=16399"> Cesco</a> <br><br><br> <a href="/bbs/?pid=75571#p"> [Click to Play]</a> </td></tr></table> </p> <p>My humble and sub-par homage to the legendary musician Giorgio Moroder, because yesterday he turned 80 years old.<br /> Quite cr*p and obviously not as good as his music by a LOOOOOONG shot, so it is a fortune that he will probably won't ever hear this rendition of his famous song &quot;Chase&quot;, from the original soundtrack of the movie &quot;Midnight express&quot; ^_____^; (he won an oscar for that score, first time ever a synthesized song won an academy award, years before Vangelis)</p> https://www.lexaloffle.com/bbs/?tid=37649 https://www.lexaloffle.com/bbs/?tid=37649 Tue, 28 Apr 2020 19:54:54 UTC How would you code AI in order to follow the player AND dodge some obstacles ? <p> <table><tr><td> <a href="/bbs/?pid=47682#p"> <img src="/bbs/thumbs/pico47681.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=47682#p"> How would you code AI in order to follow the player AND dodge some obstacles ?</a><br><br> by <a href="/bbs/?uid=16399"> Cesco</a> <br><br><br> <a href="/bbs/?pid=47682#p"> [Click to Play]</a> </td></tr></table> </p> <p>Hello, I'm trying to develop a game in which there will be some enemies chasing the player on a map, and on this map there will be some obstacles.</p> <p>I know how to code a simple AI in order to have enemies follow the player, by using math trigonometry functions like sine, cosine and arctangent; but I ACTUALLY HAVE NO IDEA about how to code an enemy AI in order to make it avoiding some obstacles on the screen.</p> <p>Basically I'd like to code a simple AI that could chase the player on the map, but at the right time when it's about to collide with an obstacle could forget for a moment that chase and dodge the obstacle.</p> <p>Do you have an idea about what I should try to implement ?<br /> At the moment I've tried something very simple that tries to rotate around an obstacles while the trajectory between the enemy and the obstacle and the trajectory between the enemy and the player is equal or greater than 90 degrees. It's a really simple trick but it doesn't work 100% of the time.</p> <p>This is my code:</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre> function _init() -- initialize -- enemy e = {} e.f = 1 e.x = 0 e.y = 0 -- player p = {} p.found = false p.distance_b = 0 p.f = 2 p.x = 118 p.y = 118 -- columns bb = {} b1 = {} b1.f = 3 b1.x = 40 b1.y = 40 b2 = {} b2.f = 3 b2.x = 80 b2.y = 80 add(bb, b1) add(bb, b2) end function object_collide_with(x1, y1, x2, y2, gx, gy) -- checks if an object has collided -- with another object, then calculated -- the angle between the ball and the other object -- gx = gravity horizontal center -- gy = gravity vertical center if (gx == nil) gx = 4 -- 8x8 --&gt; 8/2 if (gy == nil) gy = 4 --local bump = c1 and c2 and c3 and c4 local distance = sqrt(((x2+gx)-(x1+gx))^2 + ((y2+gy)-(y1+gy))^2) local angle = atan2((x1 + gx) - (x2 + gx), (y1 + gy) - (y2 + gy)) local direction = flr(angle * 8) return distance, angle, direction end function player_collide_with(x, y, w, h) -- checks if the player has collided -- with another object, then calculated -- the angle between the ball and the other object return object_collide_with(p.x, p.y, x, y, w, h) end function distance_between(x1, y1, x2, y2) -- calculates the distance between two points return sqrt((x2-x1)^2 + (y2-y1)^2) end function check_player() if (btn(0)) p.x -= 1 if (btn(1)) p.x += 1 if (btn(2)) p.y -= 1 if (btn(3)) p.y += 1 end function _update() check_player() p.found = false local distance, angle, direction -- check the distance from the target distance, angle, direction = player_collide_with(e.x, e.y) for i, b in pairs(bb) do local distance_b, angle_b, direction_b = object_collide_with(b.x, b.y, e.x, e.y) if distance_b &lt;= 10 and abs(angle-angle_b) &lt; 1/6 then angle_b += 3.1415/240 e.x = b.x - cos(angle_b) * distance_b e.y = b.y - sin(angle_b) * distance_b p.found = true break end end if not p.found then e.x += cos(angle) e.y += sin(angle) end if distance_between(e.x, e.y, p.x, p.y) &lt; 8 then -- reset if the enemy touches the player e.x = 0 e.y = 0 end end function _draw() cls(0) for i, b in pairs(bb) do spr(b.f, b.x, b.y) end spr(p.f, p.x, p.y) spr(e.f, e.x, e.y) end </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> https://www.lexaloffle.com/bbs/?tid=30517 https://www.lexaloffle.com/bbs/?tid=30517 Tue, 26 Dec 2017 07:45:34 UTC No Tomorrow <p> <table><tr><td> <a href="/bbs/?pid=46016#p"> <img src="/bbs/thumbs/pico46052.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=46016#p"> No Tomorrow 1.02</a><br><br> by <a href="/bbs/?uid=16399"> Cesco</a> <br><br><br> <a href="/bbs/?pid=46016#p"> [Click to Play]</a> </td></tr></table> </p> <p>Hello! Er... this is the first game i've ever made with Pico-8, so please forgive all the bugs you'll find in this little game. </p> <p>This is my little homage to one of the games I used to play in my arcades back in the early eighties when I was a kid... a game with a trackball, many missiles and the almost impossible task to avoid a thermonuclear world war for as long as possible. </p> <p>Yes, I know... that's not exactly a very cheerful theme, but it's also not worse than your average &quot;zombie apocalypse&quot; theme that you can find in many games today ;-)</p> <h1>THE STORY</h1> <p>In this game the final war that will annihilate the human race has just started. Your name is Dave Theurer, and unfortunately you're not a superhero. You can't stop all the missiles and you can't keep your loved ones and your city safe forever; but if you're brave and lucky enough you might be able to allow your fellow citizens to see the lights of another day.<br /> Till the next night of bombings.</p> <h1>MOVEMENTS</h1> <p>Use your mouse or the directional keys to move the gun target. Push the Z button or click the left mouse button to shoot a single rocket, Keep pressed the X button or keep clicking the right mouse button for rapid fire.<br /> Shoot the enemy missiles and avoid them falling on the buildings. When your last building falls, it's game over.</p> https://www.lexaloffle.com/bbs/?tid=30214 https://www.lexaloffle.com/bbs/?tid=30214 Wed, 08 Nov 2017 16:17:41 UTC