Log In  
BBS > Lexaloffle Community Superblog
This is a combined feed of all Lexaloffle user blogs. For Lexaloffle-related news, see @zep's blog.

All | Following | PICO-8 | Voxatron | General

Does print() in _update() work?

Hi there! Just purchased PICO-8 and Voxatron last week and I'm trying to recreate some classic pong action as a way of getting familiar with the ins and outs of the scripting environment (this is my first time ever interacting with anything related to Lua). Right now I've got a paddle that responds to up/down keyboard presses and a ball that bounces around the screen and collides with the paddle.

I'm trying to print some debug text at the moment of paddle + ball collision, but my print function appears to be doing nothing.

Here's what my current gameplay looks like:

And here's the code:
(the print function that appears to not be working is in line 53 - i.e. the 3rd line from the bottom)
(unrelated: sure would be nice to have line numbers on code snippets here in the forums!)

ball_x = 64
ball_y = 64
ballspeed_x = 3
ballspeed_y = 2
pad_x = 20
pad_y = 50
pad_w = 4
pad_h = 20

function _draw()
    rectfill(0,0,127,127,5)
    circfill(ball_x,ball_y,2,14)
    rectfill(pad_x, pad_y, pad_x + pad_w, pad_y + pad_h, 10)
end

function _update() 
    moveball()
    updateballcollisions()
    movepaddle()
    updatepaddlecollisions()
end

function moveball()
    ball_x += ballspeed_x
    ball_y += ballspeed_y
end

function updateballcollisions()
    if (ball_x < 0 or ball_x > 127) then
        ballspeed_x *= -1;
    end
    if (ball_y < 0 or ball_y > 127) then
        ballspeed_y *= -1;
    end
end

function movepaddle()
    if btn(2) and pad_y+(pad_h/2) > 0 then
        pad_y -= 4
    end
    if btn(3) and pad_y+(pad_h/2) < 127 then
        pad_y += 4
    end
end

function updatepaddlecollisions()
    pad_top_y = pad_y
    pad_bot_y = pad_top_y + pad_h
    pad_left_x = pad_x
    pad_right_x = pad_left_x + pad_w
    if ((ball_x > pad_left_x) and (ball_x < pad_right_x) and (ball_y > pad_top_y) and (ball_y < pad_bot_y)) then
        ballspeed_x *= -1
        print("paddle collision", 6, 6, 11)
    end
end

As you can see in the gameplay gif, my updatepaddlecollisions() function seems to be working correctly when the ball collides with the paddle except that there should also be a string "paddle collision" that prints at (6, 6) colored green (color 11), but that string never prints! :(

I'm aware of the printh() function but I'd really like to stay within the editor and just have my debug text print directly onto the app screen.

So! Am I crazy or does the print() function not work if it's in _update() or some function that gets called within _update()? Thanks so much! I'm so excited to actually build cooler things with this amazing tool!

P#68968 2019-10-17 17:52 ( Edited 2019-10-17 17:54)

Cart [#twotwos_weird_snake-0#] | Code | 2019-10-17 | No License | Embed

I made this game ages ago but just didn't publish it at the time. I think that's because I thought that it just wasn't polished enough, and besides, the world doesn't really need another snake game anyway. I... still think that, but my standards are now lower. So, yeah, this is just another snake game. It's got some different modes, at least! They're all pretty good (except maybe Janky mode, I don't know what I was thinking), but versus mode is the coolest in my opinion. It's a hardcore 1v1 snake battle to the death.

P#68958 2019-10-17 08:32

stars in the galaxy.
Whoops, sorry, not that. No, something BETTER. Millions and billions of VALUES you can now use in Pico-8.

 
mib
by dw817
Cart [#mib-0#] | Code | 2019-10-17 | License: CC4-BY-NC-SA | Embed
2

load this in Pico-8 immediate mode with:

load #mib-0

I understand there was a library made sometime ago that could increase a value to trillions, but it could not decrease, let alone go beyond 0 to negative numbers.

Well, I sat down and thought about it. Realized that getting past 0 is a tricky thing indeed. Especially going from 0 to a negative number and found at least for me a fairly simple solution to get around it.

So what do you have here ?

Well, in the demo hit LEFT and RIGHT to choose a positive or negative number to add or subtract to your total. And calculate the result every time you hit (O).

A program that lets you count up as high as you like, well past a billion or trillion using a STRING instead of a numeric variable. There is a catch though, and likely this is a limitation on my coding ability. You can only add or subtract up to 16383 at a time.

I'm not sure how to do it otherwise, but one advantage is if both numbers are ranged to 16383 or less, positive or negative, then the calculation is instant.

If not, it goes through my function and adds or subtracts properly and it defaults to 16-digits, or you can choose how many digits you want in your numbers if that's not enough.

Useful if you want to have a score over a long time or experience points for an RPG that surpass the 32767 barrier.

I have no doubt my code could be optimized further. :)

...

Wait. What the heck ?? It doesn't work correctly here but it does in Pico-8 ??
Well that's just EVIL. I had this problem in GFA-Basic years ago. My code would ran fine in the editor, compiled, didn't run properly. Augh ! Solution anyone ? Gotta be a bug @zep needs to squash.

Try for yourself to see it works perfect in the actual Pico-8 system.

P#68949 2019-10-17 02:29 ( Edited 2019-10-17 03:54)

Cart [#nexcidium-0#] | Code | 2019-10-17 | License: CC4-BY-NC-SA | Embed

About

This game is a vertical shooter with a story. It’s not designed to be very hard - the whole game can be completed in ~5 minutes or so. It was build for Ludum Dare 44, with the theme of "your life is currency".

Story

The year is 2098. Earth’s human population has reached 15.2 billion. Under pressure of dwindling resources, the government passes the ‘greater good’ act. Under this act, families are paid to voluntarily terminate a loved one. As a government worker, your job is to carry out these terminations. The method of choice: 100mg ‘nexcidium’ injection.

Posted this on itch.io, but I want to get it up on the BBS. Hope you enjoy!

P#68946 2019-10-17 00:27

Cart [#break_practice_cc-0#] | Code | 2019-10-16 | License: CC4-BY-NC-SA | Embed

P#68942 2019-10-16 19:16

Cart [#blackdeath-1#] | Code | 2019-10-17 | No License | Embed
5

Hello!

I'd like to present a little game I made called Black Death. It's an action game in which you play as The Plague. You have infected a rat and your goal is to kill all of the villagers with your putrid bite.

However your rat only has limited health. You must maintain your ability to infect the villagers by transferring yourself to other rats.

Beware the attacks of the villagers. They will try to kill you. Use the rat holes if you must.

Watch out for The Doctor. Though he will not harm you, his goal is to heal infected villagers. Ensure that he cannot reach them before the infection has had time to kill them.

Control your rat with the arrow keys. Bite by touching a villager or rat with your nose. If a villager touches you on any other side then you will be hit.

I hope you enjoy the game!

P#68925 2019-10-16 07:42 ( Edited 2019-10-17 07:11)

Cart [#footloose-0#] | Code | 2019-10-16 | License: CC4-BY-NC-SA | Embed

A Pico-8 version of Footloose by Kenny Loggins. Hope you enjoy!

P#68918 2019-10-16 02:15

Cart [#space_engineer-0#] | Code | 2019-10-16 | License: CC4-BY-NC-SA | Embed
4

P#68915 2019-10-16 01:15

 
brw
by dw817
Cart [#brw-2#] | Code | 2019-10-15 | No License | Embed
4

To load this in Pico-8, in the console immediate mode type:

load #brw-2

Hope you don't mind me starting a new thread. I literally had to rewrite more than half the code here so I think it's deserving of it.

And yes, it now has a proportionally spaced font.

New configuration in code lets you turn on/off shadow (runs a lot faster without).
Configure page and ink color too. And of course this will work with any text file, provided you have enough memory for it. Anything close to 19,000 chars will fit.

You have a few questions ? I have a few questions. :D

Would you like me to post an additional version that uses soft-sprites instead of individual pixel-plotting as it is now ?

The advantage will be the bookreader will run much faster even with shadowing, the disadvantage of course is you can't inject your own sprites over the set during reading.

Also I could make a version that just reads the text file by itself without poking it to sprite territory.

Further I have the font-writer with the sprite table of fonts I doodled. Do you like the proportionally spaced font or would you like to build one of your own for it ? You will need that tool.

Let me know, and thanks everyone who's helped me get as far in Pico-8 as I have today !

P#68907 2019-10-15 21:38 ( Edited 2019-10-16 04:21)

Cart [#adventuremaze-0#] | Code | 2019-10-15 | No License | Embed
2

I created this as part of a tutorial, and I ended up making my own maze. There is a way to speed run this if you can figure it out. Have Fun!

P#68898 2019-10-15 17:59

Pico Lib

After making some games in pico8 I found I was copy and pasting some functions, code designs. With the new(ish) "#include" functionality, I decided to pull those things out into a cart to use as a library. Its still a WIP but right now includes

  • Vector obj with some functions
  • screenshake manager
  • gamestate manager
  • Actor class with optional..
    • animation (multiple sprites per frame)
    • collision (with map flag 1 and other actors)

Cart [#pico_lib-1#] | Code | 2019-10-15 | License: CC4-BY-NC-SA | Embed

Examples

Cart [#pico_lib_actors_example-0#] | Code | 2019-10-15 | No License | Embed

Cart [#pico_lib_state_n_shake_example-0#] | Code | 2019-10-15 | License: CC4-BY-NC-SA | Embed

P#68896 2019-10-15 15:17

Now that I'm mixing and matching my metaphors in programming, metaphorically speaking of course, I'm running into some curious behavior by Pico-8.

For instance, take this code:

a="1"
b=2
?a+b

Which gives you 3, and that's fine.

But if you do this:

a="1"
b={1}
?b[a]

The result is NIL. Now I already know why it is because it's a string, but wouldn't it be easier for Pico (and possibly other programmers) to remove the number "type" completely and instead treat all variables as strings, only doing calculations when desired, and even then the results while visually appearing numerically are still just in truth a string ?

We already have ".." to show linking two strings together so there would be no difficulty with getting the "+" chosen correctly for calculations in determining whether or not it needs to be added to or appended to.

What problems would typecasting everything as a string cause ?

I can already see one advantage. Since strings can be any size this could also mean Pico-8 could be upgraded by @zep and allow numbers with any number of digits in them, both to the left and right of the decimal place. It would break the -32767.9999 and 32767.9999 barrier.

P#68887 2019-10-15 00:10 ( Edited 2019-10-15 01:09)

Hi guys !

I have a license for PICO-8 and Voxatron. But many of my friends don't. They downloaded PICO-8 on pirate sites and are still able to develop games.

So I was wondering: except access to future updates and a remuneration for PICO-8 creators, what is a license for? The right to submit carts on BBS?

Thanks !

P#68882 2019-10-14 19:25

Cart [#ball_effects-0#] | Code | 2019-10-14 | License: CC4-BY-NC-SA | Embed
12

Made this cart to test some distortion effects for future projects.

A lot of people got interested in a tweet I made with it so I'm posting here in case anyone wants to see the code or use it on a project.

Move with the mouse;
Z/X (O/X) to change size;
Left mouse click to switch effect.

P#68876 2019-10-14 17:29

Cart [#avoition-0#] | Code | 2019-10-14 | License: CC4-BY-NC-SA | Embed

A TweetTweetJam inspired 560 char game. Inspired by the flash game Avoision. But that name was already taken on Pico8. Everything is under 560 chars including the metadata and high score save system (If you want to delete the high score just delete or rename vsn.p8d.txt). Make the square avoid the swirlies. the square will always follow your mouse (marked by a semicolon) but will lag behind it.

If you last for 18 minutes and 30 seconds you will find a hidden Easter Egg. Which may or may not be an integer overflow. Pro tip, the red circle doesn't hurt you.

Licensed under Unlicense, the CC-BY-NC-SA is just for the label.

P#68874 2019-10-14 15:56

Hunger is a short game about greed.

It's my first game and will only take you a minute or two – would love for you to give it a try!

Cart [#hunger-0#] | Code | 2019-10-14 | No License | Embed
3

--

Itch: http://ghostronaut.itch.io/hunger

P#68865 2019-10-14 08:51

I'm still staying pretty busy here working on something else, but thought I would give this a go using the speed of the mapper to swap pages. See what you think:

Cart [#yaaa256-0#] | Code | 2019-10-13 | License: CC4-BY-NC-SA | Embed
1

P#68854 2019-10-13 23:06

At first, I saw a demo where a student implement a voxelspace algorithm with compute shaders. Voxelspace is a tech invented in the '90s by Kyle Freeman at Novalogic to render landscape. Games like Comanche, Deltaforce used it. It was based on heightmap and voxels, not polygon. I don't know much about shaders, but I know it is better at rendering polygons. So... I try to understand how all this work and here is the result: my voxelspace implementation on Pico 8

With freds72 optimization

Cart [#voxelspace_ykk-2#] | Code | 2019-10-15 | No License | Embed
13

first release
Cart [#voxelspace_ykk-1#] | Code | 2019-10-13 | No License | Embed
13

Here is an implementation of voxelspace rendering algorithm, with a little perlin noise map generation. Features :

  • Generate a 128x128 height map in memory,
  • Generate a color map base on height with some noise (I could also use height difference to better show cliffs and flat grounds, maybe latter),
  • colors fadding with distance
  • We can move, with player one controls, zoom map with X (or M), strafe with player 2 left and right (s,f)

I don't know where it will go, or if it will become a game, but here is my work :D Have fun tweaking or exploring !

for a more advance experience, you can check electricgryphon work https://www.lexaloffle.com/bbs/?uid=10844

P#68841 2019-10-13 19:50 ( Edited 2019-10-15 21:46)

Cart [#super_cold-0#] | Code | 2019-10-13 | License: CC4-BY-NC-SA | Embed
2

For Mix and Game Jam

P#68839 2019-10-13 17:13

Cart [#yeboyugusa-0#] | Code | 2019-10-13 | No License | Embed

P#68838 2019-10-13 16:17
View Older Posts
About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-10-17 19:33 | 0.122s | 4194k | Q:243