NineteenEightyFour
by Dom with pixel art by Luke: both Y9 Aged ~14
Introduction
This is a most impressive, imaginative collaboration. The combination of Luke's pixel art with the choice of supplied font and audio creates a fitting atmosphere. (There are a few magabytes of game assets so please use a good internet connection). You must reach the scene with the street lighting to appreciate fully Dom's creativity. See below notes on how to play the game, the game itself, technical features and the Smart Pascal code of Unit Main. The code of Scenes.pas is on the following page.
Gameplay
"1984 is a game based on the novel by George Orwell. It follows the story of Winston Smith and his experiences in the totalitarian superstate of Oceania. As the player, you must try and survive the oppressive government while simultaneously keeping your sanity. You must balance the red bar, representing danger level and the green bar representing sanity level. If the balance tips, your life will be on the line."
If the program does not work after clicking on the display, try another browser such as Chrome. If you see no display at school, the security system might have blocked it. You can try instead this direct link to the program running on its own page.
Technical Features
The program benefits from:
- impressive use of pixel art, supplied font (from http://www.dafont.com/visitor.font) and audio (from OPENGAMEART.ORG);
- own procedures;
- use of inbuilt routines such as LoadFromURL, DrawImageF, FillRectF, FillText;
- use of the inbuilt types TRect and TPoint;
- handling of mouse input.
Code of Unit Main
In order to compile this code with Version 3.0 of Smart Mobile Studio, add System.Types.Graphics to the uses clause.
unit Main; { Copyright (c) 2017 Dom with pixel art by Luke Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License, as described at http://www.apache.org/licenses/ and http://www.pp4s.co.uk/licenses/ } interface uses System.Types, SmartCL.System, SmartCL.Components, SmartCL.Application, SmartCL.Game, SmartCL.GameApp, SmartCL.Graphics, SmartCL.Controls.Image, Scenes, SmartCL.MediaElements; var VictoryMansions, VictoryMansionsInside, Gun, Street1, Street2, Office, GettingHanged, MiniLuvCell, AtHangings, HPH, Room1oh1, ShopRoom, Room1, Room2, Hanged, InBush, DiaryEmpt, DiaryFull, Hallway, Elevator, BigB : TW3Image; //images Theme, Hang, Shwoosh, Crash : TW3AudioElement; btnOne, btnTwo : TRect; Ln1, Ln2, Ln3, Ln4 : String; ScreenW, ScreenH, Width, Height, HalfW, HalfH, Along, InsanityAdd, SuspicionAdd: integer; RandomImg : integer := 0; ImgBool : Boolean := False; Insanity : integer := 50; Suspicion : integer := 50; Timer, x, y, TransitionWidthOut, TransitionWidthIn: integer; CurrentImg : string; PlayCrash: Integer := 0; MouseClickedOne: Boolean := False; MouseClickedTwo: Boolean := False; MouseClickedElsewhere: Boolean := False; Scene : string := "Intro"; TransitionOut : Boolean := false; Reason, NextScene : String; Bypass : Boolean := False; { Compressed file with image data included available at http://www.pp4s.co.uk/static/pp4s/resources/Main.zip const workroom ='data:image/png;base64,'+ '~~~~~~~'; const streeta ='data:image/png;base64,'+ '~~~~~~~'; const streetb ='data:image/png;base64,'+ '~~~~~~~'; const victma ='data:image/png;base64,'+ '~~~~~~~'; const victmain ='data:image/png;base64,'+ '~~~~~~~'; const bush ='data:image/png;base64,'+ '~~~~~~~'; const attendhangings ='data:image/png;base64,'+ '~~~~~~~'; const gethanged ='data:image/png;base64,'+ '~~~~~~~'; const bigbrother ='data:image/png;base64,'+ '~~~~~~~'; const corridor ='data:image/png;base64,'+ '~~~~~~~'; const lift ='data:image/png;base64,'+ '~~~~~~~'; const emptydiary ='data:image/png;base64,'+ '~~~~~~~'; const fulldiary ='data:image/png;base64,'+'~~~~~~~'; const shotgun ='data:image/png;base64,'+ '~~~~~~~'; const bedroom ='data:image/png;base64,'+ '~~~~~~~'; const capturebedroom ='data:image/png;base64,'+ '~~~~~~~'; const Rm101 ='data:image/png;base64,'+ '~~~~~~~'; const storefront ='data:image/png;base64,'+ '~~~~~~~'; const highpartyhouse ='data:image/png;base64,'+ '~~~~~~~'; const darkcell ='data:image/png;base64,'+ '~~~~~~~'; } type TCanvasProject = class(TW3CustomGameApplication) protected procedure HandleButtonPressed(x, y: integer); procedure HandleButtonReleased; procedure ApplicationStarting; override; procedure ApplicationClosing; override; procedure PaintView(Canvas: TW3Canvas); override; end; implementation procedure TCanvasProject.HandleButtonPressed(x, y: integer); begin var Point := TPoint.Create(x, y); if btnOne.ContainsPoint(Point) then begin MouseClickedOne := True; end else if btnTwo.ContainsPoint(Point) then begin MouseClickedTwo := True; end; MouseClickedElsewhere := True; end; procedure TCanvasProject.HandleButtonReleased; begin MouseClickedOne := False; MouseClickedTwo := False; MouseClickedElsewhere := False; end; procedure TCanvasProject.ApplicationStarting; begin inherited; ScreenW := GameView.width; ScreenH := GameView.height; Width := 830; Height := 530; HalfW := GameView.width div 2; HalfH := GameView.height div 2; Theme := TW3AudioElement.Create; if Theme.CanPlayTypeAsBoolean('audio/ogg') then Theme.Source := 'res/main.ogg'; Theme.Volume := 0.3; Hang := TW3AudioElement.Create; if Hang.CanPlayTypeAsBoolean('audio/ogg') then Hang.Source := 'res/hang.ogg'; Hang.Volume := 1; Shwoosh := TW3AudioElement.Create; if Shwoosh.CanPlayTypeAsBoolean('audio/ogg') then Shwoosh.Source := 'res/shwoosh.ogg'; Shwoosh.Volume := 1; Crash := TW3AudioElement.Create; if Crash.CanPlayTypeAsBoolean('audio/ogg') then Crash.Source := 'res/crash.ogg'; Crash.Volume := 1; VictoryMansions := TW3Image.Create(nil); VictoryMansions.LoadFromURL(victma); Street1 := TW3Image.Create(nil); Street1.LoadFromURL(streeta); Street2 := TW3Image.Create(nil); Street2.LoadFromURL(streetb); VictoryMansionsInside := TW3Image.Create(nil); VictoryMansionsInside.LoadFromURL(victmain); GettingHanged := TW3Image.Create(nil); GettingHanged.LoadFromURL(gethanged); AtHangings := TW3Image.Create(nil); AtHangings.LoadFromURL(attendhangings); InBush := TW3Image.Create(nil); InBush.LoadFromURL(bush); DiaryEmpt := TW3Image.Create(nil); DiaryEmpt.LoadFromURL(emptydiary); DiaryFull := TW3Image.Create(nil); DiaryFull.LoadFromURL(fulldiary); Elevator := TW3Image.Create(nil); Elevator.LoadFromURL(lift); Hallway := TW3Image.Create(nil); Hallway.LoadFromURL(corridor); BigB := TW3Image.Create(nil); BigB.LoadFromURL(bigbrother); Office := TW3Image.Create(nil); Office.LoadFromURL(workroom); Gun := TW3Image.Create(nil); Gun.LoadFromURL(shotgun); Hanged := TW3Image.Create(nil); Hanged.LoadFromURL(gethanged); Room1 := TW3Image.Create(nil); Room1.LoadFromURL(bedroom); Room2 := TW3Image.Create(nil); Room2.LoadFromURL(capturebedroom); HPH := TW3Image.Create(nil); HPH.LoadFromURL(highpartyhouse); Room1oh1 := TW3Image.Create(nil); Room1oh1.LoadFromURL(Rm101); ShopRoom := TW3Image.Create(nil); ShopRoom.LoadFromURL(storefront); MiniLuvCell := TW3Image.Create(nil); MiniLuvCell.LoadFromURL(darkcell); btnOne := TRect.CreateSized(630 + (HalfW - Width div 2), 200 + (HalfH - Height div 2), 170, 80); btnTwo := TRect.CreateSized(630 + (HalfW - Width div 2), 320 + (HalfH - Height div 2), 170, 80); GameView.Delay := 1; //1 millisecond GameView.OnMouseDown := procedure(o: TObject; b: TMouseButton; t: TShiftState; x, y: integer) begin HandleButtonPressed(x, y); end; GameView.OnMouseUp := procedure(o: TObject; b: TMouseButton; t: TShiftState; x, y: integer) begin HandleButtonReleased; end; GameView.StartSession(True); Theme.currentTime := 0; Theme.loop := True; Theme.Play; end; procedure TCanvasProject.PaintView(Canvas: TW3Canvas); //Repeated every millisecond begin Canvas.FillStyle := "#363942"; Canvas.FillRectF(0,0,GameView.Width,GameView.Height); if Scene = "Intro" then begin Scenes.Intro(Canvas); end else if Scene = "VictMA" then begin Scenes.VictMA(Canvas); end else if Scene = "VictMAIn" then begin Scenes.VictMAIn(Canvas); end else if Scene = "Text" then begin Scenes.Text(Canvas); end else if Scene = "Lift" then begin Scenes.Lift(Canvas); end else if Scene = "BB" then begin Scenes.BB(Canvas); end else if Scene = "Flat" then begin Scenes.Flat(Canvas); end else if Scene = "Diary" then begin Scenes.Diary(Canvas); end else if Scene = "Hangings" then begin Scenes.Hangings(Canvas); end else if Scene = "Work" then begin Scenes.Work(Canvas); end else if Scene = "Corridor" then begin Scenes.Corridor(Canvas); end else if Scene = "Bush" then begin Scenes.Bush(Canvas); end else if Scene = "Shop" then begin Scenes.Shop(Canvas); end else if Scene = "Street" then begin Scenes.Street(Canvas); end else if Scene = "HighParty" then begin Scenes.HighParty(Canvas); end else if Scene = "Capture" then begin Scenes.Capture(Canvas); end else if Scene = "MiniLuv" then begin Scenes.MiniLuv(Canvas); end else if Scene = "Room101" then begin Scenes.Room101(Canvas); end else if Scene = "Hung" then begin Scenes.Hung(Canvas); end else if Scene = "Shot" then begin Scenes.Shot(Canvas); end else if Scene = "WorkForever" then begin Scenes.WorkForever(Canvas); end else if Scene = "Tortured" then begin Scenes.Tortured(Canvas); end; end; procedure TCanvasProject.ApplicationClosing; begin GameView.EndSession; inherited; end; end.