Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1211188 Posts in 52538 Topics- by 43347 Members - Latest Member: polm

April 30, 2016, 04:27:04 pm

Need hosting? Check out Digital Ocean
(more details in this thread)
  Show Posts
Pages: [1] 2 3 ... 15
1  Feedback / DevLogs / Re: pixellated platform game thing dot exe on: September 20, 2015, 12:03:25 am
Spent a couple weeks writing gui for editing my skeleton sprites, until I realized that I would be much happier if I could just hot load editor resources whenever the text file changed, and just modify it in my text editor. Sheesh.
2  Developer / Technical / Re: ProgramGamer toys around in C++ on: September 03, 2015, 12:45:56 am
No problem! I have free time and thick books Wink
3  Feedback / DevLogs / Re: pixellated platform game thing dot exe on: September 02, 2015, 06:10:31 pm

more debug visualizations. minimap, player position, camera regions, camera constraint bounds.
4  Developer / Technical / Re: ProgramGamer toys around in C++ on: September 02, 2015, 05:39:09 pm
Right! Classes. Not objects. 3am typing ahoy.

I think that the goal of a practice project shouldn't be to learn general practice, it should be to learn the nuts and bolts of the language. The worst classes I ever had were the ones that treated dogma as the basics.
5  Developer / Technical / Re: Unity2D - Checking intersection between a triangle and a rectangle on: September 02, 2015, 12:08:09 am
Instead of angles, you could also work in vectors.


A, which is the right angle to the direction of the second to last point from the last point, and
B, which is the direction between the last point and the player.

Then, if A dot B is greater than one, delete the last point.

If you just do a raycast to the second to last point, you can get into situations where the angle is right for the point to be removed, but the player is still blocked by some other object and it doesn't let go. As an example, picture that the rope is attached where it is in the picture, but that the player somehow ended up under the platform on the left.
6  Feedback / DevLogs / Re: pixellated platform game thing dot exe on: September 01, 2015, 04:12:29 am
First pass on multi-screen rooms. Taste teh raneb0w
7  Developer / Technical / Re: ProgramGamer toys around in C++ on: September 01, 2015, 03:18:02 am

sounds like a great party to me!
if you're interested, I know exactly why your program wouldn't compile when you divided everything up.

C and C++ programs are compiled into 'translation units', which are basically little tiny libraries that make up
a portion of a program. You can see this directly if you compile without linking, which will produce a number of
object files, which are functionally the same as a translation unit, as far as I am aware.
When you declare a global variable, the variable is global only to that translation unit. To be able to
see that global variable from another translation unit, it has to be able to see it through a link.

When you build an exe, the linker resolves links between the TUs to detemine how they 'see' one another.
The reason that your globals weren't working was actually because #include pastes the entire contents of a file
wherever it's written. So, for instance:

Code:
//highlander.h
#pragma once

int highlander;
int give_supreme_power();

Code:
//highlander.cpp
#include "highlander.h"

int give_supreme_power() {
   if (highlander == 0) {
      highlander = 1;
      return 1;
   }
   return 0;
}

Code:
//main.cpp
#include <cstdio>
#include "highlander.h"

int main() {
   if (!highlander) {
      printf("quickening highlander!\n");
      if (give_supreme_power()) {
         printf("OH YEAH\n");
         if (highlander) {
            printf("ROLL CREDITS\n");
         } else {
            printf("wait what\n");
         }
      } else {
         printf("huh, guess we already did that\n");
      }
   }
}

using msvc, that doesn't compile. "int highlander" is multiply defined, because that code is completely identical
to this:

Code:
//highlander.cpp
int highlander;
int give_supreme_power();

int give_supreme_power() {
   if (highlander == 0) {
      highlander = 1;
      return 1;
   }
   return 0;
}

Code:
//main.cpp
#include <cstdio>
int highlander;
int give_supreme_power();

int main() {
   if (!highlander) {
      printf("quickening highlander!\n");
      if (give_supreme_power()) {
         printf("OH YEAH\n");
         if (highlander) {
            printf("ROLL CREDITS\n");
         } else {
            printf("wait what\n");
         }
      } else {
         printf("huh, guess we already did that\n");
      }
   }
}

since #include is just dumbly pasting in. Obviously this can't work, because there can only be one highlander.
the extern keyword lets the linker know that it should find a global variable with the same name.  Just defining an extern variable isn't enough, just the same way that putting a phone number for a nonexistent pizza place into your local phone directory doesn't mean you can now order pizza, if you couldn't before.  The thing that the extern is linking to actually has to exist in exactly one of your source files.

So, this version of the example works:
Code:
//highlander.h
#pragma once

extern int highlander;
int give_supreme_power();

Code:
//highlander.cpp
#include "highlander.h"
int highlander;

int give_supreme_power() {
   if (highlander == 0) {
      highlander = 1;
      return 1;
   }
   return 0;
}

Code:
//main.cpp
#include <cstdio>
#include "highlander.h"

int main() {
   if (!highlander) {
      printf("quickening highlander!\n");
      if (give_supreme_power()) {
         printf("OH YEAH\n");
         if (highlander) {
            printf("ROLL CREDITS\n");
         } else {
            printf("wait what\n");
         }
      } else {
         printf("huh, guess we already did that\n");
      }
   }
}

And that should be that! that last one will compile.

As a bonus, you can see the global initialization rules in action in this program. Since we expect highlander to start as zero, all we have to do is name it.

All in all this kind of looks more like a C program than a C++ program with all those structs instead of classes with all public members. Might want to look into that. Also you're still seemingly putting everything into the same file altho you're no longer putting everything in the main function. Might want to split stuff up a bit? Learn how to do classes properly with a header and a source file? You generally put the class definition in a .h or .hpp header file and the implementation in a .cpp source file and then just include the header from where you need the class.

Using 'structs' or 'objects' to name your data structures has nothing to do with their 'object orientedness', it has to do with how their data is accessed. Really, both are identical in memory, it's just that all fields of a struct are public by default, and all fields of an object are private by default. Unless it's super duper important that access to a field be hidden, having to write a bunch of getters and setters to basic values is lots of typing for absolutely no gain. If everything in all of your objects is public anyway, calling them structs does nothing but save keystrokes.

Hope that helped in some way! There's a lot of stuff I wish someone had told me about C++ when I was starting out, so I'm happy to share. I mean, assuming you want to read all this gnarly gibberish Blink
8  Developer / Technical / Re: ProgramGamer toys around in C++ on: August 30, 2015, 02:22:25 pm
Sort of! C and C++ have very specific rules for how global values are stored. All global and static variables are stored in a pair of segments in the executable; one for initialized variables, and one for uninitialized. They're pretty much laid out exactly how they'll be in memory when the program runs, except the uninitialized variables have a count of the number of zeros they need instead of a value. I've got a book that explains it in a lot more detail, but that's the gist of it. so if you make some array of char doop[999999999] your executable will get larger by the size of the definition of the global variable, but the size of your running program in memory will get larger by 999999999 bytes.

My example earlier wasn't for globals, it was for variables allocated on the stack (ie. within a function without using 'new' or 'malloc' or whatever). Here's a more clear example:
Code:
struct dog {
   int fleas, hunger;
};

void dogStuff() {
   //fido is unknowable
   dog fido;
   //rover is without fleas or hunger
   dog rover = {};
   //peppy is a little itchy and hungry
   dog peppy = {1, 1};
}
9  Feedback / DevLogs / Re: pixellated platform game thing dot exe on: August 30, 2015, 07:11:01 am
Just so there's something to see this update, here's a screenshot with the output of the world generator drawn. greenish lines are walls, brownish lines are doors. Next step is to link screens together into larger rooms, then get to work on platform and wall layout. Then, build a graph of the rooms and start to do the really interesting stuff.

10  Feedback / DevLogs / Re: pixellated platform game thing dot exe on: August 30, 2015, 02:38:24 am

https://dl.dropboxusercontent.com/u/66774144/cavex_test6.zip

This build is mostly internal changes, improving the architecture now that I've got some usage code, preparing for random level generation... Not a lot to see! Next build should be a little more visually interesting.

Changes:
  • Big level format changes
  • Beginnings of random level generation
  • Start of a level editor. navigate with vi keys. not super functional yet
  • Moving skeleton sprites look a lot more stable
  • Tons of internal changes, not a lot to see right now

Known bugs:
  • tile grid is extremely janky, i blame fmod

fmod doesn't actually seem to do what I would expect it to... anyone with C experience know exactly what it's trying to do? I'm getting negative numbers and all sorts of bizarre things out of it. Didn't even know that it was possible to get negative numbers as a remainder...
11  Developer / Technical / Re: ProgramGamer toys around in C++ on: August 30, 2015, 01:59:18 am
For C structs like what SDL uses, you can have them start zeroed really easily:

Code:
//this rect could be anything!
SDL_Rect shadyRect;

//this rect is at 0, 0, with width 0 and height 0
SDL_Rect zeroRect = {};

//this rect is at 2, 2, with width 64 and height 64
SDL_Rect definedRect = {2, 2, 64, 64};
12  Developer / Technical / Re: General thread for quick questions on: August 30, 2015, 01:46:20 am
The first guy is pretty opinionated and ranty (I say as a C guy), but this discussion might be what you're looking for. They discuss the garbage collection in Haxe, and compare it to direct memory management in C++. Hope that helps!
http://old.haxe.org/forum/thread/3036
13  Developer / Technical / Re: General thread for quick questions on: August 29, 2015, 12:42:12 am
Found the answer to my question! Accumulated rounding errors from adding gravity every frame vs. the relatively clean prediction function. Fixed it by adding a small amount of error correction based on the requested distance. The number is magic, I ended up just having to tune it until it worked.

Code:
inline
float jumpVelocityFromHeight(float pixels, float gravity)
{
   float jeq = (pixels + pixels * (0.0135)) * gravity * 2;
   return sqrt(jeq);
}

As far as what I need the precision for, this is one of a number of functions intended to make the player movement more predictable, so that I can prevent my random level generator from placing platforms that allow easy sequence breaks. If someone finds a skip, I want them to have earned it Grin

Also, it's equally important to detect when a jump is impossible due to a low ceiling, so the previous version that overshot its target could potentially have generated some unintentionally tricky jumps.

I wish I had more time for D/Rust/Lisp.....

Haven't tried the others, but I had a good chance to try Rust. Didn't much care for it. Not a fan of compilers that enforce code style.
14  Developer / Technical / Re: General thread for quick questions on: August 28, 2015, 05:34:43 pm
Jumps are parabolas. That needs to be there.
15  Developer / Technical / Re: General thread for quick questions on: August 28, 2015, 05:06:14 pm
Anyone here good with math?

I need to convert a desired jump height into a velocity. I'm working with a very simple euler motion (dy += gravity, y += dy).

So far what I've come up with "works", but is definitely not right.
Code:
inline
float jumpVelocityFromHeight(float pixels, float gravity)
{
   float jeq = (pixels + 8) * gravity * 2;
   return sqrt(jeq);
}

the pixels + 8 is in there because it undershoots by half a tile per 30 tiles of distance. With that in there, it pretty consistently overshoots by a little bit, which is good enough to get it working for now. Ideally, I'd like to have the player come to a stop in the air a precise number of pixels above the ground. Normally not terribly important, but I'm getting into some procedural platform placement code, and I'd like to be able to place platforms to avoid unintentional sequence breaking. Thanks!
16  Feedback / DevLogs / Re: pixellated platform game thing dot exe on: August 22, 2015, 11:25:20 pm
Map editor's coming along nicely!



If you're wondering what 'envelopes' are, they're sets of rules for placing tiles. The idea is to take a set of rectangles as input, then let the game automate the bulk of the tile placement. For now, I'll add functionality to the editor to paint rectangles, and place all the tiles in advance. Eventually, I hope to use this to generate levels that still look nice, by reducing the amount of art stuff the generator has to consider at every step of the process. Should be interesting! I've seen similar techniques before, but nothing that works exactly the way that I'm using it.
17  Feedback / DevLogs / Re: pixellated platform game thing dot exe on: August 20, 2015, 08:32:50 pm
Spent all day making text entry box work the way I wanted.
Then I read this https://wiki.libsdl.org/Tutorials/TextInput


 Epileptic

Screw it, I'll go back and fix it later
18  Feedback / DevLogs / Re: pixellated platform game thing dot exe on: August 20, 2015, 01:00:00 pm
2pm on saturday, today is problem Epileptic
19  Feedback / DevLogs / Re: pixellated platform game thing dot exe on: August 20, 2015, 12:17:30 am
When the sprite flips, the layers are also flipped around so that the arms and legs stay on the correct side of the sprite. At this point I need to decide whether I want to:
A) break the color palette I've been sticking with and darken back facing limbs programmatically, or
B) flip the joints targeted by keyframes instead of flipping the layer order

B could potentially get more complicated and error prone, but it would allow a really simple way to make moving limbs more distinct. Probably going to go with A, since it makes item attachments much simpler. Also allows me to have asymmetrical characters.

I feel like experimenting with a livestream! Anyone who has questions about the animation system, that might be a perfect time to ask them. I've got a couple pretty major changes to make to that code, and I'll be starting on the editor, so I'll be able to really pull it apart and show how stuff works. 2pm probably?
20  Feedback / DevLogs / Re: pixellated platform game thing dot exe on: August 19, 2015, 09:49:18 am
haha yeah, that's exactly what I was going for. I think there are a couple things going on that make it look strange right now: he is leaning back a little too much, and the little chest detail makes it hard to make out the silhouettes of his hands.



Here's a build that fixes both of those things. I might not do much more to the animations until I write an animation editor, editing keyframes with vim is for the birds

https://www.dropbox.com/s/fuhcyju5jqdn56x/cavex_test5.zip?dl=0
Pages: [1] 2 3 ... 15
Theme orange-lt created by panic