Initializes basic game framework

Configures the default level, game mode, player controller, and player pawn.

Sets up basic movement input for the player pawn.

This commit lays the groundwork for further game development.
This commit is contained in:
2025-10-14 01:18:44 +02:00
parent 232a87f026
commit feae7b6997
10 changed files with 48 additions and 2 deletions

View File

@@ -1,7 +1,9 @@
[/Script/EngineSettings.GameMapsSettings] [/Script/EngineSettings.GameMapsSettings]
GameDefaultMap=/Engine/Maps/Templates/OpenWorld GameDefaultMap=/Game/CTP/01_Level/L_Default.L_Default
GlobalDefaultGameMode=/Script/M4_CPP.M4_Gamemode
EditorStartupMap=/Game/CTP/01_Level/L_Default.L_Default
[/Script/Engine.RendererSettings] [/Script/Engine.RendererSettings]
r.AllowStaticLighting=False r.AllowStaticLighting=False

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,11 +1,17 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#include "M4_Gamemode.h" #include "M4_Gamemode.h"
#include "M4_PlayerController.h"
#include "M4_PlayerPawn.h"
AM4_Gamemode::AM4_Gamemode() AM4_Gamemode::AM4_Gamemode()
{ {
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false; PrimaryActorTick.bCanEverTick = false;
PlayerControllerClass = AM4_PlayerController::StaticClass();
DefaultPawnClass = AM4_PlayerPawn::StaticClass();
} }
void AM4_Gamemode::BeginPlay() void AM4_Gamemode::BeginPlay()

View File

@@ -3,16 +3,33 @@
#include "M4_PlayerController.h" #include "M4_PlayerController.h"
#include "Camera/CameraComponent.h"
AM4_PlayerController::AM4_PlayerController() AM4_PlayerController::AM4_PlayerController()
{ {
CameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("CameraComponent"));
CameraComponent->ProjectionMode = ECameraProjectionMode::Orthographic;
CameraComponent->OrthoWidth = 2048.0f;
CameraComponent->SetupAttachment(RootComponent);
} }
void AM4_PlayerController::BeginPlay() void AM4_PlayerController::BeginPlay()
{ {
Super::BeginPlay(); Super::BeginPlay();
if (CameraComponent)
{
CameraComponent->SetRelativeLocation(FVector(0, 0, 1000));
CameraComponent->SetRelativeRotation(FRotator(-90.0f, 0.0f, 0.0f));
}
} }
void AM4_PlayerController::SetupInputComponent() void AM4_PlayerController::SetupInputComponent()
{ {
Super::SetupInputComponent(); Super::SetupInputComponent();
}
void AM4_PlayerController::OnPossess(APawn* InPawn)
{
Super::OnPossess(InPawn);
} }

View File

@@ -41,4 +41,19 @@ void AM4_PlayerPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputCompo
EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AM4_PlayerPawn::Move); EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AM4_PlayerPawn::Move);
} }
} }
}
void AM4_PlayerPawn::Move(const FInputActionValue& Value)
{
// Récupérer la valeur du mouvement (vecteur 2D pour horizontal/vertical)
FVector2D MovementVector = Value.Get<FVector2D>();
// Appliquer le mouvement
if (Controller)
{
FVector NewLocation = GetActorLocation();
NewLocation.X += MovementVector.X;
NewLocation.Y += MovementVector.Y;
SetActorLocation(NewLocation);
}
} }

View File

@@ -4,6 +4,7 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "GameFramework/PlayerController.h" #include "GameFramework/PlayerController.h"
#include "Camera/CameraComponent.h"
#include "M4_PlayerController.generated.h" #include "M4_PlayerController.generated.h"
/** /**
@@ -21,8 +22,10 @@ public:
protected: protected:
virtual void SetupInputComponent() override; virtual void SetupInputComponent() override;
virtual void OnPossess(); virtual void OnPossess(APawn* InPawn) override;
private: private:
UPROPERTY(VisibleAnywhere,BlueprintReadOnly ,Category="Centipede", meta = (AllowPrivateAccess = "true"))
TObjectPtr<UCameraComponent> CameraComponent;
}; };

View File

@@ -5,6 +5,7 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "GameFramework/Pawn.h" #include "GameFramework/Pawn.h"
#include "InputAction.h" #include "InputAction.h"
#include "InputActionValue.h"
#include "Components/StaticMeshComponent.h" #include "Components/StaticMeshComponent.h"
#include "EnhancedInputComponent.h" #include "EnhancedInputComponent.h"
#include "EnhancedInputSubsystems.h" #include "EnhancedInputSubsystems.h"
@@ -38,6 +39,8 @@ private:
UPROPERTY(Category = "Centipede", VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true")) UPROPERTY(Category = "Centipede", VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
TObjectPtr<UStaticMeshComponent> MeshComponent; TObjectPtr<UStaticMeshComponent> MeshComponent;
void Move(const FInputActionValue& Value);
}; };