Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Everything posted by null;

  1. How would I go about implementing tile smoothing? Let's say there's a 3x3 set of grass tiles. I want the outside grass tiles to have some kind of outline, while the middle one blends in with the rest. I don't really see a point in sharing any code, as I'm just asking for the implementation process. Thank you to whoever replies!
  2. null;

    Tile Transition Logic

    That does seem to be the correct search term, thank you.
  3. null;

    Tile Transition Logic

    I apologize for my lack of clarity. Here's a diagram of what I'm trying to accomplish. https://gyazo.com/41dcae854315a28a67cb30390c365771 Notice how when the tiles are grouped, not all sides of each individual one are rendered, only the exposed ones.
  4. null;

    Tile Transition Logic

    I think I've thought of a better way of explaining my question, or what I want to accomplish. How would I incorporate tile smoothing, so the edges aren't always jagged and pointed. Basically, just corner smoothing.
  5. I have 4 rectangles attached to my player for collision detection. When the player collides with anything, it's moved back the opposite direction.   Here's some pseudo code to demonstrate how it works. if(leftCollisionRectangle.intersects(otherRect)) { player.move(1, 0); //player's position is set to its x, plus one 1, and the y isn't affected as it isn't checking for top or bottom collision in this example } So I'm moving the player in the opposite direction at its speed when it intersects with another rectangle.   This is the result: (I'm drawing the player's collision rectangles to demonstrate the intersection) https://gyazo.com/33b257b8ec5063b021a927d844a655ec   It works, but it's buggy. The player is getting pushed back more once the key is released. Is there anything wrong with the logic I'm using to keep the player from being able to move through the rectangle, or could it be some kind of other issue?
  6. null;

    SFML Odd Collision

    It gets called before the keyboard logic function is called, in the main class. leftCollisionRectangle.intersects(otherRect) is false after the keyboard is released and the odd player movement occurs, but it's true while the player is actively moving into the rectangle.   The logic is as simple as the pseudocode demonstrates.
  7. I recently got into SDL 2 in C++. I've implemented a camera into the game, and was wondering how I would go about zooming. I've tried doing many things, but I won't go into detail because I don't think I'm on the right track at all.   If any of you have implemented zooming in/out into your game, can you specify how you actually did it?   Thanks to everyone who replies.
  8. null;

    SDL 2 Zooming In and Out

    Yeah, it really helped with the first part. I'm mad at myself for not thinking of that!   The problem is, this kind of only works with the background image, since the way the player is rendered differs to the way the background is rendered. I'm having a hard time explaining it at the moment, I'll post another reply when I can.
  9. null;

    SDL 2 Zooming In and Out

    Wow... I mean, I really appreciate the detailed reply and code examples; I just... don't really understand a lot of it.   I mean, here's the way I'm currently doing it (pseudocode):  SDL_Rect camerRect = { 0, 0, 640, 480 }; in game loop: camerRect.x = player1.positionRect.x - 290;        camerRect.y = player1.positionRect.y - 170;         player1.Draw(renderTarget, camerRect);         SDL_RenderPresent(renderTarget);         SDL_RenderClear(renderTarget);         SDL_RenderCopy(renderTarget, mapTexture, &camerRect, NULL);   player draw method in player class:           void Player::Draw(SDL_Renderer *renderTarget, SDL_Rect camerRect) {                 SDL_Rect drawingRect = { positionRect.x - camerRect.x, positionRect.y - camerRect.y, positionRect.w * 2, positionRect.h * 2};                 SDL_RenderCopy(renderTarget, texture, &cropRect, &drawingRect);         }   I don't think the kind of stuff you're talking about applies to how I'm doing it - if it did, I don't really understand it...   Again, I really appreciate the detailed reply. I apologize for my noobness at this, lol.
  10. null;

    GameObject class structure

    Sort of. Pointers, references, or some other advanced programming techniques under the bucket of "type erasure" (that under the hood use pointers or references somewhere) can all provide dynamic polymorphism, like Java. Value objects - which Java doesn't support for user-written classes - cannot be _dynamically_ polymorphic, but can be _statically_ polymorphic (a concept that mostly doesn't exist in Java). For instance, C++ functions and classes can be generated with templates, so you can write a single function that takes any type of value and operates on it. Functions that operate on objects polymorphically can work on any kind of object in C++. e.g. you can get a reference or pointer to any object, no matter how it was created. The function doesn't and shouldn't care where the object came from. That said, dynamic polymorphism is a bit rarer in C++ than Java, typically because polymorphism and class inheritance and such are _bad solutions_ for a number of problems. Java programmers tend not to notice how bad those solutions are because Java _forces_ people to use polymorphic objects for everything; C++ gives you a lot more options for when dynamic polymorphism is a suboptimal tool for the job. Some examples:   // references should be preferred over pointers in most cases void foo(base_type& ref) { ref.method(); // dynamically polymorphic } // higher level abstractions can also be polymorphic and are sometimes very preferable over base classes and inheritance void foo(function<void(int)> func) { func(42); // "polymorphic" because func can be bound to a free function, member function, lambda, etc. } // templates are a form of static (compile-time) polymorphism template <typename T> void foo(T val) { val.method(); // tries to invoke T::method() on val, no matter what T is } In general, remember two things: - you should _very rarely_ ever have a raw pointer in C++. If you're passing around ownership of an object, use std::unique_ptr or std::shared_ptr, and if you're just observing an object, use a reference or std::weak_ptr (and __strongly__ prefer unique_ptr and references as shared_ptr/weak_ptr can cause more problems than they solve if you're not careful!). - don't use inheritance to solve every problem. that's Java-esque thinking that should be stamped out when moving to another language. :) inheritance solves a small few particular types of problem very well but leads to either inflexible code, overly-coupled code, or poorly-performining code when it's overused.   Wow, thanks! Yeah, I figured making everything I wanted to incorporate polymorphism with (which would be a lot of things in a game) a raw pointer would just get tiring after a while.    Yeah, I was worried about writing Java++ code. Thanks for the clarification!
  11. Hey all. I recently started doing some game development in C++ - I've been trying out both C++ and SFML.   Anyways, I've recently encountered this issue that I'm not sure how I'll overcome when the time comes. Well, it's not really an issue per se, but I'd like some clarification in any case.   In a language like Java, polymorphism is just a matter of changing a function in a derived class. I assume this is because pretty much everything is a pointer in Java.   However, in C++, I found out that an object has to be a pointer for me to properly implement polymorphism.   Is this actually the case, or is there some other method everybody uses that I'm unaware of?  
  12. I recently formatted my PC and upgraded to windows 10, as it was starting to get really slow and had a few driver issues.    After getting everything set up, I went to install visual studio, but I had to cancel because I forgot to add a feature. After doing that, the installer displayed a message saying that it installed 5 components out of 309 or something like that.   I really don't want to screw things up with my new setup. Did the act of cancelling the installation do anything that could have harmed my PC? If so, is there any relatively simple, non-hacky fix?   Thanks to anyone who replies.
  13. I've been having this issue with SFML where every half a second or so, my game would stutter (as in, a slight lag spike).   I've tried running old projects and the issue persisted.   After researching this issue a bit, it seems as though it's not necessarily my fault - however, I've tried updating drivers and doing other things that were recommended to people who were having my problem, but nothing worked.   Have any of you had this issue with SFML before? If so, did you solve it? How? Thanks for all replies.
  14. null;

    C++ SFML Stuttering

    The problem seems to have come back. 
  15. null;

    C++ SFML Stuttering

    Yeah, the issue got fixed somehow. Thanks anyways!   Just to answer your question, I load my assets at load time.
  16. null;

    C++ SFML Stuttering

    Yeah, that makes sense. When I framelocked it to 60 fps, it would drop down to ~19.   The stutters are pretty clear in-game. It would be a lag spike that lasts for about half a second, and it happens at half a second intervals.   This has affected every SFML project I've had as far as I can tell.   I'll just do a bit more research. Thanks anyways!   EDIT: The issue got fixed, but I'm not entirely sure how.
  17. null;

    C++ SFML Stuttering

    I don't have f.lux installed, or anything else that affects screen brightness (as far as I'm concerned).   After outputting debug data like you said, I can verify that the frame times vary a lot. It can dip from 3000 to ~700 (more or less).
  18. I've been working on a game in Java and I'm having an issue with the blocks which the player can place down in the game. I have specific types of blocks which are meant to be for decoration. They're basically walls. The player can walk through them - no interactions are made between them.   The problem is, the only way I can do that is to draw the walls before I draw the interactive/solid blocks. That means I'd need to have 2 for loops in my render method - one to iterate over my block storage list and ONLY look for walls, and the other one to render the rest of the solid ones.   This causes about a decrease of about 200-250 fps. Is there another way I can go about rendering the walls behind the player/everything else?   By the way - I'm not using any libraries, and I'd really honestly rather not.   Thank you.
  19. I'm working on this 2D game that uses a .png file to generate the level.   I basically scan through the pixels (512x512) of the .png file, and if it corresponds to a specific set of RGB colors, it renders the object to the screen.   i.e - if(red == 255 && green == 0 && blue == 0) {        listOfBlocks.add(new SpecificBlock(parameters));        } That's not an actual block of code, it's just an example.   I use that method to render my blocks to the game - basically the ground the player walks on.   The way I actually render them beside eachother is with a for loop which increments the x and y variables by 32 (the size of the blocks) then renders them in the appropriate area corresponding to the .png file.   In the game, the player can place down blocks by pressing 'K'. The issue is, the blocks can intersect with eachother and they can be placed anywhere. Think about it like this: You can't place blocks on a specific area on the ground in Minecraft, there's a grid box where the block goes. I want to have that in my game, but I can't seem to figure out how.   Okay, so while typing this out I decided to try something which ended up working.   Basically, when the player presses 'K', I have two integers which both equal the x and y coordinates of the player, they're called 'temp' for x, and 'temp2' for y. I have this block of code:     while(temp % 32 != 0) {     temp++;     }     while(temp2 & 32 != 0) {     temp2++;     } And then I add a new block with temp and temp2 as the coordinates rather than the player coordinates.   I'm kind of in a rush right now, so it may be a little hard to understand what I'm trying to explain, or even what I was originally trying to ask.   I hope this helped somebody.
  20. null;

    Bullet Collision

    Hello! I've started to work on a little game recently.   Essentially, it involves throwing a block, and the player teleports wherever it lands.   I have an ObjectId enum which stores my objects for the game. So far, I have a Block, Player, and Bullet (which is the thing you throw in the game) enum. Every new block/bullet that's created is passed its respective enum in its parameter. I use this tag to reference the objects.   Anyways, the way I'm currently checking to see if the 'bullet' landed on ground, is by literally iterating over every block there is in the game, and checking if the 'bullet' intersected with them. Obviously, this isn't very efficient, and throwing multiple at the same time causes quite a bit of lag.   Is there a better way to do this? 
  21. I was just wondering how exactly I would go about splitting a single image into multiple images of a specific size.   Essentially, I would just take a regular image, and split it into, say, multiple images which are 16x16.   I looked online for an answer, but my search terms were probably a bit messed up since the only stuff I could find was splitting it into specified rows and columns (not specifying the actual desired size of the output image).   Is there a standard algorithm for splitting an image into smaller parts of the desired size?   Thanks!   EDIT: I really need to try harder before asking. Sorry! It was really easy to do, but I just missed it somehow. But please, feel free to answer. I might learn something new!
  22. Care to share? In case others find this thread by searching :)   Well, the heart of it is essentially creating a BufferedImage with the paramters of (specified width, specified height, image type).   The rest consists of basic loops which really anyone with beginner knowledge can do  : P For some weird reason, I didn't try that in the first place even though it's extremely simple.
  23. Hi! Recently, I've been participating in this online 'game' - which just includes all kinds of cryptography challenges.   One of these challenges included a regular image, and its duplicate data moshed image. You were supposed to compare both of the image's bytes, and extract the modified ones from the data moshed image.   I've tried looking for answers online, and the only thing I could find was code belonging the same person who did the challenge.   This is the python2 code: ------       import sys     orig = open('screenshot.jpg', 'rb')     new = open('otherscreenshot.jpg', 'rb')     replaced_bytes = ''     for o, n in zip(orig.read(), new.read()):         if o != n:             replaced_bytes += o     hint, skull = replaced_bytes.split('\n')     print(hint)     for i, c in enumerate(skull):         sys.stdout.write( c )         if not i % 59:             sys.stdout.write('\n')     sys.stdout.write('\n')   ------     Apparently, this produced a hidden message and is called a 'difference check'. Is there a way to replicate this in Java?    Sorry if this is a dumb/obvious question.   Thanks to whoever answers!
  24. Yes, sure, it can be done, and doesn't look very hard.   The code is doing a byte-by-byte comparison of both files, and if not the same it does some special stuff I don't understand.       To be honest I don't understand your question. Was "yes" the answer you were looking for?   >and if not the same it does some special stuff I don't understand.   Yeah, I just wanted an explanation of the 'special stuff you don't understand', and if it could be done in Java.   Thanks.   EDIT: It was a *really* easy thing which anybody could do. I made an error. Disregard.
  25. I've been working on a little program recently (details aren't exactly very important at the moment), and I essentially copy a DLL file to a certain location.   I finished up the program, and it worked pretty much perfectly. Recently, I wanted to make it more compact so it could be a standalone jar without requiring a folder with assets (i.e the image background, icon, DLL, etc.).   I figured out that I could get the image as a resource from the actual jar file/class - that eliminates the need for the image assets in a separate folder.   Next, I wanted to store the DLL within the jar file so I could copy it to another location. I've tried everything, honestly. I just can't figure out how I would go about copying the DLL file from within the actual jar file to an external location.   Any help is welcome. I'll try everything.   Thanks to whomever answers!
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!