Code Monkey home page Code Monkey logo

the-powder-toy / the-powder-toy Goto Github PK

View Code? Open in Web Editor NEW
4.3K 122.0 735.0 33.71 MB

Written in C++ and using SDL, The Powder Toy is a desktop version of the classic 'falling sand' physics sandbox, it simulates air pressure and velocity as well as heat.

Home Page: http://powdertoy.co.uk

License: GNU General Public License v3.0

Python 0.70% C 1.07% C++ 94.90% Lua 0.79% Roff 0.07% Meson 2.01% Java 0.05% Shell 0.33% Objective-C++ 0.09%
simulation game powder powder-toy cellular-automata sandbox

the-powder-toy's Introduction

The Powder Toy - March 2024

Get the latest version from the Powder Toy website.

To use online features such as saving, you need to register an account. You can also visit the official TPT forum.

Have you ever wanted to blow something up? Or maybe you always dreamt of operating an atomic power plant? Do you have a will to develop your own CPU? The Powder Toy lets you to do all of these, and even more!

The Powder Toy is a free physics sandbox game, which simulates air pressure and velocity, heat, gravity and a countless number of interactions between different substances! The game provides you with various building materials, liquids, gases and electronic components which can be used to construct complex machines, guns, bombs, realistic terrains and almost anything else. You can then mine them and watch cool explosions, add intricate wirings, play with little stickmen or operate your machine. You can browse and play thousands of different saves made by the community or upload your own – we welcome your creations!

There is a Lua API – you can automate your work or even make plugins for the game. The Powder Toy is free and the source code is distributed under the GNU General Public License, so you can modify the game yourself or help with development.

Build instructions

See the Powder Toy Development Help section on the main page of the wiki.

Thanks

  • Stanislaw K Skowronek - Designed the original
  • Simon Robertshaw
  • Skresanov Savely
  • cracker64
  • Catelite
  • Victoria Hoyle
  • Nathan Cousins
  • jacksonmj
  • Felix Wallin
  • Lieuwe Mosch
  • Anthony Boot
  • Me4502
  • MaksProg
  • jacob1
  • mniip
  • LBPHacker

Libraries and other assets used

Instructions

Click on the elements with the mouse and draw in the field, like in MS Paint. The rest of the game is learning what happens next.

Controls

Key Action
TAB Switch between circle/square/triangle brush
Space Pause
Q / Esc Quit
Z Zoom
S Save stamp (use with Ctrl when STK2 is out)
L Load last saved stamp
K Stamp library
0-9 Set view mode
P / F2 Save screenshot as .png
E Bring up element search
F Pause and step to next frame
G Increase grid size
Shift + G Decrease grid size
H Show/Hide HUD
Ctrl + H / F1 Show intro text
D / F3 Debug mode (use with Ctrl when STK2 is out)
I Invert Pressure and Velocity map
W Cycle gravity modes (use with Ctrl when STK2 is out)
Y Cycle air modes
Ctrl + E Cycle edge modes
B Enter decoration editor menu
Ctrl + B Toggle decorations on/off
N Toggle Newtonian Gravity on/off
U Toggle ambient heat on/off
Ctrl + I Install powder toy, for loading saves/stamps by double clicking
Backtick Toggle console
= Reset pressure and velocity map
Ctrl + = Reset Electricity
[ Decrease brush size
] Increase brush size
Alt + [ Decrease brush size by 1
Alt + ] Increase brush size by 1
Ctrl + C/V/X Copy/Paste/Cut
Ctrl + Z Undo
Ctrl + Y Redo
Ctrl + Cursor drag Rectangle
Shift + Cursor drag Line
Middle click Sample element
Alt + Left click Sample element
Mouse scroll Change brush size
Ctrl + Mouse scroll Change vertical brush size
Shift + Mouse scroll Change horizontal brush size
Shift + R Horizontal mirror for selected area when pasting stamps
Ctrl + Shift + R Vertical mirror for selected area when pasting stamps
R Rotate selected area counterclockwise when pasting stamps
F11 Toggle fullscreen

Command Line

Command Description Example
scale:SIZE Change window scale factor scale:2
kiosk Fullscreen mode
proxy:SERVER[:PORT] Proxy server to use proxy:wwwcache.lancs.ac.uk:8080
open FILE Opens the file as a stamp or game save
ddir DIRECTORY Directory used for saving stamps and preferences
ptsave:SAVEID Open online save, used by ptsave: URLs ptsave:2198
disable-network Disables internet connections
disable-bluescreen Disable bluescreen handler
redirect Redirects output to stdout.txt / stderr.txt
cafile:CAFILE Set certificate bundle path cafile:/etc/ssl/certs/ca-certificates.crt
capath:CAPATH Set certificate directory path capath:/etc/ssl/certs

the-powder-toy's People

Contributors

antb avatar boxmein avatar c7c8 avatar catelite avatar catsoften avatar cracker1000 avatar huulivoide avatar ief015 avatar jacksonmj avatar jacob1 avatar jbot-42 avatar krawthekrow avatar lbphacker avatar me4502 avatar mmbob avatar mniip avatar moonheart08 avatar noh avatar ntoskrnl11 avatar perssphere07 avatar pilihp64 avatar quantech0 avatar savask avatar simtr avatar superdoxin avatar suve avatar triclops200 avatar tridiaq avatar wolfy1339 avatar zc00gii avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

the-powder-toy's Issues

cppcheck warnings

Hi there !
I was curious about this project and I tried cppcheck, the great static C/C++ analyzer, on the code.
It warns about some interesting things :

src/graphics.c (line 114) : Memory leak: result.

src/interface.c (line 3148) : Possible null pointer dereference: id_d_temp - otherwise it is redundant to check if id_d_temp is null at line 3152.
src/interface.c (line 5348) : Memory leak: save.
src/interface.c (line 5449) : Memory leak: savefname.

src/main.c (line 2365) : Possible null pointer dereference: load_data - otherwise it is redundant to check if load_data is null at line 2367.
src/main.c (line 640) : Using sizeof for array given as function argument returns the size of pointer.
src/main.c (line 3407) : Undefined behavior: variable is used as parameter and destination in s[n]printf().
src/main.c (line 1738) : Memory leak: part_vbuf.
src/misc.c (line 483) : Memory leak: iconname.
src/misc.c (line 483) : Memory leak: opencommand.

src/update.c (line 75) : Common realloc mistake: 'name' nulled but not freed upon failure.
src/update.c (line 55) : Common realloc mistake: 'fn' nulled but not freed upon failure.

All credit goes to the cppcheck team (https://github.com/danmar/cppcheck).

mac verison crashes

I don't have a mac, I just know that it gets laggy and crashes over time, and you have to restart it to fix this problem. It might be a memory leak or something.
also, fullscreen. Maybe you should update the SDL libraries, i'm sure there must have been a new release by now that fixed it.

save thumbnails are ugly

they are too pixelated. A new method to make them is needed. If you need to, mniips would still work as a temporary fix, or we could go back to tpt's method, until we find something better.

Also, i'll say here that the save boxes on the front page are different sized than the ones everywhere else, causing even more problems. They should be the exact same size as in tpt's save browser for the best thumbnail to show.

Also, you can't see full save name in the save browser if it's too long, you need to click it first. Maybe the larger thumbnail thing can be brought back.

can't publish saves

The option always says unpublish, not publish, no matter what is selected. There should be a way to publish too, depending on what is selected.

Add GPL-2 License header to each source file

I, personally, think there should be a GPL-2 (or 3?) header for each of your source files, even though there is a 'LICENSE' file in the home directory. This would be so that, even though if the files in this program were to be copied elsewhere, the license would still be clear.

exiting the save browser reloads the save

When you open a save, go back to the browser, but then exit the browser without opening a save, the save you were looking at is reloaded.

Also, if you exit the browser with the 'X', this doesn't happen. Only with ESC

id:XXXXXXX searches don't work

I told you this before, but it's still there. It mostly doesn't work on private saves, but on some public saves too. It occasionally works.

no corrupted thumbnail sign, so invalid saves are never rendered

This save:
http://powdertoy.co.uk/Browse/View.html?ID=644543
Is an invalid format. Normally it should be OPS1, but I have that as OPJ1, to prevent a thumbnail from showing. It still attempts to render it though. It's possible it will attempt to render anything else you give it too.

Also, when a save is corrupted or invalid, it doesn't make a sign that says "corrupted" or whatever it was that it did for tpt. It just leaves it empty
http://powdertoy.co.uk/Browse/View.html?ID=992287

undefined reference to `clock_gettime'

Error when compiling and report that. I read the man page(clock_gettime(3)) and it says:

Most systems require the program be linked with the librt library to use these functions.

Here's the patch:

diff --git a/Makefile b/Makefile
index 399f6d6..fb6904a 100644
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,7 @@ PYCOMMAND := $(PY_BIN) getheader.py

 CFLAGS := -w -std=c99 -D_POSIX_C_SOURCE=200112L -DLUACONSOLE -DGRAVFFT -Iinclud
 OFLAGS := -O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations
-LFLAGS := -lpthread -lSDL -lfftw3f -lm -lbz2 -lX11 -llua5.1 #-lpython$(PY_VERSI
+LFLAGS := -lpthread -lSDL -lfftw3f -lm -lbz2 -lX11 -llua -lrt #-lpython$(PY_VER
 LFLAGS_X := -lm -lbz2 -lSDLmain -I/Library/Frameworks/Python.framework/Versions
 MFLAGS_SSE3 := -march=native -DX86 -DX86_SSE3 -msse3
 MFLAGS_SSE2 := -march=native -DX86 -DX86_SSE2 -msse2

no ban message in game

It will not tell you you are banned until you try to log in again after you realize the session is invalid. It then says "Error: Account Banned. Ban expire in .94 hours" This grammar is wrong, and it doesn't even fit in the box. I also just discovered that neither tpt or tpt++ will tell you why you are banned. It should be able to tell you. I didn't check the website to see what it would say, probably something similar.

deco editor problems

there is no way to deselect a color preset, to use one, you have to change the preset if you want to use the color selector-

smudge still has a smaller radius-

the deco buttons don't have a color, they are all black-

there are some edge issues in the color picker that I fixed when making it twice as tall, but that wasn't merged in-

pressing 'b' should bring you to the menu?-

alt click with deco doesn't work with the 1 pixel brush, the brush should be changed with alt held down, some kind of selection brush like the one my mod uses for flood fill (hole in middle)

Can't compile on Fedora

on fedora, the flag -llua5.1 is invalid and you need to use -llua, also, there is no subdirectory for lua includes, all lua includes are in /usr/share includes.

Patch:

From 9148fdf41cb4dc8a66355225211230da0441afd6 Mon Sep 17 00:00:00 2001
From: Elad Alfassa <[email protected]>
Date: Mon, 7 May 2012 18:39:45 +0300
Subject: [PATCH 1/2] Make it compile on Fedora

---
 includes/luaconsole.h |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/includes/luaconsole.h b/includes/luaconsole.h
index 83fa405..e6a93ff 100644
--- a/includes/luaconsole.h
+++ b/includes/luaconsole.h
@@ -21,9 +21,9 @@
 #include <lauxlib.h>
 #include <lualib.h>
 #else
-#include <lua5.1/lua.h>
-#include <lua5.1/lauxlib.h>
-#include <lua5.1/lualib.h>
+#include <lua.h>
+#include <lauxlib.h>
+#include <lualib.h>
 #endif
 #include <defines.h>

-- 
1.7.7.6

old repo?

I don't see why you changed back to the old repo, the new one worked fine. But anyway, the default branch for this one is 'legacy'. So anyone that comes here gets directed to that branch, not master. I was going to link to this one from the wiki, but I can't when it does that.

https://github.com/FacialTurd/The-Powder-Toy <- shows legacy branch

Also, I don't have push access to this one...

Build failure with clang in graphics.h

Building The Powder Toy with clang almost works -- there's one compilation error though:

In file included from src/graphics.c:26:
In file included from includes/powder.h:5:
includes//graphics.h:90:22: error: a parameter list without types is only allowed in a function definition
int graphics_DEFAULT(GRAPHICS_FUNC_ARGS);
                     ^

For some reason clang believes that this function declaration uses the K&R style parameter list, which is only allowed in function definitions.

The problem is probably quite subtle since GCC doesn't choke on it. I don't see anything obviously wrong with graphics.h (except that the header which defines GRAPHICS_FUNC_ARGS isn't included in graphics.h, though it's included before graphics.h in any file that includes graphics.h).

I'm using clang v3.0.

sign issues

you can't move signs into the zoom window by using 'move'. I don't think all the sign stuff should happen in an imaginary 'window', the window should only happen when you actually see a window. This would fix the zoom problem.

also, the alignment isn't shown when editing signs in the game like the text is shown while drawing.

.

And I think i've seen some cases where multiple copies of a sign were stacked on top of each other. I'm not sure if it's a glitch or something else causing it (stamps)

comment scrolling issues

in save id:958277 after you scroll down to the second page, you can't go back up to the first. It happens on any save where the final page doesn't span the whole page I think. - fixed

Also, to me scrolling seems a little too fast, but it may just be that I don't like the velocity part. I already have a mouse setting that does something like it, they just don't go together that well. I'm not sure how well it works on other computers.

Also, maybe it should be changed so that when you scroll back up, you start at the bottom of the page before. That gets annoying sometimes.

saving stamps on a 1 pixel grid

It should go back to a 1 pixel grid, that way is much easier to use, and you don't accidentally pick things you didn't want to.

I already did this, and tested it, it does work (one small change is needed that I did in a later commit). I can commit it for you to test if you need to.

also, my commit fixes the bug where you can't stamp the bottom and right edges, they just don't get included.

Edit: now fixed

FIRW in radial grawity mode

Currently when 'launched' the FIRW will always go up on the X-axis,
but in it should act like gasses in radial gravity mode.
So instead of going straight up, it should go to left, or even downwards,
depending on its initial possition.

Why am I banned

This account has been banned. Reason given:
Username

I have a good username!!!
Why am i banned?

MAJOR Brush issue

When trying to use the smallest brush size, 1x1, it will not draw or delete particles, only happens with 1x1 as far as I know, VS says "Unhandled exception at 0x0044a36f in The Powder Toy.exe: 0xC00000FD: Stack overflow." and it that the statement to be executed is

if((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i_j<=ry_rx))

around 5130 area, it is hard to give exact with different mod.

Hope it helps.

Please introduce heat of transition

I want make heat pomp.
Please introduce heat of transition.
It is heat of fusion, heat of solidification, heat of vaporization, heat of condensation, for instance.

conversation notifications don't work

it notifies me, but the box is empty, it doesn't say anything as the title. It's just a small empty box next to another box with an 'X'. Clicking the tiny box does take me to the conversations tab though.

Report notifications are working, i've seen a few of those. It would be nice if those were viewable from the game, it would be easier to deal with them. I tried that in my mod once, but Reports.json was just a bunch of html.

RPM Package making

I am currently working on The Powder Toy package in Fedora 17. I want to store user Saves folder and powder.pref under ~/.powder. How I can accompish this? Also, do you have a nice .desktop file?

openGL

Why dont you use OpenGL?

no session check on startup

This causes a few problems. One is that it doesn't tell you when you have a new message. If I ever think about sending a message to someone, I don't because I know they might not see it.
Also, this means that it doesn't give you beta updates when there is one. I'm still on 84.1, because it never asked to update.
You probably don't get a message when you are banned either.

But, the way tpt did it was slightly annoying. You shouldn't have to wait until it checks to open a save (using open on the website). Also, it shouldn't log you out when it timeouts, because that kept logging me out in the old tpt, I went to the save browser before it finished.

tag interface issues

you can't vote on tags

I can't delete tags, it says could not read response, and they stay. It might only be for moderators, because other people can fine

brush issues

You can't use the line tool and remove zoom at same time
There is no cursor size shown when using shift-drag, both the cursor and line should appear

The pen size is not kept after pressing tab. Edit: i'm not sure if it should be changed, since other people seem to like it

There is no flood fill cursor. Maybe a temporary one like the one in my mod can be added, or the real one you have planned.

Lua console problems

When running the step functions, it only runs if the first one is registered, unregistering that will prevent all of the others from running (this was fixed in tpt already). Maybe the registering should be rewritten, cracker64 had problems with mouse and key events when making his script manager, and there is currently a limit of 6 functions of each kind.

not implemented functions:
tpt.set_console
tpt.hud
tpt.display_mode

tpt.set_debug says it's depreciated, but was useful, so it probably needs a replacement too (maybe you're planning a way without lua)
tpt.getscript was implemented, but doesn't return an error when I call it without arguments, so it looks like it didn't work
tpt.set_property has no element id/name checks and can create invalid elements

I noticed all of these by looking at the code, I haven't really tried running a script yet.

front page vote counter not in sync with other vote counters

it's possible that the number of votes shown on a front page save will be different than shown in my own or by date. (or the website)? I can't remember if it's faster or behind, I think it's behind? Pinning and unpinning a save from the fp also seems to lag behind slightly.

I'm not sure how fixable this is, it just seems weird that two places show different things.

PROP Tool Additions And Efficiency

In the PROP menu, up and down arrows should cycle through element property the number field should automatically be selected, and the line and box tool should select multiple particals.

STKM display problem

STKM only shows up in Fire Mode, in other modes, like Pressure Mode, he's invisible.
Last working build was build100.

Crash when exiting game, connections not closed

from 11/23:

[19:57:27] <dTal> How come the Powder Toy is responsible for 36 out of the 45 open TCP connections on my machine? Does it really need that many connections? Does it really need a connection at all, given that I have no account and was not browsing the user-submitted simulations?
[19:58:41] <jacob1> were you browsing the save search earlier?
[19:58:43] <jacob1> it could be a glitch
[20:00:49] <dTal> Yeah, I had been browsing it earlier.
[20:02:56] <dTal> They were all on LAST_ACK so there may be something in that
[20:04:18] <jacob1> what does that mean?
[20:05:33] <Ristovski> jacob1: btw, LAST_ACK means you received connection close but you havent closed it yet
[20:06:04] <jacob1> I noticed it crashed in visual studio because of something like that
[20:06:11] <jacob1> when I exit, it still crashes, because it has open connections
[20:06:13] <Ristovski> jacob1: yeah, TPT keeps a socket open even if the server is done sending stuff
[20:06:33] <jacob1> i'll report it on github then

I think the crash happens at line 420 of http.cpp (actually 248 of ThumbnailBroker.cpp - if(http_async_req_status( req.HTTPContext))), i'm not sure if that's changed to a new line though

Gameplay suggestions

1 semiconductor model is wrong
make semiconductors act as they act in real life
2 add different types radioactivity
3 add magnetic fields, capacitors , etc.....
4 make 2 kinds of batteries -- + and -
5 allow to set temperature and pressure everyhwere
6 improve phisics

grid issue

In build106, grid doesn't show up.
Last working version was build100.

WIRE name is confusing,

For new users, WIRE is the only obvious way of connecting electronics, but it doesn't actually work WITH anything else since it's just an automaton rule

WIND + line tool

It should create wind every frame, so you can hold shift drag down to create wind.
also, maybe try making it work better too... Wind doesn't work that well right now.

multiline textbox problems

highlight sometimes is drawn all the way across the screen - can't reproduce now ... maybe fixed

when there are no spaces, it just keeps going across the screen, and then you can't see the next word that follows either - fixed

you can't copy and paste the text back in, only the first line will paste and it pastes weird-fixed

When you paste a large amount of text into the box before it grows in width, it gets the wrong height since it expands to be the height that smaller width would be.

Also long strings (ex. url's) now get cut off. I made a commit that did this as a replacement to going out of the textbox, copying them seems fine though for some reason.

More Linux issues from TPT++

When you click the "Copy save ID" button, TPT++ crashes. Some code has been added to prevent crashing from the missing copy/paste feature on linux but not for that button seems like.

Updating Lua

what about switching to Lua 5.2? or maybe even to LuaJIT?

PhysX

What about PhysX?
It is very good for calculations for particles?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.