Du bist nicht angemeldet.

Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!

Werbeanzeige

1

28.01.2012, 16:59

SFML fps Frage

hi Leute,
ich bin neu im Forum.
Ich hätte eine Frage zu SFML.
Also ich möchte eine Linie zeichnen und sie dann flüssig weiterführen.
Wie man die Liene erstellt weiß ich schon.
Aber ich weiß nicht, wie ich sie flüssig weiter führen soll.

Danke Voraus:

NachoMan

Community-Fossil

Beiträge: 3 885

Wohnort: Berlin

Beruf: (Nachhilfe)Lehrer (Mathematik, C++, Java, C#)

  • Private Nachricht senden

2

28.01.2012, 17:05

Willkommen im Forum.
Was meinst du mit weiterführen?
Willst du die Linie einfach nur verlängern erstellst du eine neue.
Willst du z.B. Freihand zeichnen erstellst du für jeden Abschnitt eine neue Linie(mit Hilfe von Vektoren z.B.) oder du frügst dem Shape einen neuen Knotenpunkt hinzu.
"Der erste Trunk aus dem Becher der Erkenntnis macht einem zum Atheist, doch auf dem Grund des Bechers wartet Gott." - Werner Heisenberg
Biete Privatunterricht in Berlin und Online.
Kommt jemand mit Nach oMan?

3

28.01.2012, 19:44

Willkommen im Forum.
Was meinst du mit weiterführen?
Willst du die Linie einfach nur verlängern erstellst du eine neue.
Willst du z.B. Freihand zeichnen erstellst du für jeden Abschnitt eine neue Linie(mit Hilfe von Vektoren z.B.) oder du frügst dem Shape einen neuen Knotenpunkt hinzu.

Mit weiterführen meine ich das wie in einem bildschirmschoner. D.h, die Linie soll so langsaml und flüssig weiter gehen:

NachoMan

Community-Fossil

Beiträge: 3 885

Wohnort: Berlin

Beruf: (Nachhilfe)Lehrer (Mathematik, C++, Java, C#)

  • Private Nachricht senden

4

28.01.2012, 20:17

Du kannst die neue Position der Linie mithilfe der Frametime berechnen.

Eine Bewegung mit 100 Pixel pro Sekunde kriegst du z.B. wenn du diesen Methodenaufruf in jedem Frame machst:
shape.Move(100.f*window.GetFrameTime(), 0.f);

Dabei solltest du aber die FPS vom Renderwindow begrenzen.

Ich würds dir etwas genauer erklären wenn ich deinen Mathematikkenntnissstand kennen würde. Gehst du noch zur Schule? Welche Schulart besuchst du und in welchem Jahrgang bist du? Kennst du dich mit Vektorrechnung aus?

Achja, Komplettzitate sind meistens unnötig. ;)
"Der erste Trunk aus dem Becher der Erkenntnis macht einem zum Atheist, doch auf dem Grund des Bechers wartet Gott." - Werner Heisenberg
Biete Privatunterricht in Berlin und Online.
Kommt jemand mit Nach oMan?

5

28.01.2012, 21:21

Edit.


gibt es was efiektiveres als das :

C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
#include <SFML/Graphics.hpp>
#include <iostream>

#pragma comment(lib, "sfml-system-s-d.lib")
#pragma comment(lib, "sfml-window-s-d.lib")
#pragma comment(lib, "sfml-graphics-s-d.lib")


int main()
{
// Create main window
sf::RenderWindow App(sf::VideoMode::GetMode(0), "Projekt", sf::Style::Fullscreen);

// Start game loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();

// if button on keyboard pressed : exit
if ((Event.Type == sf::Event::KeyPressed)) 
App.Close();

// if Mouse Button pressed : exit
if (Event.Type == sf::Event::MouseButtonPressed)
App.Close();

// if Mouse Wheel moved : exit
if (Event.Type == sf::Event::MouseWheelMoved)
App.Close();
}


void vFunktion(int x1, int y1);




App.SetFramerateLimit(25);




App.Draw(sf::Shape::Line(1, 1, 100, 1, 25, sf::Color::Red));
App.Display();
App.Clear();

App.Draw(sf::Shape::Line(1, 1, 100, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(100, 1, 200, 1, 25, sf::Color::Red));
App.Display();
App.Clear();

App.Draw(sf::Shape::Line(1, 1, 100, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(100, 1, 200, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(200, 1, 300, 1, 25, sf::Color::Red));
App.Display();
App.Clear();

App.Draw(sf::Shape::Line(1, 1, 100, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(100, 1, 200, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(200, 1, 300, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(300, 1, 400, 1, 25, sf::Color::Red));
App.Display();
App.Clear();

App.Draw(sf::Shape::Line(1, 1, 100, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(100, 1, 200, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(200, 1, 300, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(300, 1, 400, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(400, 1, 500, 1, 25, sf::Color::Red));
App.Display();
App.Clear();

App.Draw(sf::Shape::Line(1, 1, 100, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(100, 1, 200, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(200, 1, 300, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(300, 1, 400, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(400, 1, 500, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(500, 1, 600, 1, 25, sf::Color::Red));
App.Display();
App.Clear();

App.Draw(sf::Shape::Line(1, 1, 100, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(100, 1, 200, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(200, 1, 300, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(300, 1, 400, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(400, 1, 500, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(500, 1, 600, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(600, 1, 700, 1, 25, sf::Color::Red));
App.Display();
App.Clear();

App.Draw(sf::Shape::Line(1, 1, 100, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(100, 1, 200, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(200, 1, 300, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(300, 1, 400, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(400, 1, 500, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(500, 1, 600, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(600, 1, 700, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(700, 1, 800, 1, 25, sf::Color::Red));
App.Display();
App.Clear();

App.Draw(sf::Shape::Line(1, 1, 100, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(100, 1, 200, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(200, 1, 300, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(300, 1, 400, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(400, 1, 500, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(500, 1, 600, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(600, 1, 700, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(700, 1, 800, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(800, 1, 900, 1, 25, sf::Color::Red));
App.Display();
App.Clear();

App.Draw(sf::Shape::Line(1, 1, 100, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(100, 1, 200, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(200, 1, 300, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(300, 1, 400, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(400, 1, 500, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(500, 1, 600, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(600, 1, 700, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(700, 1, 800, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(800, 1, 900, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(900, 1, 1000, 1, 25, sf::Color::Red));
App.Display();
App.Clear();

App.Draw(sf::Shape::Line(1, 1, 100, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(100, 1, 200, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(200, 1, 300, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(300, 1, 400, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(400, 1, 500, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(500, 1, 600, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(600, 1, 700, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(700, 1, 800, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(800, 1, 900, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(900, 1, 1000, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(1000, 1, 1100, 1, 25, sf::Color::Red));
App.Display();
App.Clear();

App.Draw(sf::Shape::Line(1, 1, 100, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(100, 1, 200, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(200, 1, 300, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(300, 1, 400, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(400, 1, 500, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(500, 1, 600, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(600, 1, 700, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(700, 1, 800, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(800, 1, 900, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(900, 1, 1000, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(1000, 1, 1100, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(1100, 1, 1200, 1, 25, sf::Color::Red));
App.Display();
App.Clear();

App.Draw(sf::Shape::Line(1, 1, 100, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(100, 1, 200, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(200, 1, 300, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(300, 1, 400, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(400, 1, 500, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(500, 1, 600, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(600, 1, 700, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(700, 1, 800, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(800, 1, 900, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(900, 1, 1000, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(1000, 1, 1100, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(1100, 1, 1200, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(1200, 1, 1300, 1, 25, sf::Color::Red));
App.Display();
App.Clear();

App.Draw(sf::Shape::Line(1, 1, 100, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(100, 1, 200, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(200, 1, 300, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(300, 1, 400, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(400, 1, 500, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(500, 1, 600, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(600, 1, 700, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(700, 1, 800, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(800, 1, 900, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(900, 1, 1000, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(1000, 1, 1100, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(1100, 1, 1200, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(1200, 1, 1300, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(1300, 1, 1400, 1, 25, sf::Color::Red));
App.Display();
App.Clear();


App.Draw(sf::Shape::Line(1, 1, 100, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(100, 1, 200, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(200, 1, 300, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(300, 1, 400, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(400, 1, 500, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(500, 1, 600, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(600, 1, 700, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(700, 1, 800, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(800, 1, 900, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(900, 1, 1000, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(1000, 1, 1100, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(1100, 1, 1200, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(1200, 1, 1300, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(1300, 1, 1400, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(1400, 1, 1500, 1, 25, sf::Color::Red));
App.Display();
App.Clear();

App.Draw(sf::Shape::Line(1, 1, 100, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(100, 1, 200, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(200, 1, 300, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(300, 1, 400, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(400, 1, 500, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(500, 1, 600, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(600, 1, 700, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(700, 1, 800, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(800, 1, 900, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(900, 1, 1000, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(1000, 1, 1100, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(1100, 1, 1200, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(1200, 1, 1300, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(1300, 1, 1400, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(1400, 1, 1500, 1, 25, sf::Color::Red));
App.Draw(sf::Shape::Line(1500, 1, 1600, 1, 25, sf::Color::Red));
App.Display();
App.Clear();




App.Display();
}


return EXIT_SUCCESS;
}



das mit den :S Smylies is wegen dem Shape nach dem :

EDIT by dot: Code Tags eingefügt.

Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von »dot« (29.01.2012, 12:46)


6

29.01.2012, 12:44

Bitte Code-Tags verwenden ;)

7

29.01.2012, 14:32

Was machst du da? Ich darf gar nicht auf den Code gucken.
Schon mal was von std::vector oder Arrays oder std::list gehört?
Warum berechnest du nicht die neuen Positionen/Offsetwerte? (Offsetwerte->Vektor der dem sf::Sprite::Move-Parameter übergeben wird)
Was soll die Schleife am Anfang? Fällt dir irgendwas auf?
UND noch mal als Randbemerkung: Die Tabulatortaste (=Google kann helfen) ist ein tolles Ding. :vain:

MfG
Check

PS: Bitte nicht falsch aufnehmen. Ich mein das freundlich. ^-^ Ich und die anderen mit Sicherheit auch wollen, dass du das selbst (lösen) kannst und wir/ich schubsen dich nur in die richtige Richtung.

NachoMan

Community-Fossil

Beiträge: 3 885

Wohnort: Berlin

Beruf: (Nachhilfe)Lehrer (Mathematik, C++, Java, C#)

  • Private Nachricht senden

8

29.01.2012, 15:11

Du brauchst in dem Fall nichtmal ein Vector.

Wie hast du denn Programmieren gelernt? Weißt du was Schleifen und Variablen sind und wie man sie richtig einsetzt? Auf deinem jetztigen Wissensstand macht es jedenfalls kein Sinn mit der SFML anzufangen.
"Der erste Trunk aus dem Becher der Erkenntnis macht einem zum Atheist, doch auf dem Grund des Bechers wartet Gott." - Werner Heisenberg
Biete Privatunterricht in Berlin und Online.
Kommt jemand mit Nach oMan?

9

29.01.2012, 22:15

das problem ist,
wenn ich funktionen erstelle, oder klassen, muss ich jedes mal sf::RenderWindow neu definieren.
So geht dass ganze kaputt, denn dann sieht das ganze schlecht aus.
Könnt ihr pls Bsp. geben

10

29.01.2012, 22:40

Ich bitte sehr um entschuldigung,
denn ich habe ein sehr kleines Fehler gemacht, weshalb meine Funktionen und Klassen immer nicht funktioniert haben.
ich habe sf::RenderWindow ....
nicht als global definiert.


Aber um klar zu stellen, ich habe dass ganze mit funktionen, klassen und alles andere in c++ ausführlich gelernt, aber ein Mensch macht immer Fehler und aus Fehler lernt man.
Kann geschlossen werden

Werbeanzeige