kikendo [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=26497 How to approach level creation/management? <p>Hello everyone, it's been a while, life gets in the way and my little pico-8 project gets pushed away, but here I am again with more questions.</p> <p>I got to the point where I basically have all the game elements I need running (I think), and I need to start building levels, but I have no idea how to go at this really.</p> <p>My game is a flip screen type, 8 screens wide per level.<br /> Each level will of course have an increasing number of features with different attributes.<br /> Some of them are collectables (two types), some of them are enemies (3 types)</p> <p>I know there's two ways I could approach this: </p> <ul> <li>Have a fixed amount of levels that are all the same and tweak them difficulty-wise as I see fit, by hand</li> <li>Have the levels be created procedurally</li> </ul> <p>I don't have the foggiest idea about procedural generation of anything, so I don't think I would understand ANY explanation about that route. Although it would be nice to learn eventually and maybe change the game to do that in the future, at this point I think option 1 is my only course of action for the time being.</p> <p>With that in mind, how would you approach this task?</p> <p>My main idea was to have an object level{}, which would have as elements each level (up to 15 or whatever I decide I can have), and each level element would have the data I need, in some format.</p> <p>i thought maybe an array of numbers representing each level would tell it what each screens has, but haven't really figured that one out yet.</p> <p>Looking forward to hear your ideas!</p> https://www.lexaloffle.com/bbs/?tid=31882 https://www.lexaloffle.com/bbs/?tid=31882 Fri, 14 Sep 2018 16:08:40 UTC Sprite priority (z-index)? <p>Hi everyone,</p> <p>I hope you can help me out with this one as I have no idea how to approach it.</p> <p>I have a player character that moves across a screen, and there is an element I am drawing that sometimes should be behind the character and sometimes it should be in front. Basically, if my character is around its area (collided with it) and I press a button, the sprite should come on top of the character. When I press another button, the sprite goes back to being behind the character.</p> <p>What would be the best way to achieve this, since I cannot dynamically change the order in which things are written? (or can I?) I read some hints at the forum some time ago regarding the use of flags, but I have no idea how this would work (and never used sprite flags before).</p> <p>Any help appreciated!</p> https://www.lexaloffle.com/bbs/?tid=31501 https://www.lexaloffle.com/bbs/?tid=31501 Thu, 12 Jul 2018 13:08:57 UTC Check collision against a line? <p>Hi pico8'ers, it's me again. Sorry!</p> <p>Today I am wondering what the best approach would be to check if a sprite/object has touched a line and act accordingly.</p> <p>Take the following example:<br /> Let's say I made this 45 degree slope and I have a character that can walk to it or jump to it from wherever. I want that line to be &quot;solid&quot; and affect the character's behavior.</p> <p>Illustrated:</p> <img loading="lazy" style="margin-bottom:16px" border=0 src="https://i.imgur.com/qWwcUQB.png" alt="" /> <p>How would I go at this, I have no idea.<br /> I have a collision system in place in my game, but it checks bounding boxes.<br /> Of course I don't want to make bounding boxes of 1x1 and check against all of them, that sounds slow and stupid.</p> <p>I think maybe what I need here is &quot;raycasting&quot; but I never in my life have done anything like that and have no idea where to begin. I don't even know if that is what I am looking for.</p> <p>I don't want to make slopes of varying angles, it will always be a 45 degree slope. I Am hoping this also would make things easier.</p> <p>I didn't find any cart on the BBS that does exactly what I want from where I could look at some code. Maybe I didn't look hard enough.</p> <p>Any help appreciated!</p> https://www.lexaloffle.com/bbs/?tid=31174 https://www.lexaloffle.com/bbs/?tid=31174 Tue, 24 Apr 2018 14:32:33 UTC flr() giving me trouble <p>So I implemented the following jump function in my game:</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 jump(sp,vel,factor) for i=1,factor do player.sprite = 12 player.velocity+=sp if player.y&lt;=player.origpos then player.y+=(player.velocity*player.speed) else player.velocity=vel player.y=flr(player.origpos) player.sprite = 0 player.jumping = false end end end </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>The problem I am having here, is that the Y of the player every second jump is equal to player.origpos+0.24</p> <p>I moved stuff around because what I feel is happening is that the routine is entering some condition one time too many, but why does it every second frame? Does it have to do with the fact that I am calling &quot;factor&quot; twice? And how would I fix this problem?</p> <p>The difference is every second jump, the character ends up one pixel above the floor, and let me tell you, it does NOT let my OCD rest peacefully :D</p> <p>Any help appreciated!</p> https://www.lexaloffle.com/bbs/?tid=31148 https://www.lexaloffle.com/bbs/?tid=31148 Thu, 19 Apr 2018 16:40:18 UTC Rotate rects around a point <p>I'm trying to make a bunch of rectangles that rotate around a given point, my code so far is this</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 _update() timer+=0.01 velocity_x=cos(timer) velocity_y=sin(timer) for vect in all(rotographic) do vect[1]+=velocity_x*radius vect[2]+=velocity_y*radius vect[3]+=velocity_x*radius vect[4]+=velocity_y*radius end end function _draw() cls(0) for v in all(rotographic) do rectfill (v[1],v[2],v[3],v[4],flr(rnd(15)+1)) end end </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>&quot;rotographic&quot; is a table in which each cell contains a 4 value vector with the x and y positoins of origin and destnation to feed to rectfills. So far this works fine making the squares, however, all they do is rotate together, around their own center if I am not wrong.</p> <p>What I want to achieve, is for the each rect to rotate around a given center (let's say 64,64 to exemplify) so in the given example, what would happen is, the outer rects will rotate around a bigger radius than the inner ones.</p> <p>I know I'm failing at math here (no surprises) so I hope you guys can nudge me in the right direction!</p> <p>I read this very helpful article, but I am failing to figure out how to apply its logic to more than one element in the data structure I have.<br /> <a href="http://endlessillusoft.com/rotating-around-a-point/">http://endlessillusoft.com/rotating-around-a-point/</a></p> https://www.lexaloffle.com/bbs/?tid=31106 https://www.lexaloffle.com/bbs/?tid=31106 Mon, 09 Apr 2018 21:17:15 UTC n00b issue calling functions <p>Hi everyone,</p> <p>In a try to make my code cleaner, I am trying to get all the junk I was putting in _update into its own function, but failing.</p> <p>I copy pasted the exact same code and put it in a function called &quot;game_update&quot;, then called &quot;game_update()&quot; from the _update function, and I get a runtime error: Attempt to call global 'game_update' (a nil value)</p> <p>If I copy that back into update, the game works.</p> <p>I read that in lua the order you define things in is important. My init, update and draw are at the bottom of the code so this shouldn't be the problem (I moved them atop and also didn't work).</p> <p>Any idea what could be happening here??</p> https://www.lexaloffle.com/bbs/?tid=31051 https://www.lexaloffle.com/bbs/?tid=31051 Fri, 30 Mar 2018 11:03:21 UTC OT: PicoPi on RPi 0? <p>Has anyone beena ble to run PicoPi on a RaspberryPi Zero?<br /> <a href="https://guillermoamaral.com/read/picopi/">https://guillermoamaral.com/read/picopi/</a></p> <p>It says to copy everything to a card and boot, but I got mine stuck on a black screen, nothing happens.</p> <p>I want to make a standalone device booting straight to pico8 and this seems like the only option.</p> https://www.lexaloffle.com/bbs/?tid=30745 https://www.lexaloffle.com/bbs/?tid=30745 Fri, 09 Feb 2018 10:42:58 UTC