[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

How do you program a 2d platformer?

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 163
Thread images: 10

File: 1340933502809.gif (87KB, 200x100px) Image search: [Google]
1340933502809.gif
87KB, 200x100px
How do you program a 2d platformer?
>>
Google it.
>>
>>390125740
By not forgetting minor stuff that make the difference between a shitty platformer and one that handle great, like jump input buffering & ledge forgiveness.
>>
>>390125740
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
>>
>>390126592
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
>>
>>390126948
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
>>
>>390126592
>>390127195
What language do you suggest?
>>
>>390125740
If (Jump = Pressed);
then Jump;
else;
noJump;
>>
>>390126592
What about double jump?
>>
>>390127475
>that kid who noJump-ed to school
>>
>>390127357
C#
try unity for your first game
>>
>>390125740
Download game maker and google how to use it, you moron.
>>
you don't
>>
>>390127357
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 : >>390127647
>>
>>390127357
honestly javascript
it's not a "real" programming language but you can make great games and publish to literally any platform
>>390127614
if state == air && doublejumped == false, allow double jump and set doublejumped = true
when you touch the ground again reset doublejumped = false
>>390127647
also a good suggestion but javascript is probably more beginner friendly if you have no experience with compilers or cs in general
>>
>>390127475
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?
>>
>>390127781
>it's not a "real" programming language

?????
>>
File: kamiko.jpg (82KB, 640x359px) Image search: [Google]
kamiko.jpg
82KB, 640x359px
How difficult to program is a game like this?
>>
>>390127807
are you simple ? increase the character's elevation until a certain threshold has been reached, then lower it until he reaches the ground
>>
>>390127807
If (Player.state == ground) {
moveVertically(Player);
}
else {
}

Hope that helps.
>>
>>390127901
it would take months or years depending how much daily time you can sink into it
>>
X = X + VelocityX
Y = Y + VelocityY
>>
>>390127475
I wish it was this fucking easy.
>>
>>390127815
meant to reply with this >>390128040
>>
>>390127807
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
>>390127815
I'd suggest box2d but there are plenty of 2d physics engines
>>390127869
java*script*
like I said you can do almost anything you want with it but on paper it's a scripting language
>>390127901
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
>>
>>390128085
well, it is in a way, once you have a functioning characters and all his associated states you already have a game
>>
>>390127807
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
>>
>>390127781
>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
>>
>>390128245
very true but think psuedocodes for beginners and what's easiest to understand off the bat

anyway best of luck OP
>>
>>390128117
>programming isn't measured in difficulty
That's complete bullshit. Some things are more difficult to program than others.
>>
>>390127901
Just programming? A couple weeks maybe.
>>
>>390127947
wtf my character won't stop jumping YOU RUINED MY LIFE!!
>>
>>390128117
>on paper it's a scripting language

and in practice that hasn't been true since the v8 engine was a thing
>>
>>390128270
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.
>>
>>390125740
That looks very good
>>
>>390128530
can you recommend a good IDE for javascript ?

Since jaavscript is so shit to read you would think a good one exist....
>>
>>390128387
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...
>>390128530
No compiler, doesn't run natively in any OS (except maybe chrome os?), just controls a browser...
>>
>>390128730
Visual Studio Code
>>
>>390128730
>js
>IDE
Unironically notepad++
>>
>>390128619
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
>>
>>390128730
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
>>
>>390128753
>>390128801
shut the fuck up you fucking idiot

>>390128730
this >>390128797

>>390128753
>just controls a browser

lol
and it has a compiler, v8 compiles it on the fly
>>
>>390128805
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
>>
>>390128924
>calling me an idiot for recommending notepad++
>implying I'm him
Literally all you need is syntax highlighting.
>>
>>390128730
Webstorm faget
>>
>>390128907
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
>>
>>390128974
lel this is what I get for assuming 4chan would leave the leading spaces for the shit in the loop
>>
>>390127781
but /g/ told me javascript is pajeet technology :(
>>
>>390128958
I've seen definately being used so often I sometimes have to stop and think about it when using the term
>>
>>390128924
I'm surprised somebody finally agreed with me on VSCode.
>>
>>390129102
It is, sadly it became popular
>>
>>390127901
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
>>
>>390129102
asking /g/ about programming is like asking /v/ about games
they're full of shitposters that just want to shit on <insert language here> and if you listened to them you wouldn't write a single line of code because everything is terrible
>>
>>390128619
That's what I was implying
>>
>>390129183
vscode is legitimately great, just needs time to grow
>>
>>390129183
What's the difference between VSC and Visual studio Datetime.Now.Year?
>>
>>390129042
How do they even work?
>>
>>390129193
get fucked functional memer
js shits on whatever meme language you would want to use for writing applications
>>
File: 729.gif (137KB, 340x340px) Image search: [Google]
729.gif
137KB, 340x340px
>>390129398
>>
>>390129378
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.
>>
>>390129351
VSCode is a very nice code editor and available on Windows, Mac, and Linux
VS2017 is the entire IDE
>>
>>390129205
>you can learn to code all this behavior in months.
Where do I start?
>>
nobody programs video games in javascript
>>
File: 1499748144950.gif (1MB, 800x533px) Image search: [Google]
1499748144950.gif
1MB, 800x533px
>>390127629
>>
>>390129525
google unity tutorials
>>
>>390129541
With html5 you can do some pretty cool shit. It's nice for prototyping since it's quick and easy.
>>
>>390129351
VSC is like Code::blocks with intellisense while VS proper is gigantic overcomplicated team enterprise collaboration project management contraption.
>>
>>390129541
Granblue fantasy
>>
>>390126271
Examples of shitty and good ones?
>>
>>390129351
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
>>
>>390129605
Yeah but now that web assembly exists you can use a sane language.
>>
>>390127781
>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.
>>
>>390126271
ledge forgiveness is casual as fuck, platformers are easy enough without the game basically cheating on your behalf
>>
>>390129686
Is there a fairly simple way to use the full VS compiler with VSC?
>>
>>390129605
unless you're making web games (and why would you) don't use web technology, it's awful
>>
>>390129709
>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# ?
>>
>>390129709
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.
>>
>>390129686
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?
>>
>>390128117
>using a physics engine for a simple 2d platformer
Holy shit the armchair game developers on here
>>
>>390129837
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
>>
>>390128117
>>390129923
Yeah, physics engine + 2d = pure shit
>>
>>390129774
not that I know of, visual studio's compiler isn't standalone
just download mingw
>>
>>390129954
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
>>
>>390129873
google dolphin island 2 github
>>
>>390129864
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
>>
>>390129837
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.
>>
>>390129824
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.
>>
>>390125740
There is a general thread on /vg/ for game devs, most people do 2d platformers over there
>>
>>390130205
> 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
>>
>>390130260
I looked but I couldn't find it
>>
>>390130352
/agdg/
>>
>>390130216
Thanks for the explanation

Never coded something complicated enough where it could have an impact to notice it
>>
>>390130139
Start with simple shit like text adventure, then go from there
>>
>>390129837
>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.
>>
>>390130426
Thanks, anon
>>
>>390125740
This is an amazing sprite, is this from a game?
>>
>>390130139
Coding is like minecraft just with words
>>
>>390130539
probably just a sprite, no game would have that much animation detail unfortunately
>>
>>390130336
Yeah but it's so much easier on the person learning if they're just doing one thing directly instead of one thing in the manner of something else.
>>
>>390130484
I can do simple shit up until a point, no problem, then I just suddenly fall off a cliff and flounder. It's usually shortly after I learn about functions.
>>
If dimensions == 3D
[DONT];

Any good engine from that point onwards will be set up for any 2D stuff you wanna do
>>
>>390130539
nope, it's an old sprite from an internet artist
>>
>>390127475
what the fuck is a "noJump"
>>
>>390130727
Learn about data structures. Start with trees because they're the most important.
>>
>>390130819
nothing, his else statement is useless
>>
>>390127357
Visual scripting is probably the easiest to understand since you can see what you're doing extremely easy. Tedious, but you see what's going on especially if it has a good debugger like UE4
>>
>javascript anything
don't listen to them, op.
c++ or c#
>>
>it's another "I'm not a programmer but I want to make le mario" thread
kys. Get a babies degree in the topic and you'll be competent enough to answer this shit yourself.
>>
Assembly or bust
You don't want to be a dirty casual, do you
>>
File: 1456403935988.jpg (21KB, 300x316px) Image search: [Google]
1456403935988.jpg
21KB, 300x316px
>>390130898
>C#
I would unironically rather use javascript.

It's been years since I tried it though so maybe they've improved it by now.
>>
>>390130998
but everything is better than javascript except visual basic
>>
>>390130956
Where did OP say that?
>>
>>390130998
javascript has to many memeframework.js
>>
>>390130998
>It's been years since I tried it though so maybe they've improved it by now.
I think they have. I remember also trying and disliking C# when it was still in early versions (don't remember which .net it was) but recently I picked it up again and now I find it to be a beautiful and easy language. Sure there are some limitations and I miss macros and proper templates, but most of the time its just a breeze, like programming in easy mode.
>>
how do you create such an art, op?
>>
>>390131108
Yeah you can collect the stickers and put them on your macbook.
>>
>>390131151
modern C# is also much better than Java.
>>
File: 1482794998645.png (134KB, 500x522px) Image search: [Google]
1482794998645.png
134KB, 500x522px
>Java = Javascript
>>
Guess this is the more technical part of /v/.
Is there a quick way to weight-paint a new mesh(body) to a skeleton in 3ds-max?
Currently customizing a body for skyrim - but I'll have to weight-paint it all and the skeleton is a mess to keep track of when you're not used to working with anything other than standard faces/verts.
>>
File: 1446407240488.jpg (20KB, 575x323px) Image search: [Google]
1446407240488.jpg
20KB, 575x323px
>>390131450
>>
>>390129730
It is about as casual as driving a car made after 1940.
>>
>ITT a debate about programming languages without caps-lock, rage or cursing
this thread has one of the more civilized debated on programming I've seen. this is a nice change.


Now lets talk about PHP vs nodejs...
>>
>>390131706
>Now lets talk about PHP vs nodejs...
i use neither but from what i know about php it's still better than anything javascript
>>
>>390131706
Hmm, a tough one. I think I'll choose suicide.
>>
File: 1460535982075.gif (336KB, 185x231px) Image search: [Google]
1460535982075.gif
336KB, 185x231px
>>390131706
>PHP vs nodejs
They're used for different things, aren't they?

Is there really anything to discuss?
>>
>>390131897
both can be used to develop server side
>>
>>390132005
But would anyone ever want to use php for real time shit with constant polling? That's what node is for isn't it?
>>
>>390132073
I would ask why would anyone ever want to use PHP for anything... but I think its more common to find the other way around, eg nodejs used for not realtime stuff.

btw I agree with you they are for different purposes, but I still see people argue about them all the time.
>>
>>390132073
Node is kind of for everything.
>>
>>390131706
>webshit languages in a 2d platformer thread
>>
>>390130581

How so? I am interested in this analogy.
>>
>>390132421
You need to code your mtx store in something :^)

>>390132513
I wouldn't get your hopes up.
>>
>>390132513
"X is like minecraft with Y" can be said about nearly anything..

don't even try to understand what he meant, it was nonsense.
>>
>>390129645
>shitty
La Mulana

>good
Shovel Knight
>>
just get unreal or unity, and download a fucking blueprint or whatever the name for unity is

easy as fuck, all you do is insert crap, no programming, there's like 90 minute tutorials on how to make a mario clone
>>
>>390132786
La Mulana wouldn't improve with "better" jumping controls. The remake makes 'em easier to deal with as-is.
>>
>>390132786
>AIDS: The Opinion
>>
>>390132513
It doesn't even make sense. Unless he means 'oh you're just putting building blocks for something better' which in the case can be said for almost everything in life.
>>
File: OOP_Objects.png (26KB, 538x351px) Image search: [Google]
OOP_Objects.png
26KB, 538x351px
>>390134659
I think what he meant is that in programming you create objects (blocks) and you put them together to create a full program.
>>
>>390134428
What's wrong with Shovel Knight?
>>
>>390135717
La Mulana is a masterpiece.
>>
>>390135856
shitty controls
>>
>>390129603
>Unity
LOOOOOOOOOOOOOL
>>
>>390127901
Depends how much functionality you want in your game, I could recreate that in less the a month but it will have no map, a very basic combat system and no menus

Just depends how deep you want your game to be
>>
>>390136171
What's wrong with unity?
>>
>>390132786
La-Mulana has ledge forgiveness though.
You can jump off midair after walking off a ledge Though the window is only 1 frame long
>>
>>390136532
Nothing, Im just messing with you. Have a nice day.
>>
>>390136630
Oh, so it's only about as hard as a standard SFIV link. No problem.
>>
>>390136532
How many good Unity games do you know?
There's a reason Unreal is the Go-To Engine.
>>
>>390125740
With a keyboard.
>>
>>390125740
Nobody will play it anyway. People disregard anything pixel and indie nowadays.
>>
>>390129525
Here
https://masbudiyono.files.wordpress.com/2009/09/programming-for-dummies.pdf
You can skim through the important bits in this and then just cobble together a prototype in UE4 within a day or two, then start working on it for real in whatever engine you want.
>>
File: 1505145684758.jpg (45KB, 560x388px) Image search: [Google]
1505145684758.jpg
45KB, 560x388px
>>390127357
GML which is the language used in game maker. It's pretty easy and made specifically to create 2d games.
Anything else is too complicated and boring. There are some great tutorials on youtube that help you to create your first game.
>>
>>390127357
Processing IDE.
>>
>>390127195
>avoid gamemaker entirely
I'm a retard with zero knowledge, why avoid Gamemaker anon?
>>
>>390131706
node is the future
>>
>>390125740
Start from doing colision detection.
Then implement moving and jumping.
Thread posts: 163
Thread images: 10


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.