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

Wirago

Alter Hase

Beiträge: 1 193

Wohnort: Stockerau

Beruf: CRM Application Manager

  • Private Nachricht senden

11

23.06.2016, 13:39

XNA wurde eingestellt. MonoGame ist die aktuelle "Fortsetzung"
MonoGame ist ein Framework das sich nahtlos in Visual Studio einbinden lässt, keine IDE.

Kurze Eigenwerbung:
Ich arbeite derzeit an einer Tutorialreihe für Monogame. Der Erste von bisher drei Artikel ist hier zu finden:
http://www.kleincodiert.at/articles/game…game1/index.php

Tician

Frischling

  • »Tician« ist der Autor dieses Themas

Beiträge: 32

Wohnort: Bad Friedrichshall

Beruf: FISI

  • Private Nachricht senden

12

23.06.2016, 15:21

Kein Problem mit Eigenwerbung^^ Ich würde das Tutorial sogar gerne mal durchlesen und ausprobieren und würde dir Feedback geben wie sich das bei einem absoluten Einsteiger wie mir macht :)

Dann melde ich mich wohl wieder wenn ich massiv Probleme habe oder wenn ich mein nächstes Spiel fertig habe! 8)

Schorsch

Supermoderator

Beiträge: 5 145

Wohnort: Wickede

Beruf: Softwareentwickler

  • Private Nachricht senden

13

23.06.2016, 20:52

Da du ja grad noch mitten im lernen bist würde ich dir von sowas erst mal abraten. Mach erst mal weiter mit den Grundlagen. Wenn die besser sitzen kannst du dir das immer noch angucken. Wenn du Dinge wie Switch noch nicht gelernt hast ist da ja noch einiges zu lernen.
„Es ist doch so. Zwei und zwei macht irgendwas, und vier und vier macht irgendwas. Leider nicht dasselbe, dann wär's leicht.
Das ist aber auch schon höhere Mathematik.“

Tician

Frischling

  • »Tician« ist der Autor dieses Themas

Beiträge: 32

Wohnort: Bad Friedrichshall

Beruf: FISI

  • Private Nachricht senden

14

24.06.2016, 14:38

Mir ist auch noch etwas eingefallen was ich merkwürdig fand.
Ich hatte die Form-Anwendung anfänglich auf 400*400 (pixel?) gesetzt und meinen "Schlangen-Kopf-Kreis" 10*10 groß gemacht. Das tatsächlich SPielfeld kam dann auf 350 Pixel in der Breite die die sich der Kreis bewegen kann bevor er außerhalb des Bildschirms ist. Die Höhe hat gar nicht dazu gepasst. Auf was muss ich denn da achten, wo liegt der Fehler, was sind die Einheiten in denen die Größen angezeigt werden? Da ich die Finger von der PixtureBox lassen möchte würde ich gerne wissen ob es eine alternative gibt um ein kleineres Fenster innerhalb der Forms zu definieren.

Wobei mir gerade einfällt ich kann ja selbst Linien zeichnen um den Spiel-Bereich abzustecken, das wäre also geklärt, aber vielleicht gibt es ja doch noch etwas anderes?

Sylence

Community-Fossil

Beiträge: 1 663

Beruf: Softwareentwickler

  • Private Nachricht senden

15

24.06.2016, 14:56

Wenn du Size der Form setzt, dann ist das Größe des Fensters. Also mit Titlebar und Rändern. Das, was du suchst ist ClientSize

LInsoDeTeh

Treue Seele

Beiträge: 372

Wohnort: Essen, Deutschland

Beruf: Team Lead Inhouse-Entwicklung

  • Private Nachricht senden

16

29.06.2016, 14:05

XNA wurde eingestellt. MonoGame ist die aktuelle "Fortsetzung"
MonoGame ist ein Framework das sich nahtlos in Visual Studio einbinden lässt, keine IDE.

Ich hatte bei meinem Versuch, ein XNA-Spiel auf Monogame zu portieren, leider immense Probleme. Monogame hat sich mittlerweile sehr weit von XNA weg entwickelt. Gleich heißende Funktionen verhalten sich teils vollständig anders, als man es aus XNA kennt, weil leider der "ich mach alles komplett anders, einfach weil ich es kann" Gedanke dort sehr ausgeprägt ist. Einfache Funktionen des Content-Importers, die bei XNA noch funktionierten, funktionieren bei Monogame nicht mehr richtig (z.B. automatische Erzeugung von Normal-, Tangent- und Binormal Spaces) und das größte Manko an MonoGame ist sicherlich die fehlende Anti-Aliasing Implementierung. Ich kam, ohne selbst am Monogame-Sourcecode rumzuschrauben, auf keinen grünen Zweig damit.

Ein neues Projekt mit Monogame zu starten, ist sicherlich eine Sache. Ein bestehendes Projekt mit hunderten Models, Soundfiles und Musik zu portieren, wo du an praktisch jedem Contentfile irgendwas ändern musst, damit du nicht irgendwelche ominösen nichtssagenden SharpDX Fehlermeldungen ('could not load sound file', InnerException=null) bekommst, davon würde ich abraten.

Nichts persönliches gegen die Verfechter von Monogame und die Community, die da zweifelsohne viel Arbeit reinsteckt, aber ich musste meinen Frust darüber jetzt einfach mal rauslassen. Meiner Meinung nach hat sich da unter der Haube gegenüber XNA viel zum Schlechten verändert.

PS: XNA funktioniert übrigens mit ein bisschen Editieren der Manifest-XML-Datei ohne Probleme in allen aktuelleren Visual Studio Versionen.
PPS: Sorry für etwas off-topic ;-)

Tician

Frischling

  • »Tician« ist der Autor dieses Themas

Beiträge: 32

Wohnort: Bad Friedrichshall

Beruf: FISI

  • Private Nachricht senden

17

30.06.2016, 13:54

Könnt ihr mir nochmal kurz helfen? Ich wollte aus Spaß mal 2 Spieler (und 2 mal "Futter") ausprobieren.

Das hier wie gehabt funktioniert:

C#-Quelltext

1
2
3
4
5
6
7
8
9
SolidBrush playerBrush = new SolidBrush(Color.Red);
Graphics grafik = this.CreateGraphics();
Rectangle circle = new Rectangle(headX, headY, circleH, circleW);
grafik.FillEllipse(playerBrush, circle);

SolidBrush foodBrush = new SolidBrush(Color.Blue);
Graphics futter = this.CreateGraphics();
Rectangle rekt = new Rectangle(rndFutterX, rndFutterY, 10, 10);
futter.FillRectangle(foodBrush, rekt);


Das hier funktioniert auch noch:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
SolidBrush playerBrush = new SolidBrush(Color.Red);
Graphics grafik = this.CreateGraphics();
Rectangle circle = new Rectangle(headX, headY, circleH, circleW);
grafik.FillEllipse(playerBrush, circle);

SolidBrush player2Brush = new SolidBrush(Color.Yellow);
Graphics grafik2 = this.CreateGraphics();
Rectangle circle2 = new Rectangle(head2X, head2Y, circleH, circleW);
grafik2.FillEllipse(player2Brush, circle2);

SolidBrush foodBrush = new SolidBrush(Color.Blue);
Graphics futter = this.CreateGraphics();
Rectangle rekt = new Rectangle(rndFutterX, rndFutterY, 10, 10);
futter.FillRectangle(foodBrush, rekt);


Das hier funktioniert nicht mehr

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
SolidBrush playerBrush = new SolidBrush(Color.Red);
Graphics grafik = this.CreateGraphics();
Rectangle circle = new Rectangle(headX, headY, circleH, circleW);
grafik.FillEllipse(playerBrush, circle);

SolidBrush player2Brush = new SolidBrush(Color.Yellow);
Graphics grafik2 = this.CreateGraphics();
Rectangle circle2 = new Rectangle(head2X, head2Y, circleH, circleW);
grafik2.FillEllipse(player2Brush, circle2);

SolidBrush foodBrush = new SolidBrush(Color.Blue);
Graphics futter = this.CreateGraphics();
Rectangle rekt = new Rectangle(rndFutterX, rndFutterY, 10, 10);
futter.FillRectangle(foodBrush, rekt);

SolidBrush food2Brush = new SolidBrush(Color.Azure);
Graphics futter2 = this.CreateGraphics();
Rectangle rekt2 = new Rectangle(rnd2FutterX, rnd2FutterY, 10, 10);
futter2.FillRectangle(food2Brush, rekt2);


Bei letzterem bekomme ich nur noch die 2 Kreise, die Rechtecke werden komplett ignoriert und ich weiß nicht warum, gibt es da etwas das ich nicht bedacht habe? :hmm:

Ich habe morgen schon eine Präsentation darüber und wollte das als kleines Highlight am Ende mit 2 Spieler-Modus machen :S


Das komplette sieht so aus, aber wie gesagt wird das Futter, also die Vierecke nicht mehr erstellt.

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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BubbleWars
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        Timer timer = new Timer();
        Random random1 = new Random();
        Random random2 = new Random();
        Random random3 = new Random();
        Random random4 = new Random();

        short headX = 100; //Spielerposition X
        short headY = 100; //Spielerposition Y
        short head2X = 200;
        short head2Y = 200;
        byte circleW = 10; //Breite des Kreises
        byte circleH = 10; //Höhe des Kreises
        int score = 0; //Punktzahl natürlich!
        int score2 = 0;
        int rndFutterX = 0; //eine Zufallszahl für die x-Achse des Futters
        int rndFutterY = 0; //eine Zufallszahl für die y-Achse des Futters|
        int rnd2FutterX = 0;
        int rnd2FutterY = 0;

        byte richtung = 0; //Variable für die Pfeiltasten
        byte richtung2 = 0;

        private void Form1_Load(object sender, EventArgs e)
        {
            this.Paint += Form1_Paint; //Aufruf Paint-Event
            timer.Interval = 1000;
            timer.Tick += new EventHandler(Update);
            timer.Start();

            rndFutterX = 10 * random1.Next(0, 35);
            rndFutterY = 10 * random2.Next(0, 35);
            rnd2FutterX = 10 * random3.Next(0, 35);
            rnd2FutterY = 10 * random4.Next(0, 35);
        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            SolidBrush playerBrush = new SolidBrush(Color.Red);
            Graphics grafik = this.CreateGraphics();
            Rectangle circle = new Rectangle(headX, headY, circleH, circleW);
            grafik.FillEllipse(playerBrush, circle);

            SolidBrush player2Brush = new SolidBrush(Color.Yellow);
            Graphics grafik2 = this.CreateGraphics();
            Rectangle circle2 = new Rectangle(head2X, head2Y, circleH, circleW);
            grafik2.FillEllipse(player2Brush, circle2);

            SolidBrush foodBrush = new SolidBrush(Color.Blue);
            Graphics futter = this.CreateGraphics();
            Rectangle rekt = new Rectangle(rndFutterX, rndFutterY, 10, 10);
            futter.FillRectangle(foodBrush, rekt);

            SolidBrush food2Brush = new SolidBrush(Color.Azure);
            Graphics futter2 = this.CreateGraphics();
            Rectangle rekt2 = new Rectangle(rnd2FutterX, rnd2FutterY, 10, 10);
            futter2.FillRectangle(food2Brush, rekt2);
        }

        private void Update(object sender, EventArgs e)
        {
            if (richtung == 1)
            {
                headY += 10;
                this.Refresh();
            }
            if (richtung == 2)
            {
                headY -= 10;
                this.Refresh();
            }
            if (richtung == 3)
            {
                headX -= 10;
                this.Refresh();
            }
            if (richtung == 4)
            {
                headX += 10;
                this.Refresh();
            }
            if (richtung2 == 1)
            {
                head2Y += 10;
                this.Refresh();
            }
            if (richtung2 == 2)
            {
                head2Y -= 10;
                this.Refresh();
            }
            if (richtung2 == 3)
            {
                head2X -= 10;
                this.Refresh();
            }
            if (richtung2 == 4)
            {
                head2X += 10;
                this.Refresh();
            }
            //Schlange an Rand
            if (headY == 360 || headY == -10 || headX == 360 || headX == -10)
            {
                timer.Stop();
                MessageBox.Show("Game Over. Player 1 ran into a wall.\nPlayer one score: "+score+"\nPlayer 2 score: "+score2);
            }
            if (head2Y == 360 || head2Y == -10 || head2X == 360 || head2X == -10)
            {
                timer.Stop();
                MessageBox.Show("Game Over. Player 2 ran into a wall.\nPlayer one score: " + score + "\nPlayer 2 score: " + score2);
            }
            if (head2Y == headX && head2Y == headY)
            {
                timer.Stop();
                MessageBox.Show("Game Over. You idiots crashed into each other!\nPlayer one score: " + score + "\nPlayer 2 score: " + score2);
            }


            //Schlange auf Futter
            if (headY == rndFutterY && headX == rndFutterX)
            {
                rndFutterX = 10 * random1.Next(0, 35);
                rndFutterY = 10 * random2.Next(0, 35);
                score += 1;
                if (timer.Interval > 250)
                {
                    timer.Interval = timer.Interval - 250;
                }
                if (timer.Interval > 100 && timer.Interval <= 250)
                {
                    timer.Interval = timer.Interval - 50;
                }
                if (timer.Interval > 20 && timer.Interval <= 100)
                {
                    timer.Interval = timer.Interval - 20;
                }
                if (timer.Interval > 2 && timer.Interval <= 20)
                {
                    timer.Interval = timer.Interval - 2;
                }
            }
            if (head2Y == rndFutterY && head2X == rndFutterX)
            {
                rndFutterX = 10 * random1.Next(0, 35);
                rndFutterY = 10 * random2.Next(0, 35);
                score2 += 1;
                if (timer.Interval > 250)
                {
                    timer.Interval = timer.Interval - 250;
                }
                if (timer.Interval > 100 && timer.Interval <= 250)
                {
                    timer.Interval = timer.Interval - 50;
                }
                if (timer.Interval > 20 && timer.Interval <= 100)
                {
                    timer.Interval = timer.Interval - 20;
                }
                if (timer.Interval > 2 && timer.Interval <= 20)
                {
                    timer.Interval = timer.Interval - 2;
                }
            }
            if (headY == rnd2FutterY && headX == rnd2FutterX)
            {
                rnd2FutterX = 10 * random3.Next(0, 35);
                rnd2FutterY = 10 * random4.Next(0, 35);
                score += 1;
                if (timer.Interval > 250)
                {
                    timer.Interval = timer.Interval - 250;
                }
                if (timer.Interval > 100 && timer.Interval <= 250)
                {
                    timer.Interval = timer.Interval - 50;
                }
                if (timer.Interval > 20 && timer.Interval <= 100)
                {
                    timer.Interval = timer.Interval - 20;
                }
                if (timer.Interval > 2 && timer.Interval <= 20)
                {
                    timer.Interval = timer.Interval - 2;
                }
            }
            if (head2Y == rnd2FutterY && head2X == rnd2FutterX)
            {
                rnd2FutterX = 10 * random3.Next(0, 35);
                rnd2FutterY = 10 * random4.Next(0, 35);
                score2 += 1;
                if (timer.Interval > 250)
                {
                    timer.Interval = timer.Interval - 250;
                }
                if (timer.Interval > 100 && timer.Interval <= 250)
                {
                    timer.Interval = timer.Interval - 50;
                }
                if (timer.Interval > 20 && timer.Interval <= 100)
                {
                    timer.Interval = timer.Interval - 20;
                }
                if (timer.Interval > 2 && timer.Interval <= 20)
                {
                    timer.Interval = timer.Interval - 2;
                }
            }
        }


        public void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Down)
            {
                richtung = 1;
            }
            if (e.KeyCode == Keys.Up)
            {
                richtung = 2;
            }
            if (e.KeyCode == Keys.Left)
            {
                richtung = 3;
            }
            if (e.KeyCode == Keys.Right)
            {
                richtung = 4;
            }
            if (e.KeyCode == Keys.S)
            {
                richtung2 = 1;
            }
            if (e.KeyCode == Keys.W)
            {
                richtung2 = 2;
            }
            if (e.KeyCode == Keys.A)
            {
                richtung2 = 3;
            }
            if (e.KeyCode == Keys.D)
            {
                richtung2 = 4;
            }
        }
    }
}

Tician

Frischling

  • »Tician« ist der Autor dieses Themas

Beiträge: 32

Wohnort: Bad Friedrichshall

Beruf: FISI

  • Private Nachricht senden

18

30.06.2016, 14:11

Problem gefunden. Es lag an meinen Random zahlen, sie waren alle dieselben, weswegen die Vierecke immer übereinander waren. Ich habe es gelöst indem ich aus 4 Random Klassen eine gemacht habe.

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Tician« (30.06.2016, 22:34)


Werbeanzeige