Skip to content

Commit 4388e23

Browse files
committed
Add stars, stars-mechanics, add tips
1 parent 8418a4c commit 4388e23

32 files changed

+61723
-146
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

CYPVP/.vs/CYPVP/v17/.suo

3.5 KB
Binary file not shown.

CYPVP/CYPVP.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
<Compile Include="Program.cs" />
7373
<Compile Include="Properties\AssemblyInfo.cs" />
7474
<Compile Include="Slime.cs" />
75+
<Compile Include="Star.cs" />
7576
<EmbeddedResource Include="Form1.resx">
7677
<DependentUpon>Form1.cs</DependentUpon>
7778
</EmbeddedResource>
@@ -230,5 +231,14 @@
230231
<ItemGroup>
231232
<None Include="Resources\Btn01.png" />
232233
</ItemGroup>
234+
<ItemGroup>
235+
<None Include="Resources\star_preview_rev_1.png" />
236+
</ItemGroup>
237+
<ItemGroup>
238+
<None Include="Resources\coin_collect.wav" />
239+
</ItemGroup>
240+
<ItemGroup>
241+
<None Include="Resources\oscillating-space-waves-31400.wav" />
242+
</ItemGroup>
233243
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
234244
</Project>

CYPVP/Character.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void Move(String Position,int Speed,int Height,int Width,int x,int y)
2828
if (Position == "UP")
2929
{
3030
int NewPosition = CharacterSkin.Location.Y - Speed;
31-
if (NewPosition >= 80d)
31+
if (NewPosition >= 80)
3232
{
3333

3434

CYPVP/Form1.Designer.cs

Lines changed: 18 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CYPVP/Form1.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ namespace CYPVP
1515
public partial class CYPVP : Form
1616
{
1717
public MainMenu Menu { get; set; }
18-
18+
public static Random Random { get; set; }
19+
1920
public CYPVP()
2021
{
2122
InitializeComponent();
2223
Menu = new MainMenu();
2324
LoadMenu();
25+
Random=new Random();
2426
}
2527

2628
private void LoadMenu()
@@ -80,5 +82,7 @@ private void btn_start_Click(object sender, EventArgs e)
8082
//Menu.Play();
8183
}
8284
}
85+
86+
8387
}
8488
}

CYPVP/Game.cs

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,51 @@
55
using System.Threading.Tasks;
66
using System.Windows.Forms;
77
using System.Drawing;
8+
using System.Media;
9+
810
namespace CYPVP
911
{
1012
public class Game
1113
{
1214
public Character MainCharacter { get; set; }
15+
public List<Star> List0fStars { get; set; }
16+
public SoundPlayer CollectCoinSound { get; set; }
17+
1318

1419
public Slime MainSlime { get; set; }
1520
public int Score { get; set; }
1621
public int Time { get; set; }
1722

1823

19-
24+
2025
public Game(int height,int width,PictureBox mainCharacter,PictureBox mainSlime) {
2126
MainCharacter = new Character(mainCharacter);
2227
MainSlime=new Slime(mainSlime);
2328
Time = 90;
2429
Score = 0;
30+
List0fStars=new List<Star>();
31+
CollectCoinSound = new SoundPlayer(Properties.Resources.coin_collect);
32+
2533
}
2634

35+
public void CreateStars()
36+
{
37+
for(int i=0; i < 5; i++)
38+
{
39+
PictureBox star = new PictureBox();
40+
star.BackColor = Color.Transparent;
41+
star.Image = Properties.Resources.star;
42+
int x = CYPVP.Random.Next(25, 696);
43+
int y = CYPVP.Random.Next(93, 486);
44+
star.Location=new Point(x, y);
45+
List0fStars.Add(new Star(star));
46+
}
47+
48+
}
49+
public static int Distance0f(Point x, Point y)
50+
{
51+
return (int)Math.Sqrt(Math.Pow((x.X - y.X), 2) + Math.Pow((x.Y - y.Y), 2));
52+
}
2753
internal void MoveCharacter(int Height,int Width)
2854
{
2955
if (MainCharacter.CanMoveUp)
@@ -43,11 +69,33 @@ internal void MoveCharacter(int Height,int Width)
4369
MainCharacter.Move("RIGHT", 15, Height, Width, MainSlime.SlimeSkin.Location.X, MainSlime.SlimeSkin.Location.Y);
4470
}
4571

72+
4673
}
4774

4875
internal void MoveSlime()
4976
{
5077
MainSlime.Move((int)MainCharacter.CharacterSkin.Location.X, (int)MainCharacter.CharacterSkin.Location.Y);
78+
79+
}
80+
public int Check()
81+
{
82+
return Distance0f(MainCharacter.CharacterSkin.Location, List0fStars[0].StarSkin.Location);
83+
}
84+
85+
internal void CheckIfEaten()
86+
{
87+
foreach(Star c in List0fStars)
88+
{
89+
if (Distance0f(MainCharacter.CharacterSkin.Location, c.StarSkin.Location) < 30)
90+
{
91+
c.IsEaten = true;
92+
Score += 10;
93+
94+
}
95+
}
96+
97+
98+
5199
}
52100
}
53101
}

0 commit comments

Comments
 (0)