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 ... 4 5 [6]
76
SFML wiki / Re: Zooming a view at a specified pixel
« on: June 02, 2017, 06:24:18 pm »
I'm sorry, better description:

I'm using your code from wiki and what I want to achieve:
- draw scene with sprites (sun) etc. + move view + zoom view to pixel
- draw GUI over this scene (this black box with text), 1:1, without any transformations

Scene: https://imgur.com/a/IIdk3

1) Your code without changes, working - https://youtu.be/olxO6OAgbQU

2) When I call window.setView(ViewGUI) - https://youtu.be/i6VovaULCxM

In first seconds is your function, it doesn't work anymore, it reset View.
From cca 5 sec. there is my code based on your, it works +- but view follows mouse cursor

I made global variable Zoom (zoom = zoom + 0.01) and put zoomViewAt() into drawing function.
Probably I can fix this mouse following but I'm not sure if it's right way or not, these view seems little bit tricky. The solution could be simpler as your suggestion. But I do not know exactly where to use it.

My code (it's not C but commands have similar syntax):
Procedure SFML_DRAW;
begin
  if ViewResized then begin // when is window resized
    sfRenderWindow_setSize(renderWindow, PanelSize_u );
    sfView_reset( View, ViewRect );
    sfView_reset( View_GUI, ViewRect_GUI );
    ViewResized := false;
  end;

// MAIN SCENE
  sfview_move( view, ViewPos );   // arrow keys = move view to sides

 // sfRenderWindow_setView( RenderWindow, View );
  zoomViewAt( mouse, RenderWindow, Zoom );   // Zoom
 // View := sfRenderWindow_getView( RenderWindow );

  // Draw sprites
  spr_Draw_I( renderWindow, tex_sun, sun_pos.x, sun_pos.y, 0, 0, 0 );
  spr_Draw_I( renderWindow, tex_sun, 200, 100, 0, 0, 0 );
  // Screen boundary
  Draw_Rect_Line( -1, -1, Form1.Panel1.width + 1, Form1.Panel1.height + 1, 180, sfGreen );

// GUI
  //sfView_reset( View, ViewRect );
  sfRenderWindow_setView( RenderWindow, View_GUI );

  Game.DrawInfo( Form1.Panel1.Width - 210, 0, 12 ); // Black box with text
end;

Controls:
    //GET_WHEEL_DELTA_WPARAM(wParam);
    WM_MOUSEWHEEL : if Smallint(HiWord(wParam)) < 0 then begin
       //sfRenderWindow_setView( RenderWindow, View );
       zoomViewAt( Mouse, RenderWindow, 1.1 );
       //View := sfRenderWindow_getView( RenderWindow );
    end else begin
       // sfRenderWindow_setView( RenderWindow, View );
       zoomViewAt( Mouse, RenderWindow, (1 / 1.1) );
       //View := sfRenderWindow_getView( RenderWindow );
     end;

  if sfKeyboard_isKeyPressed(sfKeyU)  = 1 then
    begin
      Zoom := Zoom + 0.01;
    end;

    if sfKeyboard_isKeyPressed(sfKeyI)  = 1 then
    begin
      if zoom > 0.01 then Zoom := Zoom - 0.01;
    end;
 

77
SFML wiki / Re: Zooming a view at a specified pixel
« on: May 31, 2017, 12:21:42 pm »
Nice code, but if I have next view for GUI and call window.setView(ViewGUI) it reset zoom. Is it possible to combine it?



78
SFML game jam / Re: Making a Jam on Itch io with prices
« on: May 26, 2017, 01:22:08 pm »
The idea is fine, but you're sure, that you want to send printed books over half the world? Maybe some symbolic rewards would be better.

Anyway, I don't need any prices, I want to defeat C/C++ SFML users with my miraculous Pascal code :)

About rules:
I'm only for own graphics and sound assets directly created for the project






79
Graphics / Re: Texture intersect - TiledMap(editor)
« on: April 16, 2017, 12:45:34 pm »
Hello,

you have very basic structure which only shows how draw with vertex arrays. But otherwise it's not very useful
I think. Read some articles about tilemaps.

You can have an array in which can be stored "ID" or pointer to your object (tree, castle).

ID:
0 - nothing
1 - tree 1
2 - tree 2
3 - castle

Some tips:
- map grid starts from [0;0] not [1;1]
- you draw whole map but you need draw only tiles which are on screen

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