[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 38
File: wow dude.jpg (178 KB, 934x1000) Image search: [Google]
wow dude.jpg
178 KB, 934x1000
old thread: >>54505857

What are you working on, /g/?
>>
FIRST4TRAPS!
>>
>>54510936
Second for D
>>
>>54510936
Just finished all my exams.

AMAA about theoretical computer science, cause I'm at the height of my understanding right now and it's all downhill from here lol

>>54510953
ye
>>
>>54510936
please stop the anime cancer on this board
>>
>>54510936
kys
>>
>>54511007
MOOOODS!
JUST BAN THIS SHITTER ALREADY!
>>
File: mallocast.png (1 MB, 1280x720) Image search: [Google]
mallocast.png
1 MB, 1280x720
>>54511007
KEEP OVERFLOWING THE STACK, HIME!

>>54510936
Now that exams are over I'm going to start working on my HDL again. And maybe write some simple networked game.
>>
File: 35426271_p0.png (651 KB, 561x800) Image search: [Google]
35426271_p0.png
651 KB, 561x800
>>54510936
nth for coq
>>
>>54511019
I'm sure on reddit, you would already have 3 automated bots responding to you about how your mod request has already been received and how your little feelings are special and deserve to be protected.

Stop posting this shit every thread.
>>
File: nsa.jpg (92 KB, 1366x768) Image search: [Google]
nsa.jpg
92 KB, 1366x768
>>54510993
>>54511019
>>54511062
>desperation

Listen, man, try to contribute something productive to this thread.

Does anyone know of any languages/projects that compile to Haskell? I know there are compilers that translate Haskell to JS, but that's the other direction.
>>
>>54511007
kys

>>54511033
kys

>>54511035
kys
>>
>>54511062
SUCK IT FAGGOT!
>>
Does writing NSIS scripts count as programming? Because that's what I'm doing right now.
>>
>>54511076
kys
>>
>>54511076
>mental illness
you should seek help tho
>>
Thinking about how to deal with reporting errors in my language's compiler.

The issue is that the language is written in a high-level form, which is then elaborated down to a core theory before doing type checking. So errors at the type checking stage that want to report the problematic code will print terms of the core theory, not what the user is expecting to see.

For example, the high-level data type of natural numbers could be encoded in the core theory as a W-type:
-- written
data Nat : Set where
zero : Nat
succ : Nat -> Nat

-- elaborated
Nat : Set
Nat = W Bool \{ff => Empty; tt => Unit}
zero : Nat
zero = sup ff \{}
succ : Nat -> Nat
succ m = sup tt \{tt => m}


I'm sure the user would rather see that a value wasn't of type "Nat" rather than "W Bool \{ff => Empty; tt => Unit}". This will be tricky.

>>54511076
What would be the point of compiling to Haskell? JS is basically the assembly of the web, so it makes sense to go the other way.
>>
>>54511076
>contriboot something productive
>animuuuuuuuuuuuuuuuuuuuu
>>
>>54511116
>assembly of the web
End you're self!
>>
>>54511133
Like it or not.
>>
>>54511116
>assembly of the weeaboo
ftfy
>>
File: indians5.png (44 KB, 753x772) Image search: [Google]
indians5.png
44 KB, 753x772
Which programming languages are going to be the top 5 languages in 2020?
>>
File: dpt.png (2 MB, 1696x2467) Image search: [Google]
dpt.png
2 MB, 1696x2467
>>54511116
I'm just curious. Sometimes people make DSLs which happen to build into a language they're familiar in. Haskell developers tend to be the type that more often understand parsers compiler theory and such, so I thought it would be interesting if I could find at least one example.

>>54511136
Yeah, it's a fact of life whether you like JS or not. He's going to get banned soon enough, don't worry.
>>
Anime babies should just leave /g/.
>>
>>54511120
Honestly, just kill yourself; you can't even program, why are you here?
>>
>>54511162
parsers and*
>>
>>54511162
>soon™
ZEN
E
N
>>
>>54511150
Java
C
C++
C#
D
>>
>>54511162
>it's a fact of life
Is JS really going to stay this ubiquitous?

Why is there no competition?
>>
>>54511175
>animooooooooooooooooo
>mental illness
>muh degeneracy
honestly, can you even average 2 ints?
>>
>>54511185
>no javascript
>D

>>54511150
C
Javascript
C++
Java
C#

In that order.
>>
>>54511212
kys
>>
>>54511150
Javascript
Coffeescript
Clojurescript
Go
ScalaJS
>>
>>54511175
Why are you responding to him?

People like that thrive off of the negative attention. They want to be the counterculture for the smug points.

Just let them tucket themselves out with all the kicking and screaming.
>>
>>54511162
>Haskell developers tend to be the type that more often understand parsers compiler theory and such

That's rich.
>>
>>54511195
int avg(int a, int b)
{
return ((a + b) / 2);
}
>>
>>54511229
>tucket
tucker

Although, tucket should be a word for something.
>>
>>54511229
>Let's just enjoy our mental illness
anon...
>>
>>54511252
nao u've dun it m8
>>
File: [tilting increases].png (27 KB, 500x500) Image search: [Google]
[tilting increases].png
27 KB, 500x500
>>54511162
>Haskell developers tend to be the type that more often understand parsers compiler theory and such
>>
>>54511252
What if I wanted it to be exponentially smoothed average?
>>
>>54511252
animeshits should off themselves
>>
>>54511252
>what is integer overflow
>>
>>54511290
is it anime?
>>
File: indians4.jpg (246 KB, 1017x873) Image search: [Google]
indians4.jpg
246 KB, 1017x873
Question 1:
Write a function to calculate an estimated size of one's penis by programmatically utilizing online sources of your choice.

This estimate should be based on two given inputs: race and height.
>>
File: xdress.png (1 MB, 1702x2471) Image search: [Google]
xdress.png
1 MB, 1702x2471
>>54511190
The biggest problem is the difficulty to debug translated code which has more than an arm's length difference from JS. Source maps are getting better over time though, and in languages similar enough to JS you can just debug your non-JS code in the browser as if it were JS. But still, even in a language like Coffeescript, which bases its entire type system and model for functions on JS, debugging can be a pain when things go wrong (especially in a poor environment like Safari). Then you have to look at the actual JS it generates and it's terrible.

The most versatile competition that isn't just a wrapper for JS is Emscripten, which ironically results in the most garbled horrific JS you'll ever see. Emscripten is so accurate though that when you debug, so long as you're not debugging the border between your code and browser APIs, you might as well just run the C++ natively and debug it there.

The downside? Emscripten also results extremely large JS files (used to be a lot worse), and sometimes getting things to be interoperable is a pain. For example, to make a game loop, you need to use a special setup to play nicely with JS's asynchronicity (you can't just sleep, that'd hang the browser window if it existed). Emscripten has been making leaps and bounds over time, though.

Hope this answers your question robustly. Also, bonus skirt image.
>>
public float psize (into race, into height) {
return Math.random()*8;
}
>>
File: threading.png (20 KB, 566x450) Image search: [Google]
threading.png
20 KB, 566x450
How have I fucked up. Errors aren't explaining shit to me/I'm retarded
pic related
>>
>>54511351
So something like Apache Cordova runs on Node.js, and Node.js is just a wrapper for Javascript?

Is the entire internet just Javascript wrappers at this point?

>>54511359
0/10, no APIs.
>>
My boss caught me sleeping on the job again. This coding job literally pulls me to sleep. He wasn't too made since my work was done but fuck. How can I make C interesting?
>>
>>54511401
More pointers
>>
>>54511370
std::thread t1(&TestingObject::graphics, this);
>>
>>54511401
More mental illness
>>
>>54511401
triple redirection!
>>
File: sicppat.jpg (286 KB, 1024x768) Image search: [Google]
sicppat.jpg
286 KB, 1024x768
>>54511370
I think you need to do
&TestingObject::graphics
but I rarely use C++ so just try it and see

>>54511398
Cordova doesn't use Node.js. It actually uses the JS environment of whatever browser it has available. But yeah, the JS world is a total mess of libraries abstracting each other at this point.

>>54511401
It's probably not C that's the problem, it's what you're being asked to do.

>>54511440
>indirection
>>
>>54511401
>C interesting
C is tedious. That's like asking how to make shelf-stocking in a hardware store interesting.

I mean, yeah, you could use a forklift as a skateboard and have lightsaber fights with flourescent tube light bulbs nigger-rigged to 9-volt batteries. But then people look at you funny and you might get fired anyway.
>>
Hey gee, can you average 2 numbers?
Let's make /dpt/ great again (none of this anime trapshit)!
>>
>>54511453
>C is tedious
>I'm below average
>>
>>54511455
#include <math.h>

i dont know what im doing help
>>
>>54511432
Thanks that worked
>>
>>54511401
If you C is that tedious, consider writing a C code generator in a higher level language to do the work for you.

Yo dawg, I herd you like to program...
>>
>>54511475

C is tedious, there's no way around that.
>>
>>54511370
By definition you need "this" to be passed to t1 in order for your method to execute, just "graphics" with no explicit receiver won't work. For a way to do this, either use a lambda or something like http://en.cppreference.com/w/cpp/utility/functional/mem_fn with a bind.
>>
>>54511475
C is tedious, though. Makes no difference whether you are competent.
>>
>>54511482
Maybe for the incompetent.
>>
>>54511497
Do you know what tedious means?
>>
>>54511432
>>54511491
Wait, ignore, that guy is right, the constructor of thread can manage it.
>>
>>54511495
>tedious tho
>trust me, I'm one of the incompetents
>>
>>54511502
Do you?
>>
>>54511528
It doesn't mean "difficult", that's for sure.
>>
>>54511491
There's no this, it's a static class man
>>
>>54511538
Putting "static" before a class declaration doesn't do anything in C++.
>>
>>54511530
>I don't actually know but it sure ain't anime
>>
>>54511538
>static class man
wew laddie
>>
>>54511538
graphics() has to be static too in order to do

std::thread t1(graphics);


(I think?)
>>
>>54511497

Not an argument.
>>
>>54511601
>DELETE THIS
I didn't mean to offend you.
>>
>>54511549
Oh, oops. I was thinking like he had put static before the member functions. My bad.
>>
>>54511596
>>54511549
>>54511616
solution found, ty anyway
here: >>54511432
>>
>>54511615

Still not an argument.
>>
gulp vs grunt vs bower: go!
>>
>>54511649
>gulp vs grunt vs bower
One of these things is not like the others.
>>
https://www.youtube.com/watch?v=oUzXEV5qigQ

standard rectilinear projection is no good when the viewer is far away or the screen is too small! it's why console games have such narrow fov. in this video with just 120 fov everything is distorted like crazy and the things you focus on in the center of the screen are tiny unless you view it in full screen and sit very close to the monitor
>>
>>54511668
>I'm the real webshit
o-ok
>>
>>54511649
why does that girl have a bulge in her pants?
>>
>>54511674
>unless you view it in full screen and sit very close to the monitor

Well, that's sort of the point. People who play PC games are generally playing them in fullscreen and are sitting close to the monitor.
>>
>>54511704
yes but imo it's not the optimal solution in all situations for example mobile games
>>
>>54511699
she's a programmer
>>
>>54511717
>mobile games
please
>>
>>54511674
I usually shoot for ~130 FoV on my 21:9 35" ultrawide that I sit right in front of.

You wouldn't use that FoV on a narrower screen you're setting far away from.

>>54511717
>it's not the optimal solution in all situations
Who said that it was the optimal solution?

I don't understand why you're in /dpt/ posting about this.
>>
>>54511733
sorry i forgot this is the steam greenlight only unity babby thread
>>
>>54511755
>mobile baby
anon...
>>
>>54511764
>unity babby
kid...
>>
File: tegaki.png (6 KB, 800x400) Image search: [Google]
tegaki.png
6 KB, 800x400
>>54511674
>>
why should i use enums instead of
#define WAIT 0
#define CALL 1
etc
>>
File: tegaki.png (5 KB, 400x400) Image search: [Google]
tegaki.png
5 KB, 400x400
>>54511777
Furthermore.
>>
>>54511212

This sounds like a reasonable assessment. Maybe Python in there somewhere.

>>54511252

assert(avg(INT_MAX, INT_MAX) == INT_MAX);


>>54511401

Get a better sleep schedule. If you have your programming done at work and you still have time, there's always still work to do. Run it through rigorous tests. Help your coworkers with anything they're having difficulty with. Ask your boss if he has any more work to do. You want to get a promotion to a job you might enjoy more, show your boss that you won't be the kind to sleep on the job, but instead, take action without being told he needs to.

>>54511370

>static class TestingObject

This isn't a thing in C++. The only reason C++ allows the keyword static before the keyword class is to allow you to create a static object of that class in the same statement as creating the class.

https://codeyarns.com/2012/01/10/c-static-class-definition/

So remove the static keyword. It's an eyesore, and it makes you look like you're a retard trying to write C# in C++.
>>
>>54511811
can't see shit captain
can't look around easily because shit controls captain
>>
>>54511828
Okay.
>>
>>54511777
>PC wide
You'd need a seriously large monitor to be able to have your face at that relative distance.
>>
>>54511855
Yeah, it's a bit exaggerated.
>>
>>54511808
Because of scoping purposes, which also makes the code more clear. Other than that, I don't think there's much of a difference (maybe compiler implementation is different performance/memory-wise?)
>>
So let me get this straight. If I use SFML or OpenGL I need to have a main loop for them to keep the window open (presumably on a different thread). Inside that main loop I'd have to create an event system to check what needs to be drawn in the current iteration. This event system would then be accessed by the rest of the program to add shit to the next render.

Where's the graphic libraries that don't need a main loop. That can just window.drawPng(int x, int y, string file)
Then it's up to ME when I clear the screen and render the screen.
My uni has their own library for this but I thought I'd try SFML. Now I hate this fucking looping so WHAT DO
>>
>>54511961
What's the end-goal of your project?
>>
>>54511961
ffs just read this
https://www.packtpub.com/game-development/sfml-game-development
pirate it/dl source code

good book
>>
>>54511961
You don't need a loop, you don't need multiple threads.

It completely depends on what you're trying to do.
>>
>>54511972
I'm currently just setting up the generic base. The different controllers which get user input and output. I guess eventually I'd like to make a simple platformer to test my self. But I'm writing this initial part generically enough so I can use it as a start point for multiple projects.
>>
>>54511961
You don't need a main loop for OpenGL. Not sure about SFML but I doubt you do there, either.
>>
>>54511961
in SFML it is up to you to draw and clear the screen
you need to call the draw function on the texture
>>
>>54512001
>>54512017
>>54512023
If the method that creates the window ends, the window closes. Hence you need it to loop until the end? Or is there another way?
>>
>>54511961
What the fuck is wrong with message looping? You are the first person I have ever known to have a problem with the message loop system. Just fucking use GLFW and set the loop to
while(!(glfwGetKey(window,GLFW_KEY_ESCAPE)))
>>
>>54512040
Why not just redraw when needed and close the window when the code says to close the window?
>>
>>54512064
because your loop won't only contain methods to draw but several different things
>>
>>54512057
Because it just makes everything more difficult?
I can't write a method in my graphics manager called DrawPNG(int x, int y, string file). Because it can't pass it into the main loop to be drawn directly.
It has to be added to some storage array to be temporarily held until the loop is at the point where it checks the array?
I'm probably fucking retarded but that's what I think I have to do right now...
>>
>>54512111
Why not just have a loop for the several different things?

If the GUI is going to sit there completely static for 10 seconds, why do I have to loop constantly during those 10 seconds?
>>
>>54512133
Is this your first time working with a state machine?
>>
>>54512040
>Or is there another way?
some libraries will keep it open for you.

Fundamentally you can make a thread that sleeps, and wakes up when events are triggered.
>>
>>54512133
>Because it can't pass it into the main loop to be drawn directly.
Why would it not be able to draw immediately whenever you call it?
>>
>>54511150
C
C
C
C
C++
>>
>>54512156
I've learnt about FSM but not really sure how this applies now

>>54512176
Because if it's looping, in a thread, lets say called GraphicsLoop(). How do you pass data to that loop directly? You can't? You just have to store it in an array that it will look at during it's loop? Right?????
>>
>>54512205
This is not how anything works. Not games, not UI frameworks.

In games, you often have a "game loop". and in that you have *everything*. Game logic, graphics, sound everything. You don't have a graphics loop and a game logic loop, they are just 1. The game logic is generally at the start of the loop and the graphics stuff is at the end of it.

You almost never use different threads to try to draw things for a lot of reasons. One of which is cross thread latency. Another is that it quickly becomes a cluster fuck, so you better have a real good reason to use a separate thread.
>>
>>54512151
>why don't I just hard code entire seconds of visuals, rather than having the computer do it for me

Because for most people, their time is worth considerably more than a CPUs.
>>
>>54512319
I don't disagree with you on that. Maybe I'm misunderstanding the concept of shoving everything into one loop.
>>
>>54512279
I've spent about 100 hours developing the rest of the logic though. I've split it all up into different controllers. I wanted to keep my input, logic, and output completely separate. I made my own looping system which logs everything, and maintains a constant loop time using the system clock.
The last piece was to hook it up to a graphics library. But apparently the graphics library wants to BE MY LOOP. wtf. Why do I feel like it's overstepping. The graphics was going to be the tiny part.
>>
>>54512356
most graphics you just register shit to draw and when you've registered all that shit, you call the draw function.

what graphics library are you using that "wants to be the loop"?
>>
>>54512346
Some things will be on the screen for a long time, and some things will be there for a single frame only.

The point is, unless you have different loops for "held" vs single frames, you need each iteration of the loops to take the same amount of time.
Also, you probably want to be checking things even if the screen isnt changing, otherwise it's gonna take forever to respond.
>>
>>54512356
>But apparently the graphics library wants to BE MY LOOP.
If you already have a loop than just do all your draw calls a the end of it. Whats the big deal? Just about every graphics library I can think of allows this.
>>
>>54512396
SFML
I posted this above
"If the method that creates the window ends, the window closes. Hence you need it to loop until the end? Or is there another way?
"
But I think OpenGL does the same thing
>>
>>54512421
see>>54512423

though I may be retarded
>>
>>54512423
>If the method that creates the window ends
that should be thread, not method. Just create the window in your initialisation code and draw to it at the end of your loop.
>>
>>54512423
dude what?

I've never used SMFL but I've used SDL / OpenGL.

Most often you create a rendering context (the window) and when you're done, you destroy that context. There is no "end of method" shit like you're talking about. You create the window, draw a bunch of shit to it, and when you're done you just destroy it as part of your "end of life" routine for your controller.
>>
File: Untitled.png (46 KB, 818x505) Image search: [Google]
Untitled.png
46 KB, 818x505
>>54512423
Proof that you do not need the message loop in OpenGL. At least not with GLFW.
>>
>>54512458
Okay I'll give OpenGL another crack then

>>54512444
That's a good point actually. That could work. It'd be confusing in the overall look of my loop but I could put up with it.

thanks anons
>>
>>54512444
This could work. It'd look weird in the context of my project but I'll give it a go.

>>54512458
Okay I'll try to use OpenGL again

>>54512498
thanks anon I'll try this too
>>
>>54512205
did you make a multi-threaded system and didn't think about communication between those threads?
>>
>>54512567
>It'd look weird in the context of my project but I'll give it a go.
What were you expecting to do?
>>
>>54512578
No it's one thread I just thought I HAD to make another thread for the graphics loop. Thanks to someone on the previous /dpt/
>>
File: the loop.png (28 KB, 800x600) Image search: [Google]
the loop.png
28 KB, 800x600
>>54512586
It's just that the MasterController will have to create the graphics window and pass it to the OutputController. Because otherwise it'll close (using SFML anyway...) because .output will end
>>
>>54512665
anything that isn't data, i.e. thing that change, shouldn't be going through THE LOOP and should be in your master controller.

so the master controller has some method "draw" which does all that shit. on creation in makes the window. on destroy it destroys it.

why doesn't that work?
>>
>>54512711
Master controller is only there for the management of the sub controllers. It manages how fast the loop runs, and provides debugging information.
The other controllers communicate between themselves Nothing is passed up to MasterController.
>>
>>54512665
Why can't the output controller create it?
>>
>>54512747
from what i'm understanding the output controller gets allocated and destroyed each loop or something
>>
So if I'm making a game, should I keep graphics, logic and input as 3 separate threads?

Should the game loop be on a different thread?
>>
>>54512747
Because if the method that creates the wndow ends, the window closes for some fucking reason
>>
>>54512762
Where did you read that? That's garbage. You just need to stop the tread that created the window from terminating.
>>
>>54512761
no. Everything should be on one thread.
>>
>>54512761
depends on your experience with threads and how big of a game you're making.

typically graphics & input are going to be on the same thread because input comes from the graphics context (the window).
>>
>>54512780
Ugh welcome to my past 2 hours
I don't know why but that's what SFML is doing
Trying OpenGL now if I can stop filling out 4chan captchas
>>
>>54512800
How am I supposed to keep a consistent framerate tho?
If both the input loop and graphics redraw are in the same thread, the game will run only as fast as my input loop
>>
>>54512810
SFML has no way of knowing what method created it. You're getting mixed up some place.
>>
>>54512810
you don't know why you're destroying the window?
post some code because this shit is getting everyone no where
>>
>>54512830
i'm assuming you're using some graphics libraries. they spawn threads behind-the-scenes so you don't have to deal with them. this means your input/graphics/logic will all be non-blocking in the loop
>>
File: Untitled.png (77 KB, 1157x624) Image search: [Google]
Untitled.png
77 KB, 1157x624
>>54512762
What do you mean?
>>
File: 7846658.jpg (44 KB, 651x335) Image search: [Google]
7846658.jpg
44 KB, 651x335
Can anyone tell me why vim is (comparably) slow on Mac OS X?

E.g. if I do a visual block selection, and an insert, and press ESC, in vim it takes ~3 seconds for the changes to appear.

If I do the same thing in Emacs with evil mode, it's instantly.
>>
>>54512761
There would be no point, they have to happen in lockstep and in sequence anyway (no logic to do without input, nothing to render if nothing has moved), spinning up multiple threads would just incurr overhead.

What you should use multithreading for in a game is offloading async work to background threads like asset loading, sound mixing, procedurally generated content, maybe building certain auxiliary data structures for collision detection, etc.
And of course the actual rendering or physics could be multithreaded, but the main loop (get input, update, draw) should be your synchronization point.
>>
>>54512762
just make a sf::RenderWindow in your windowcontroller class and it won't close unless you tell it to
>>
>>54512796
>Everything should be on one thread.
Isn't this horrible advice? Wouldn't slightly complex calculations lock the game briefly and make it stutter?
>>
What's the go-to source for learning Haskell?
>>
>>54512830
Don't use any blocking calls when getting input, you should just be polling the current state of the keyboard, mouse, gamepad, etc.
>>
>>54512982
Most of the really cool tricks are inside the heating sleeves of Hot Pockets™ Pepperoni-Flavored Sandwiches™
>>
>>54512982
Your local retirement community.
>>
>>54512975
this is true but no one here is making their own gaming engine for the next AAA 3D game.

a single-threaded 2d game is fine for hobby/learning
>>
File: fucking SFML.png (48 KB, 1201x481) Image search: [Google]
fucking SFML.png
48 KB, 1201x481
>>54512887
>>54512832
It pops up for a split second then closes
>>
>>54513010
That's like teaching someone who is writing their first data-driven GUI to not async out the database call because the 5-line, locally hosted query is basically instant.

Why not do it right the first time?
>>
>>54513010
That's a pretty black and white way of looking at things. There is a massive middle ground between Skyrim and Cave Story.
>>
>>54512975
>Isn't this horrible advice?
no
>Wouldn't slightly complex calculations lock the game briefly and make it stutter?
yes. Multiple threads doesn't solve this though besides some exceptional scenarios. Making a game run faster by using multiple threads is very very tricky. Some game/physics/graphics engines will do some of this for you behind the scenes, but it's unwise to try it yourself unless you have an exceptional reason.
>>
>>54512975
How would another thread help?
Still not gonna have that calculation ready, so you will render the last known state which will look like the game froze at that point.
>>
>>54513019
you're letting main() end. Don't do this.
>>
in C/C++, is:
*x // as in dereference

the same as:
x[0]

?
>>
>>54513024
first you must learn to make a game

>>54513028
i'm sure cave story uses 3d rendering for lighting and plus it has music/etc. please stop looking for things to argue about. neither of those games are "hobby/learning" tier
>>
>>54513040
>>54513046
Say you're continuously calculating the trajectory of a ball.

Rather that stuttering the game when the calculation is made, the music, background, timer, etc all continues while the physics choke for a small, unnoticable amount of time. It's more noticeable when literally everything freezes, rather than one small item.
>>
>>54513062
No I'm not? It's still doing the getline?
>>
>>54513070
Yes.
>>
>>54513088
No I'm saying you are an idiot for assuming we are all making shitty, baby pixel platformers when it is inherently untrue.
>>
>>54513126
/dpt/ is /beginner programmer general/ friendo
>>
Any opengl es c++ wrappers for plebs?
>>
>>54513104
Replace getline with std::cin>>str; so we can see the results.
>>
will i need a skirt to do the needful and becoem a petter programmer?
>>
>>54513126
but you are LOL
>>
>>54513097
>unnoticable amount of time
if it's unoticable then why not let it choke the main thread? A dropped frame is very noticeable.

>It's more noticeable when literally everything freezes, rather than one small item.
Even if you think that it's much much much easier just to use on thread. Doing stuff like physics on a separate thread creates a lot of overhead. The main thread has to message the physics thread about work it wants it to do. Then when the physis thread is done it has to message back the main thread. This alone can be a 20ms round trip (someone correct me on this, maybe there's more efficient ways). Not to mention the added complexity of deadlock and race conditions. Avoiding this creates more overhead. Sometimes a huge amount depending on what you're doing.
>>
>>54513164
Nice, you rekt me good son.
>>
>>54513097
If sound, physics and rendering are all completetly decoupled in seperate threads they would go out of sync if one of them doesn't hit the target framerate, and from that point forward you'll forever have say the sound in the future X seconds (so you'll hear something before you see the action which caused it ).

Sound, physics and rendering must all be synced at 60 Hz (or w/e your framerate is), and they must all hit it.
>>
>>54513189
suck my cock u lil gay boi LOL
>>
>>54513149
Same result. I also put a loop in Main(), looping 9999999999 times (takes a few seconds), and the window doesn't stay open any longer.
>>
>>54513104
Which takes <1ms to complete. Then the method ends.
>>
>>54513198
Put it at the exact moment before the window closes.
>>
>>54513201
see >>54513198
>>
>>54513201
Doesn't getline() wait for user input?

Main shouldn't end until something is entered in the console.
>>
>>54513198
because that sf::RenderWindow goes out of scope as soon as SFMLManager::CreateWindow finishes.
You have to make that renderwindow a field in that SFMLManager class, and then in CreateWindow use window.create(allthatstuff ...)
>>
>>54513228
No.

Cin waits for user input.
>>
>>54513215
and you're surprised why?

I'm not a c++ guy, but do something like:
while(true) {
getLine(blah);
Thread.sleep(16);
}
>>
>>54513150
of course bb
>>
Anyone here have any tips for staying awake during software testing?
>>
>>54513243
I have
private:
sf::RenderWindow window;
in SFMLManager.h

>>54513214
What?
>>
>>54513320
Masturbation.
>>
>>54513320
Hook up a failed test assertion to a stun gun.
>>
>>54513323
Forget it, have you tried creating the window in main instead of in a function? The problem could be scoping.
>>
>>54513358
you're gonna fall asleep during your afterglow

>>54513320
Take off your clothes.
I'm assuming you're in an air conditioned cushy building.
The cold will keep you awake.
>>
>>54513323
You have a member and are not using it. in the body you've redeclared a new window

do this->window(...), not what you have.
>>
Hello guys I'm a senior in high school taking a pre ap comp sci class our final is to make a game. I wanna just make a simple space invaders type game and I was wondering what exactly am going to need to accomplish this and also are there any good tutorials I can watch?
>>
File: shit.png (29 KB, 683x649) Image search: [Google]
shit.png
29 KB, 683x649
I know I'm going to catch shit for this but my project is due in 40 min

I have the solution already but it won't compile for some reason. I keep getting Exception in thread "main" java.langNumberFormatException: For input string


it's this one right here.
http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-092-introduction-to-programming-in-java-january-iap-2010/assignments/MIT6_092IAP10_assn07.pdf

The code is right but it won't compile. It's cool if you guys don't want to help. I'll just submit as is
>>
File: 1417911861742 (2).jpg (9 KB, 145x119) Image search: [Google]
1417911861742 (2).jpg
9 KB, 145x119
>>54513421
>Notepad
>>
>>54513374
Well the whole problem is that I don't want to use a loop. The solution is finding a way so that the window doesn't close at the end of the method it's made in. So moving it to Main proves nothing. Of course the window will stay open if I put cin >>str after it. It stays open when I do that in CreateWindow().

>>54513388
see pic
>>
>>54513421
pastebin the code

why are you using a fucking text editor
>>
>>54513421
sounds like parseInt is failing. Haven't used java in awhile, does it have the equivalent of a tryParse? you could debug by printing out the result of a split before parsing and summing.
>>
File: Capture.png (5 KB, 689x52) Image search: [Google]
Capture.png
5 KB, 689x52
>>54513451
>>54513388
oops here
>>
>>54513421
convert the boolean to a string? can't test your code if it's in an image.
>>
>>54513451
I'm not telling you to use a loop, I'm telling you to take all the things you placed in functions and put them in int main()

A function has its own "scope" and when the function ends everything declared in it is discarded with the exception of whatever is "returned" and whatever values you pass to it as pointers.
>>
>people trying to do graphics programming when they don't even understand the language they are working with
>>
>>54513462
is the manager static?
>>
I believe my C skills are pretty good now. What do I write now, so I can practice? I though of comting to the linux kernel, but I have no idea where to start?
>>
>>54513487
>Why even learn things if you don't already know them!
>>
File: sagsag.png (27 KB, 1268x444) Image search: [Google]
sagsag.png
27 KB, 1268x444
>>54513323
it works
>>
File: int.png (181 KB, 713x833) Image search: [Google]
int.png
181 KB, 713x833
I'm working on a C program for a microcontroller. Currently learning about interrupt handling. Pic related, is there any difference between the three different ways of declaring an ext. interrupt service routine?

Currently I am using it like this:

ISR(INT0_vect) {

}
>>
>>54513455
>>54513465
http://pastebin.com/xZMVACyb
>>
>>54513479
My point was that it works in main but offers no solution.

>>54513499
Nope

>>54513514
OMG THE SOLUTION.
So I was using the RenderWindow constructor, instead of .create(), which takes the same fucking parameters. One of them closes after the current method ends. One of them doesn't. Fuck me. Thanks everyone ima go kill myself
>>
File: Capture.jpg (60 KB, 1722x308) Image search: [Google]
Capture.jpg
60 KB, 1722x308
>>54513505
Not the point, you don't seem to understand basic C++, which is sort of a requirement before doing anything more advanced with it.
>>
>>54513562
What is the exact error you're getting?
>>
>>54513501
Write a heap allocator first.
>>
What's the point of getters and setters?
>>
>>54513562
System.out.println(fileName + " is magic? " + testMagic(fileName))


testMagic() returns a boolean.

Does Java implicitly convert that to a string?
>>
File: j.png (6 KB, 624x100) Image search: [Google]
j.png
6 KB, 624x100
>>54513609
>>
>>54513581
>So I was using the RenderWindow constructor, instead of .create(), which takes the same fucking parameters. One of them closes after the current method ends
No, that was not the problem.
>>
File: bewaretheneckbear.png (1 MB, 1000x7835) Image search: [Google]
bewaretheneckbear.png
1 MB, 1000x7835
>>54511266
>>
>>54513629
Sanitizing your inputs and preventing compatibility issues between different API versions.

It's really only useful if you're writing a robust library, but if your setters and getters do nothing but assign a single variable, they're basically pointless.
>>
>>54513623
What do you mean exactly? Doesn't malloc do it?
>>
>>54513642
Comment out the
sum += Integer.parseInt(par);


Instead, print out all of the 'parts' with println.

What is your output?
>>
>>54513581
>So I was using the RenderWindow constructor, instead of .create(), which takes the same fucking parameters
Which doesn't matter, they do the same thing, however, you created a window inside your "CreateWindow" function, that window gets destroyed as soon as that function returns.
>>
>>54513358
>>54513385
I work in an office were everybody can see everybody else. So that isn't going to work.

>>54513359
I'm 90% certain that stun guns are illegal were i live. I do have access to plenty of 24V power supply's though.
>>
>>54513599
I wasn't even the person you were arguing with. I was just interjecting to call you a simp.

If you're struggling with something you are passionate about you double down not give up.
>>
>>54513629
So that you can do things when a value is retrieved or modified.

You can make the set private, or you can make the getter return an arbitrary number of pictures of penises.

The sky is the limit.
>>
>>54513629
they are the anti-pattern of OOP
>>
>>54513070
Yes. In-fact, x[offset] is syntactic sugar for *(x + offset), so 0[x] would work too (but don't do it)
>>
>>54513686
>>54513646
Oh it was because I was making a variable insite CreateWindow, and not the same one as the private variable which is saved.
Either way it works now so im out
>>
File: 1334439603801.png (70 KB, 208x193) Image search: [Google]
1334439603801.png
70 KB, 208x193
>>54513678
You wonderful bastard. That fixed and it compiled. I don't understand why but thanks my friend

I owe you big time
>>
>>54513740
lmao dude do u not understand local scope?
>>
>>54513752
Yeah I understand but I just thought I was storing it outside of that method
>>
>>54513743
What

No, I was trying to get you to understand why it was breaking.

The issue was that your strings weren't in a format that was able to be parsed into integers.

That was a debug test, not a 'fix'.
>>
>>54513126
>Stop talking to me as if I'm some kinda noob asking for advice about super basic shit on a Mongolian cave painting gallery.

If you knew what you were doing, you wouldn't have to ask kid.
>>
>>54513455
What's wrong with using a text editor?
>>
>>54513780

It's too late. He probably already submitted it.
>>
File: GY!BE3.jpg (322 KB, 1440x900) Image search: [Google]
GY!BE3.jpg
322 KB, 1440x900
Did a crash course on Python so that I can try Cython out
Now I'm going to be looking at the Linux kernel source code
>>
>tfw making a program to help sort and tag porn

I don't know whether to feel positive about having a goal and useful end point to work towards, or sad about the tragic purpose it will be used for.
>>
File: wtf.gif (1021 KB, 235x156) Image search: [Google]
wtf.gif
1021 KB, 235x156
>>54513743

Another CS student passes with flying colours everyone!
>>
>>54513894
>Anonymous image board
Why are you assuming I was asking for help? Do you think it's just me and you in this thread?
>>
Can't sleep.
>>
>>54513979
Can't get a gf
>>
>>54513979
Can't wake up
>>
>>54514009
Same
>>
>>54513977
Why are (You) assuming that the same advice would be given to other anons who actually seem to understand what they are doing?

If you tell someone "well the proper way to do it is x, but you're not ready for that yet so use y" they are likely to just go ahead with x anyway to "save time".
To get around this, people will just tell someone that y is the best method and let them work out when it's best to change methods on their own.
>>
>>54514049
I want some (You)s
>>
>>54513979
drink a bottle of hard liquor as fast as possible. always makes me sleepy
>>
>>54514009
Can't get a bf
>>
>>54514070
Let him put it in your ass, and then in your mouth immediately afterwards.
>>
How do I create C-style strings in javascript?
>>
>>54514070
are you a grill?
Thread replies: 255
Thread images: 38

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.