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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Paul

Pages: 1 ... 3 4 [5] 6
61
General / Re: Using multiple views for level and entities
« on: February 01, 2018, 05:52:02 pm »
Hello,

I think it should be more like this:
levelView = level/map and all objects (player + enemies, items)
"UIView" = GUI, HUD, text infromations etc.

Sprite scaling is problematic in many ways - zooming, screen resolution, DPI etc.
- if you have retro style game, you can set setSmooth(0) for textures and it's really simple and effective solution
- If you have detailed graphics like e.g. Angry Birds, game graphics must be in higher resolution (PC) or in various resolutions (which is common for mobile phones because there are problems with DPI)

62
General / Re: When should I update my tilemap
« on: January 30, 2018, 09:39:13 pm »
Yes, it's correct way. Draw only tiles which are visible on the screen.

Sometimes it can be harder for imagination, just use pencil and paper :)

63
General / Re: When should I update my tilemap
« on: January 30, 2018, 05:25:54 pm »
Few things:
- must be map in chunks? You can load whole map and use formula to get the tiles which are on the screen

- update map/view every frame is rather unnecessary. Update it only if you're scrolling is not good idea, what if object on the map is destroyed?

- you can have fixed update procedure in game loop, let's say 20x, 30x or 60x per second.

- it depends on what you want to achieve, your world will be not only terrain I suppose. If you have static or moving objects like trees, characters, you can store their ID in tilemap/grid. If they are animated/moving 30 updates per seconds can be too low

- also scrolling can looks bad with low update rate

64
Graphics / Re: Is it possible to make full white sprite?
« on: January 29, 2018, 05:53:35 pm »
In OpenGL it's possible even without shaders:

// Set color, your case
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB );
glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB,  GL_REPLACE );
glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB,  GL_PRIMARY_COLOR_ARB );
 

// Mix colors
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
 

But I'm not sure if it's in any SFML functions.

65
General / Re: Delay between commands
« on: January 29, 2018, 01:45:02 am »
You can not have fixed values. Use variables and increase thier value in some period of time - https://www.sfml-dev.org/tutorials/2.4/system-time.php




66
Graphics / Re: Aligning movement with rotation vector
« on: January 28, 2018, 07:31:19 pm »
Use atan2 how eXpl0it3r suggested. I had same problem week ago (It's not C/C++ code, but the meaning is clear):

// Initial angle
initAngle := ArcTan2( mouse.y - gun.y, mouse.x - gun.x );

// Velocity
vel.x := initvel.x * cos( initAngle ); // Initvel is initial velocity
vel.y := initvel.y * sin( initAngle );

// Applying gravity
acc.y := acc.y + gravity * weight * dt;
vel.y := vel.y + acc.y;

// Get position based on speed
pos.x := pos.x + vel.x * dt;
pos.y := pos.y + vel.y * dt;

angle := ArcTan2( vel.x, vel.y ); // angle of projectile
angle := 90 - RadToDeg( Angle ); // bullet sprites are under 90 degrees  
 



Of course position and velocity formulas are big question, you can implement it in many ways, also it can depend on the order what is calculated first. There is lot of articles in game dev forums about it.

67
General discussions / Re: Unfreezing the API
« on: January 25, 2018, 11:57:28 pm »
.. not many companies/studios use SFML for producing games ..

It's not SFML failure.

1) More than 10 years game companies completely ignore 2D style and mainstream is 3D. Maybe Paradox Interactive is an exception and there is few games from Ubisoft like South Park

2) If you have 2-3 full time job programmers, they can create own 2D engine fast

3) You can't compete engines like Unity because some part of people want dev games in easy way (no matter if it means poor performance and another issues)

Then it does not matter whether the creator of Factorio uses SFML, SDL or Allegro..

68
SFML projects / Re: Ludum Dare 40 - Master Farmer
« on: December 07, 2017, 03:03:41 pm »
Because C/C++ needs too much time and effort to create something. Even if you're using basic things like strings, arrays (vectors), pointers.. Syntax isn't fast readable, structure is unclear. If I get even some simple compiler errors in Visual Studio.. I'm completely lost :) In Lazarus/FPC I need few seconds to find problem and fix it.

The only thing I'm worried about is performance. FPC compiler efficiency is far behind C/C++ Visual Studio. But it is still evolving slowly and I'm not making 3D games. Next big plus is that I can create level/map editors superfast, just put SFML window in LCL Form (Panel).

I'm also learning C++, which gives me bigger knowledge and overview. C#, Python, Java are too slow.

69
SFML projects / Re: Ludum Dare 40 - Master Farmer
« on: December 06, 2017, 07:41:09 pm »
Ah, sorry missing units (SFML and my engine) you can find here: http://slavicgames.com/download/LD_40_SFML_units.rar
Unpack it somewhere and setup paths in project in Lazarus (CTRL + SHIFT + F11).

But source code is too chaotic copy & paste style - if you have 3 days to make game.. there is no time keep it in order. Also my engine is incomplete, sound/music manager is missing and some parts needs "final touch":)

I think Pascal is great language for games. Of course it lacks perfection, the possibility of optimization and compliter result vs C/C++.. but you can code really fast and it's easily readable, learning curve is great for beginners. Also it's not so bad in performance if you stay on lower level with pointers and array's instead of OOP for game objects used in mass numbers.

70
SFML projects / Ludum Dare 40 - Master Farmer
« on: December 05, 2017, 12:31:04 pm »
Well, here is my first entry for Ludum Dare. It was fun and little bit hectic. Game itself is not great miracle but every finished project counts :)

https://ldjam.com/events/ludum-dare/40/master-farmer

Uses CSFML + Pascal bindings.

Have fun.

71
Graphics / Re: One sprite for all my objects
« on: June 24, 2017, 12:28:53 pm »
In the case of special requirements:
- you need any kind of texture manager
- manager can also hold sprite assigned to texture
- game objects can hold pointers to these sprites

The problem starts when you want to change the parameters of sprite, like scale. In such case you need individual sprites for each object, reset scale values or make sprite copies on-the-fly.

72
Graphics / Re: Sprites and shadow overlapping
« on: June 13, 2017, 03:56:55 pm »
Thank you, I will try it.

EDIT:
Well, it's working fine :) And I do not see any measurable difference in performance (tested in 1920 x 1080 pix, render texture have same size).

73
Graphics / [Solved] Sprites and shadow overlapping
« on: June 13, 2017, 01:35:57 pm »
Hi,

I have game sprites with shadows like this: (1x texture / 4x sprites)


And during rendering there is classic problem:


I tried combinations for blending in sf::BlendMode - factor and equation, also without changing alpha color or so but without any results. Is possible solve it simply with blendmode or shaders are needed?

Code for drawing sprites:
procedure spr_Draw_Alpha( renderWindow : PsfrenderWindow; sprite : PsfSprite; x, y : single; alpha : byte; RenderStates : PsfRenderStates = nil );
  var
    pos    : sfVector2f;
    color  : sfColor;
begin
  if not Assigned( sprite ) then exit;

  pos.x := x;
  pos.y := y;

  color.A := Alpha;

  sfSprite_setColor( sprite, Color );
  sfSprite_setPosition( sprite, pos );
  sfRenderWindow_drawSprite( renderWindow, sprite, RenderStates );
end;  
 

74
Graphics / Re: Loading indexed images with transparency
« on: June 07, 2017, 01:42:53 pm »
Why is it a pain from the past ?

I was modding one old game. If game use indexed palettes you never fit into with colors. So your new graphics will looks different and it take lot of time to get similar result as original. And these games don't use 1 palette but many for same kind of objects (or subpalettes based on original colors).. impossible :)

75
Graphics / Re: Loading indexed images with transparency
« on: June 07, 2017, 01:00:24 pm »
It does work with unindexed color though, and I'll eventually come to using it, but I feel like it's a huge waste of space.

Indexed palletes are pain from the past. For smaller files or less memory usage you can use PNG with RGBA4444 or use some optimalization like PngOpt.

And you can get better result:
original indexed.png = 24 281 bytes
indexed.png RGBA8888 with opt. level 1 = 23 670 bytes (1:1 with origninal, no losses in qualilty)

Pages: 1 ... 3 4 [5] 6
anything