Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • elmotabe/ohj1ht
  • jotapark/ohj1ht
  • tanelira/ohj1ht
  • akrasa/ohj1ht
  • mimaahin/ohj1ht
  • oihietan/ohj1ht
  • tie/ohj1/2024s/ohj1ht
  • anpahypp/ohj1ht
  • saelripa/ohj1ht
  • mapepess/ohj1ht
  • eamaki/you-lost-the-game-the-game
  • yubablum/yubablum
  • roelsuom/roelsuom
  • askoleax/hakkaa-uudelleen
  • palolala/ohj-1-ht
  • jasyvays/ohj1ht
  • ruviljam/ohj1ht
  • jookettu/ohj1ht
  • vervarjo/ohj-1-ht
  • conrcsir/ohj1ht
  • otananti/ohj-1-ht
  • eerepo/ohj1ht
  • vieeaape/my-megis-1
  • uaopolso/ohj1ht
  • miltarva/Milja
  • huotta/ohj-1-ht
  • rrisiisk/ohj-1-ht
  • vesal/vesal5
  • saniitty/ohj1ht
  • setilus/ohj-1-ht
  • stniemel/stniemel
  • hirvepjw/ohj1ht
  • pjyypiix/ohj1ht
  • erpajala/ohj1ht
  • eerjanho/ohj1ht
  • saeteppo/ohj1ht
  • jutautri/ohj1ht
  • pjgenas/harkkatyop-g
  • juhsansa/juhsansa
  • pellrata/qmoduuli
  • mvaalata/ohj1ht
  • visamata/ohj1ht
  • rlokilja/ohj1ht
  • tuohmawi/ohj1ht
  • itsario/ohj-1-ht
  • koivishe/teekkarin-taival-2048
  • peillips/ohj1ht
  • nkeuren/ohj1ht
  • sasoleht/ohj1ht
  • jooantni/ohj1ht
  • kivistve/ohj1ht
  • rmrintal/ohj1ht
  • maimatsa/ohj1ht
  • hiltunma/ohj1ht
  • timovaan/ohj1ht
  • palaakho/numero-peli
  • loukovjv/ohj1ht
  • julipits/ohj1ht
  • haelkaja/ohj1ht
  • otjomatt/ohj-1-ht
  • jejalaht/ohj1ht
  • mamiparv/ohj1ht
  • akharine/ohj1ht
  • visevima/ohj1ht
  • rtmatilt/swatter
  • linvilan/ohj1ht
  • eppkarki/ohj1ht
  • maaivasi/ohj1ht
  • saveveka/saveveka
  • laitozz/ohj1ht
  • mietmiaa/ohj1ht
  • suominsh/tankkipeli
  • osalo/ohj1ht
  • jniskane/ohj1ht
  • jniskane/ohj-1-ht-2
  • jniskane/jniskane
  • kainumee/ohj1ht
  • helijave/ohj1ht
  • eemjorto/ohj1ht
  • nmpuskzv/nmpuskzv
  • laiadevi/ohj1ht
  • tochmart/ohj1ht
  • roijerve/bit-survivors
  • essmarpe/ohj1ht
  • eeeeoino/ohj1ht
  • rikretel/ohj1ht
  • anilnikk/ohj1ht
  • sivupehe/ohj1ht
  • torkhema/ohj1ht
  • vvlaspa/ohj1ht
  • apenttin/ohj1ht
  • ruotvive/ohj1ht
  • jemanare/ohj-1-ht-1
  • reponaw/ohj1ht
  • hjmhilli/hjmhilli
  • oapaaso/vads-sovellus
  • jaemvahu/ohj1ht
  • lajoveps/pallopeli
  • thalolri/ohj1ht
  • niemimm/ohj1ht
  • kagwochx/ohj1ht
  • kkvalke/ohj1ht
  • jormlsuu/pako-matka
  • kkmartik/harjoitustyo-ohj-1
  • lainejee/ohj1ht
  • taelbevi/ohj-1-ht
  • tornittu/ohj1ht
  • iiaumaoi/ohj1ht
  • ovevalka/pyramidin-purkaus
  • ltvertai/ohj-1-ht-kissan-sieniretki
  • leoksamu/ohj-1-ht-avaajosuskallat
  • ekhoalas/ohj1ht
  • saarakka/ohj1ht
  • rantajsu/rantajsu
  • jaetykky/ohj1ht
  • tyynakka/ohj1ht
  • kousaepw/ohj1ht
  • tiiliksi/ohj1ht
  • kokkaree/ohj1ht
  • halolpvz/ohj1ht
  • salonevs/ohj1ht
  • mohamoah/ohj1ht
  • vihavi/Vihavi
  • sisjeany/ohj1ht
  • kalopali/ohjelmointi-1-harjoitustyo
  • aabdi/ohj1ht
  • nsmietyt/ohj1ht
  • pslohi/ohj1ht
  • eenorta/ohj1ht
  • kantsiii/ohj1ht
  • aichinos/ohj1ht
  • elvihave/ohj1ht
  • tukilo/ohj1ht
  • vilvalka/ohj1ht
  • vehakkar/ohj1ht
  • savolave/ohj1ht
  • myhesare/ohj1ht
  • jutaalko/ohj1ht
  • auvijeka/ohj-1-ht
  • miankort/ohj1ht
  • ahtiansu/ohj1ht
  • rekolapi/rekolapi
  • oparve/ohj1ht
  • tuoskopp/ohj1ht
  • kylkii/ohj1ht
  • mkvuonos/ohj1ht
  • eeemkarv/ohj1ht
  • ojbhuota/ohj1ht
  • pohtojoj/vainylos
  • seaaemla/ohj1ht
  • kotajuka/ohj1ht
  • pmikaiko/ohj1ht
  • heajuvon/ohj1ht
  • mannmiar/ohj1ht
  • juriloaa/ohj1ht
  • emmamaki/e-makinen-tapio-ja-hiisi
  • pjheimon/ohj1ht
  • ahonenvi/ohj1ht
  • joamaxma/ohj1ht
  • lktkyllo/ohj1ht
  • pirinpot/ohj1ht
  • nisknmyy/ohj1ht
  • mmleppis/ohj1ht
  • elle/ohj1ht
  • alevilpa/ohj1ht
  • pitksouu/ohj1ht
  • jukakorp/ohj1ht
  • lesatuom/kaarmetyo
  • joolmatt/ohj1ht
  • lailvout/ohj1ht
  • pepartyy/ohj1ht
  • siwpentt/ohj-1-ht
  • limasjoh/ohj1ht
  • nurmsajo/ohj1ht
  • laleiho/ohj1ht
  • kojotarn/ohj1ht
  • matijazz/ohj1ht
  • tuomiluu/ohj1ht
  • vperkkol/ohj1ht
  • vepajuna/ohj1ht
  • smrautio/sokkelo
  • aajualal/harjoitustehtava-mage-survival
  • laaajoke/ohj1ht
  • tmgartow/ohj1ht
  • pdanilei/ohj1ht
  • kaipainm/kalastaja-kalevi
  • hietaolo/ohj1ht
  • inkemiah/skatemania
  • inkemiah/ohj-1-ht
  • puhavezz/puhavezz
  • truhtejo/ohj1ht
  • eoelehto/jumping-moose
  • sediiv/ohj1ht
  • akjuhesa/ohj1ht
  • sasalons/ohj1ht
  • valltoha/ohj-1-ht-blackjack
  • aajataip/ohj1ht
  • lamakany/ohj1ht
  • eepihote/ohj1ht
  • jaaseepe/ohj1ht
  • arpaanan/ohj1ht
  • vuorelma/ohj1ht
  • isojarto/ohj-1-ht
  • mtkarjal/ohj1ht
  • samavakk/ohj1ht
  • viininkr/jalkapallo-peli
  • elkortti/nyrkkeily
  • heautuom/ohj1ht
  • alimyy/tasohyppely
  • haloneot/ohj1ht
  • launon/ohj-1-ht
  • jemvirzy/kirjoitus-peli
  • miniospa/miniospa
  • aeheiska/apina-peli
  • saheikkx/ohj-1-htt
  • jalempel/ohj-1-ht
  • jujolaih/jump-guys
  • hejolesk/ohj1ht
  • akkasivu/ohj1ht
  • sajussin/ohj1ht
  • alhainai/ohj-1-ht
  • jamajuku/ohj1ht
  • eevharki/jalkapallopeli
  • annhenle/escape
  • kjsalova/ohj1ht
  • marjohku/ohj1ht
226 results
Show changes
Commits on Source (15)
Showing
with 384 additions and 0 deletions
File added
File added
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/contentModel.xml
/.idea.Escape.iml
/modules.xml
/projectSettingsUpdater.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Escape", "Escape\Escape.csproj", "{8B1D90DF-F3DC-4808-ADA4-17367347EB82}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8B1D90DF-F3DC-4808-ADA4-17367347EB82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8B1D90DF-F3DC-4808-ADA4-17367347EB82}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8B1D90DF-F3DC-4808-ADA4-17367347EB82}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8B1D90DF-F3DC-4808-ADA4-17367347EB82}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
File added
File added
Escape/Escape/Content/Barkov.png

1.13 KiB

Escape/Escape/Content/Barkov_move1.png

1.28 KiB

Escape/Escape/Content/Barkov_move2.png

1.28 KiB

Escape/Escape/Content/Barkov_tackle.png

538 B

Escape/Escape/Content/player.png

1.03 KiB

Escape/Escape/Content/player_move1 kopio.png

1.02 KiB

Escape/Escape/Content/player_move1.png

1.02 KiB

Escape/Escape/Content/player_move2.png

1.03 KiB

Escape/Escape/Content/player_tackled.png

625 B

using System;
using System.Collections.Generic;
using Jypeli;
using Jypeli.Assets;
using Jypeli.Controls;
using Jypeli.Widgets;
namespace Escape;
/// @author annilehtinen
/// @version 09.04.2025
/// <summary>
/// Peli, jossa pelaajaan tavoitteena on vältellä vastustajaa (Barkov) ja kerätä kiekkoja saadakseen pisteitä.
/// </summary>
public class Escape : PhysicsGame
{
private IntMeter _pointCounter;
private Image[] _playerSkate = LoadImages("player_move1.png", "player_move2.png");
private Image[] _playerIdle = LoadImages("player.png");
private readonly Image[] _barkovSkate = LoadImages("Barkov_move1.png", "Barkov_move2.png");
private Image[] _barkovIdle = LoadImages("Barkov_move1.png");
public override void Begin()
{
Camera.ZoomToLevel();
CreateLevel();
PhysicsObject player = AddPlayer(this);
SetControls(player);
SetAnimation(player);
PhysicsObject barkov = AddBarkov(this, player);
AddCollisionHandler(player, barkov, Tackle);
AddCollisionHandler(player, "puck", CollectPuck);
Timer.CreateAndStart(4.0, SpawnPucks);
}
/// <summary>
/// Peliohjainten asettaminen pelaajalle
/// </summary>
/// <param name="player">Hahmo, jolle ohjainkomennot lisätään</param>
void SetControls(PhysicsObject player)
{
Keyboard.Listen(Key.Up, ButtonState.Down, MovePlayer, "Liikuta pelaajaa eteenpäin", player);
Keyboard.Listen(Key.Left, ButtonState.Down, TurnPlayer, "Käännä pelaajaa vasemmalle", player, 2.0);
Keyboard.Listen(Key.Left, ButtonState.Released, TurnPlayer, null, player, 0.0);
Keyboard.Listen(Key.Right, ButtonState.Down, TurnPlayer, "Käännä pelaajaa oikealle", player,-2.0);
Keyboard.Listen(Key.Right, ButtonState.Released, TurnPlayer, null, player,0.0);
Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");
}
/// <summary>
/// Asetetaan pelaajalle animaatio sen mukaan, onko hän aktiivisessa liikkeessä (luistelee) vai liukuu/on paikallaan
/// </summary>
/// <param name="player">Pelaaja, jonka hahmolle animaatiot asetetaan</param>
void SetAnimation(PhysicsObject player)
{
Animation skate = new Animation(_playerSkate);
Animation idle = new Animation(_playerIdle);
Keyboard.Listen(Key.Up, ButtonState.Pressed, () =>
{
player.Animation = skate;
player.Animation.FPS = 9;
player.Animation.Start();
}, null);
Keyboard.Listen(Key.Up, ButtonState.Up, () =>
{
player.Animation = idle;
player.Animation.Start();
}, null);
}
/// <summary>
/// Lisää pelaajan hahmon pelikentälle ja määrittää sen ominaisuudet
/// </summary>
/// <param name="game">Peli, johon hahmo lisätään</param>
/// <returns>Pelaaja</returns>
static PhysicsObject AddPlayer(PhysicsGame game)
{
PhysicsObject player = new PhysicsObject(40, 40, -450, 0);
player.Image = LoadImage("player.png");
player.CanRotate = false;
player.LinearDamping = 0.95;
game.Add(player);
return player;
}
/// <summary>
/// Lisää "vihollisen" eli Barkovin pelikentälle
/// </summary>
/// <param name="game">Peli, johon hahmo lisätään</param>
/// <param name="target">Kohde, jota Barkov seuraa (pelaajan hahmo)</param>
/// <returns>Barkov</returns>
PhysicsObject AddBarkov(PhysicsGame game, PhysicsObject target)
{
PhysicsObject barkov = new PhysicsObject(45, 45, 450, 0);
barkov.CollisionIgnoreGroup = 1;
Animation idle = new Animation(_barkovIdle);
Animation skate = new Animation(_barkovSkate);
barkov.Animation = idle;
FollowerBrain fb = new FollowerBrain(target);
int followingDistance = 600;
fb.DistanceFar = followingDistance;
fb.Speed = 50;
fb.Active = true;
fb.TurnWhileMoving = true;
barkov.Brain = fb;
game.Add(barkov);
fb.DistanceToTarget.AddTrigger(600, TriggerDirection.Down, () =>
{
barkov.Animation = skate;
barkov.Animation.FPS = 9;
barkov.Animation.Start();
});
return barkov;
}
/// <summary>
/// Törmäyksenkäsittelijä pelaajahahmolle ja Barkoville
/// </summary>
/// <param name="player">Pelaajan hahmo</param>
/// <param name="barkov">Barkov</param>
void Tackle(PhysicsObject player, PhysicsObject barkov)
{
Image tackled = LoadImage("player_tackled.png");
barkov.Image = LoadImage("Barkov_tackle.png");
IsPaused = true;
Keyboard.Listen(Key.Up, ButtonState.Irrelevant, () => player.Image = tackled, null);
EndGame();
//Peli päättyy tähän taklaukseen
}
/// <summary>
/// Pelin lopetus
/// </summary>
void EndGame()
{
Label ending = new Label("Game over!");
ending.Position = new Vector(0, 80);
ending.Color = Color.Red;
ending.TextColor = Color.White;
Add(ending);
int pucksCollected = _pointCounter.Value;
Label collectedPucks = new Label($"You collected {pucksCollected} pucks!");
collectedPucks.Position = new Vector(0, 50);
collectedPucks.TextColor = Color.Black;
Add(collectedPucks);
}
/// <summary>
/// Pelaaja kerää kiekon pelikentältä
/// </summary>
/// <param name="player">Pelaajan hahmo</param>
/// <param name="puck">Kiekko, joka poistetaan kentältä</param>
void CollectPuck(PhysicsObject player, PhysicsObject puck)
{
puck.Destroy();
_pointCounter.Value += 1;
}
/// <summary>
/// Pelaajan liikuttaminen eteenpäin
/// </summary>
/// <param name="player">Hahmo, jota liikutetaan</param>
void MovePlayer(PhysicsObject player)
{
int playerSpeed = 10;
Vector playerDirection = Vector.FromLengthAndAngle(50.0, player.Angle);
player.Push(playerDirection * playerSpeed);
}
/// <summary>
/// Pelaajan kääntäminen nuolinäppäinten avulla
/// </summary>
/// <param name="player">Pelaaja, jonka hahmoa käännetään</param>
/// <param name="angle">Kulma, jossa hahmoa käännetään</param>
void TurnPlayer(PhysicsObject player, double angle)
{
player.Angle += Angle.FromDegrees(angle);
}
/// <summary>
/// Kiekon lisääminen kentälle satunnaiseen kohtaan
/// </summary>
/// <param name="amount">Kuinka monta kiekkoa luodaan kentälle</param>
/// <param name="lifetime">Aika, jonka kiekko on kentällä ennen kuin se katoaa</param>
void SpawnPucks(int amount, double lifetime)
{
for (int i = 1; i <= amount; i++)
{
PhysicsObject puck = new PhysicsObject(18, 18);
puck.CollisionIgnoreGroup = 1;
puck.Shape = Shape.Circle;
puck.Color = Color.Black;
puck.LifetimeLeft = TimeSpan.FromSeconds(lifetime);
puck.Position = Level.GetRandomPosition();
puck.Tag = "puck";
this.Add(puck);
}
}
/// <summary>
/// Yhden kiekon lisääminen kentälle satunnaiseen kohtaan viiden sekunnin ajaksi,
/// jos kutsussa ei anneta parametrinä määrää ja aikaa erikseen
/// </summary>
void SpawnPucks()
{
SpawnPucks(1, 5.0);
}
/// <summary>
/// Luodaan kenttä ja pistelaskuri, lisätään kentälle haluttu määrä kiekkoja (pelin alkaessa)
/// </summary>
void CreateLevel()
{
Surfaces borders = Level.CreateBorders(0.5, true, Color.White);
CreatePointCounter();
SpawnPucks(5, 10.0);
}
/// <summary>
/// Luodaan pistelaskuri, joka antaa pelaajalle yhden pisteen jokaisesta kerätystä kiekosta
/// </summary>
void CreatePointCounter()
{
_pointCounter = new IntMeter(0);
Label points = new Label();
points.X = Screen.Right -140;
points.Y = Screen.Top -30;
points.TextColor = Color.White;
points.Title = "Pucks collected: ";
points.BindTo(_pointCounter);
Add(points);
}
}
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Jypeli.NET" Version="11.*"/>
<PackageReference Include="Jypeli.FarseerPhysics.NET" Version="2.*"/>
</ItemGroup>
<ItemGroup>
<None Update="Content\Barkov.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Content\still_player.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Content\player.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Content\player_move1.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Content\player_move2.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Content\Barkov_move1.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Content\Barkov_move2.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Content\player_move1 kopio.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Content\puck.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Content\puck3.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Content\Barkov_peili.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Content\player_tackled.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Content\Barkov_tackle.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
#endregion
namespace Escape
{
/// <summary>
/// The main class.
/// </summary>
public static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
using var game = new Escape();
game.Run();
}
}
}
\ No newline at end of file