How do you program a 2d platformer?

How do you program a 2d platformer?

Google it.

By not forgetting minor stuff that make the difference between a shitty platformer and one that handle great, like jump input buffering & ledge forgiveness.

always start with states
define your states and then have a conditional determine what the current state is
use current state as a permission check for actions and reactions
i.e. only jump if state == grounded

i dont even program or do codes, but for some reason that made sense and didnt at the same time.

This is some Schrodinger shit going on here

you know how rpgs have status effects, like say in pokemon you can be put to sleep or frozen?
and if you're one of those things then you can't attack or do much of anything?
a state machine is the backend equivalent of that, your code keeps track of things like whether or not your character is touching the ground, and you use that to determine whether or not you allow the player's spacebar etc. to trigger a jump
if you're already in the air then maybe you can't jump or maybe it's a double jump, whatever the coder wants
my advice if you're getting started is avoid gamemaker entirely, I'm making a platformer now and it's great for the basics but once you start trying to add complex state machines it's more hassle than the ide is worth

What language do you suggest?

If (Jump = Pressed);
then Jump;
else;
noJump;

What about double jump?

>that kid who noJump-ed to school

C#
try unity for your first game

Download game maker and google how to use it, you moron.

you don't

Don't think in term of language, think in term of engine.
Once you know which engine you want to use, the language question will be solved.
But by default :

honestly javascript
it's not a "real" programming language but you can make great games and publish to literally any platform
if state == air && doublejumped == false, allow double jump and set doublejumped = true
when you touch the ground again reset doublejumped = false
also a good suggestion but javascript is probably more beginner friendly if you have no experience with compilers or cs in general

But what is "Jump"?

Could you write a command to me that will specify the character to move vertically when a specific button is pressed? Thanks.

How do I implement momentum into a 2d platformer?

>it's not a "real" programming language

?????

How difficult to program is a game like this?

are you simple ? increase the character's elevation until a certain threshold has been reached, then lower it until he reaches the ground

If (Player.state == ground) {
moveVertically(Player);
}
else {
}

Hope that helps.

it would take months or years depending how much daily time you can sink into it

X = X + VelocityX
Y = Y + VelocityY

I wish it was this fucking easy.

meant to reply with this

presumably you have an event listener that listens for keyboard presses and parses which key is oressed, yielding the keycode
you set up a switch statement that decides which function to invoke depending on which key was pressed
if W for example, then invoke jump()
inside jump() you check to see if you can actually jump, then set the character momentum
I'd suggest box2d but there are plenty of 2d physics engines
java*script*
like I said you can do almost anything you want with it but on paper it's a scripting language
programming isn't measured in difficulty the way math might be
it's measured in how much time it will take
the more skilled you are, the quicker you can work, and the cleaner your code can be, but something like that can be programmed (shittily) by any beginner if they dedicate enough time

well, it is in a way, once you have a functioning characters and all his associated states you already have a game

Jumping doesn't take place in one function
while you hit jump and you're on the ground, set your Y velocity to -10 or something
then when it gets updated every frame it applies the velocity

>doublejumped == false
Better to just have a jump counter. Then you can easily expand to a triple jump if you want to.

This thread is great. I'm a brainlet and decided to flunk out of my IT/CS course but I can still understand a bit of what is being posted here.

Have a bump

very true but think psuedocodes for beginners and what's easiest to understand off the bat

anyway best of luck OP

>programming isn't measured in difficulty
That's complete bullshit. Some things are more difficult to program than others.

Just programming? A couple weeks maybe.

wtf my character won't stop jumping YOU RUINED MY LIFE!!

>on paper it's a scripting language

and in practice that hasn't been true since the v8 engine was a thing

That's because you're seeing psuedocode, which is written in a way anyone can understand. The real code to perform even a simple jump would be much more complex.

That looks very good

can you recommend a good IDE for javascript ?

Since jaavscript is so shit to read you would think a good one exist....

I think there's a fine line between designing algorithms/software and actually programming it.
Designing can be measured in difficulty as it requires critical thinking, problem solving, mathmatics, etc.
Programming your designs is just typing away and reading over to find out where you fucked something up, it just takes time.
In the case of a generic platformer game, there's very little software design required as it's been done a million times before and everyone already had an idea of how they're designed funtionally speaking...
No compiler, doesn't run natively in any OS (except maybe chrome os?), just controls a browser...

Visual Studio Code

>js
>IDE
Unironically notepad++

It's pseudo, even though it's pronounced psuedo
I keep seeing this and first figured it to be a typo, but I no longer think so

there's no "ide" because it's just a scripting language with no compilation or runtime environment
literally any text editor works great, I prefer atom despite all the hate it gets
very customizable

I'm good enough to make pretty much an Iphone game but I will never understand how shit like hacking networks or making video games cracks works

shut the fuck up you fucking idiot

this >just controls a browser

lol
and it has a compiler, v8 compiles it on the fly

Nah, that was definitely my typo. I mix it up a ton, even though I like to think I know better.

do
get input
update all your stuff based on that input
draw everything
while the game is going

top tip for being lazy keeping it simple
-use a fixed frame rate so you don't have to fuck around with variable time deltas between frames

>calling me an idiot for recommending notepad++
>implying I'm him
Literally all you need is syntax highlighting.

Webstorm faget

cracking requires a particular set of skills that is only tangentially related to programming
hacking is a different beast and basically requires being a great programmer

lel this is what I get for assuming Sup Forums would leave the leading spaces for the shit in the loop

but Sup Forums told me javascript is pajeet technology :(

I've seen definately being used so often I sometimes have to stop and think about it when using the term

I'm surprised somebody finally agreed with me on VSCode.

It is, sadly it became popular

the easy part is the programming. you can learn to code all this behavior in months.

it's the art that will be consume most of your time

asking Sup Forums about programming is like asking Sup Forums about games
they're full of shitposters that just want to shit on and if you listened to them you wouldn't write a single line of code because everything is terrible

That's what I was implying

vscode is legitimately great, just needs time to grow

What's the difference between VSC and Visual studio Datetime.Now.Year?

How do they even work?

get fucked functional memer
js shits on whatever meme language you would want to use for writing applications

...

it basically boils down to knowledge about tools that can help you mine for information, and a set of techniques to use that information to hijack the behavior of a program or the result of a request.

There are way too many to list here, but the most basic and well known is cheatengine.

VSCode is a very nice code editor and available on Windows, Mac, and Linux
VS2017 is the entire IDE

>you can learn to code all this behavior in months.
Where do I start?

nobody programs video games in javascript

...

google unity tutorials

With html5 you can do some pretty cool shit. It's nice for prototyping since it's quick and easy.

VSC is like Code::blocks with intellisense while VS proper is gigantic overcomplicated team enterprise collaboration project management contraption.

Granblue fantasy

Examples of shitty and good ones?

vsc is a lightweight editor that contains only the very fundamental elements of an IDE, and is extensible with downloable plugins.

Visual studio is a large IDE/Project Manager that does a lot of things that a company building large projects can need but that as a lone programmer you will never use.

VSC is the superior choice if you're just coding on your lonesome. However remember that it doesn't come with a c/c++ compiler so you have to download that separately

Yeah but now that web assembly exists you can use a sane language.

>also a good suggestion but javascript is probably more beginner friendly if you have no experience with compilers or cs in general
not the other guy, but js is a terrible language for beginners. Ugly syntax, millions of pitfalls (especially with callbacks, 'this' and global vs local vars), and too dynamic / unstructured.

Don't get me wrong, I think js is totally fine (wouldn't rate it as favorite but don't hate it either). But C# is just so much more beginners friendly. The C# compiler actually makes it hard for you to make mistakes.

The only thing a beginner needs to worry about in C# is garbage.

ledge forgiveness is casual as fuck, platformers are easy enough without the game basically cheating on your behalf

Is there a fairly simple way to use the full VS compiler with VSC?

unless you're making web games (and why would you) don't use web technology, it's awful

>The only thing a beginner needs to worry about in C# is garbage.

Wait i tought you dont have to worry about garbage collection in c# ?

I'd argue that a language with many pitfalls is much better for beginners. I started with C and it boggles my mind that people think it's a poor choice. Much better to face these kind of problems earlier than later.

It's a shame that editing in VSC under windows and compiling with gcc through wsl is a bit of a shitfest.

Is there any where to see the code of an already completed game for an example of what to expect?

>using a physics engine for a simple 2d platformer
Holy shit the armchair game developers on here

honestly most people these days are not ever going to have to go so low-level they're going to need to use C, you might aswell start with C# unless you want to be a hardcore engine programmer

Yeah, physics engine + 2d = pure shit

not that I know of, visual studio's compiler isn't standalone
just download mingw

They're good if your game actually uses it but the best plaftform physics are bounding box to bounding box / pixel collisions which you can easily do yourself

google dolphin island 2 github

what do you mean ?
you can program a shell task that uses gcc and just set it as the default build task

>tfw too brainlet to understand
its fucking magic
how do you even know what the right strings of code to put

The problem with JS as a first language is it uses a bizarre everything-is-a-function model that doesn't translate to anything else and the js culture is about jamming together a million frameworks and libraries instead of making sense or using sensible design.

It's also impossible to find good advice about it because the whole landscape changes every six months and 75% of the people who use it don't know what they're doing.

C# collect garbage for you automatically, but the garbage collector takes resources. If you create and "release" (release = lose all references to object) too many objects every frame, the GC will work too much and affect your overall performance.

In more extreme cases, if your code sometimes lose reference to large chunks of objects, the GC may cause lag-like behavior when it kicks in to clear them.

In general - if you have lots of 'new' in functions that are called every frame, and its for classes (structs behave differently) - you might have a problem with GC.. But ofc its a general statement and not always true.

There is a general thread on /vg/ for game devs, most people do 2d platformers over there

> it uses a bizarre everything-is-a-function model

doesn't really matter in practice, it's easily abstractable to "everything is an object" and it's pretty simple to do standard oop in javascript

I looked but I couldn't find it

/agdg/

Thanks for the explanation

Never coded something complicated enough where it could have an impact to notice it

Start with simple shit like text adventure, then go from there

>I started with C and it boggles my mind that people think it's a poor choice.
I don't think its necessarily bad to start with C (learning C / CPP does teaches a lot about the inner works, which is important), but gamedev is already quite overwhelming as it is, for beginners.

So he should at least enjoy an easier language.