Willicious
Members-
Content Count
144 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Willicious
-
Yes, good advice. I can play piano and guitar (both of which took years to learn and master), so - in theory - a bit of programming shouldn't be too far beyond me. I am learning well, but some things just don't have answers without already knowing the codebase you're working with. Starting from scratch is so tempting, but the project I'm working on is already huge, it would likely take way longer to start it from scratch than it would to wrestle with the few features I'm trying to reverse-implement.
-
Beginner to Delphi. Have no idea what I'm doing wrong here
Willicious posted a topic in Delphi IDE and APIs
Hi all, complete beginner to Delphi/Embarcadero here. I'm following this tutorial in an attempt to make a very basic movement-based game. I'm getting a bunch of errors, so I've dialled it back and I'm doing everything a step at a time and checking for errors. Can anyone see what's going wrong here? I've tried so many things to solve this error, but since the error message is extremely vague ("E2008 Incompatible types"), it makes troubleshooting very difficult. I've posted the entire code so far. The error is with the word "then" on the line if Key = 'w' then Movement := 'down'; unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls; type TForm1 = class(TForm) Shape1: TShape; KeyboardInput: TListBox; procedure FormCreate(Sender: TObject); procedure KeyboardInputKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); private { Private declarations } public { Public declarations } end; var Form1: TForm1; Movement: String; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin KeyboardInput.SetFocus(); end; procedure TForm1.KeyboardInputKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if Key = 'w' then Movement := 'down'; end; end. Incidentally, if anyone knows of any good online tutors for Delphi/Embarcadero (i.e. live tutoring, NOT video tutorials), I'm interested! Thanks, Will -
Beginner to Delphi. Have no idea what I'm doing wrong here
Willicious replied to Willicious's topic in Delphi IDE and APIs
Thanks for the advice. I'll take a look at these games -
@David Schwartz Thanks for your reply. I'd love to get into programming more and gain a better understanding of object-oriented. I've been thinking I probably need a tutor. My thinking tends to be more abstract/ideas-oriented than logic-oriented, and this trips me up a lot when it comes to programming. I know exactly what I want to happen, but the "how/why" of it holds me back. Very frustrating.
-
Undeclared identifier errors are something I could do with knowing how to deal with once and for all
Willicious posted a topic in Delphi IDE and APIs
I get undeclared identifiers almost every time I try to implement something in the project I'm working on. Here's an example: I'm trying to check the state of a condition called GameSpeed, which is defined in the unit GameWindow. In the unit LemGame, if I try to add "GameWindow" under "uses" at the top of the unit, I get a circular reference error. It's previously been explained to me that when this happens, I should list the unit under "implementation > uses" instead. Here's what I currently have (edited to fit it here😞 unit LemGame implementation uses GameWindow; procedure TGame.Start(aReplay: Boolean = False); begin if GameSpeed = gspRewind then begin GameSpeed := gspNormal; end; end; The idea is to return the game's speed to Normal forward-speed time when the Rewind speed has gone all the way to the start. TGame.Start is a procedure which deals with all conditions present at the start of the game, so this seems the best place to get it to check for the GameSpeed condition. However, GameSpeed gets an undeclared identifier error despite being present in the GameWindow unit. I've also tried changing it to TGameSpeed, but nothing doing. In GameWindow, GameSpeed is a property which is set in this way: function GetGameSpeed: TGameSpeed; property GameSpeed: TGameSpeed read GetGameSpeed write SetGameSpeed; function TGameWindow.GetGameSpeed: TGameSpeed; begin Result := fGameSpeed; end; Everywhere in GameWindow that I use "if GameSpeed = {whatever}", I get no errors. Do I therefore need to copy-paste all of the stuff regarding GameSpeed into the LemGame unit? Because I thought the point of being able to call on stuff from other units is that you don't have to redefine things again. Very confused. Maybe there is some information I haven't included here which might help to answer this. If so, I apologise in advance and I'll do my best to provide whatever is needed. The Rewind feature has been hanging around unfinished for weeks now because of problems like this. -
Undeclared identifier errors are something I could do with knowing how to deal with once and for all
Willicious replied to Willicious's topic in Delphi IDE and APIs
Thanks @PeterBelow for the explanation, I think I understand what I'm doing wrong here, your explanation has helped the penny to drop. This probably isn't the best way to achieve what I'm trying to do, since LemGame otherwise doesn't need to be aware of the existence (or not) of GameWindow. It seems a bit drastic to make big changes to the existing structure to achieve something relatively small. I'm re-focusing my efforts on the GameWindow unit. I need to find a way for the Rewind code itself to check for reaching the start of the level. But, I have tried several ways of doing this to no good result. I'll persevere with it, though; perhaps something useful will present itself if I keep looking. -
I'm currently working on a project which uses Un4seen's Bass.dll plugin. It's already installed, and at present just makes use of the basic plugin for playing audio files. Ideally, I'd like to use one of the add-ons (specifically, one which can pitch/tune the audio up or down during playback, such as Bass_FX). I wonder if anyone here has any experience working with Bass and its add-ons. I could do with some help getting started (specifically with the Bass_FX add-on); I've located the .pas file in the Bass_FX folder, but there doesn't seem to be a .dll anywhere. Also, once I've managed to get the add-on in the correct place, how do I call it for use?
-
Using Bass.dll and add-ons in a Delphi project
Willicious replied to Willicious's topic in General Help
Apparently, it's because I'm using it with the latest version of RAD. Chris over on the un4seen forums provided this zip which has the files correctly configured for 10.4. Tempo.7z Next, though, I have the task of trying to call bass_fx for use in my project, which I'm struggling to find any sort of step-by-step tutorial for. I can try to mimic what's happening in the Tempo project, but I'd mostly be guessing instead of knowing what I'm actually doing. New to this, but willing and able to learn quickly. -
Yes, this does remove the error, thanks 🙂 So, what exactly does override do? From what I understand, it applies changes to procedures/functions with the same name that also exist in another unit/class. If override is needed here, then how can I prevent the error in that case? Yes, I too found this Google result (as I stated in the OP). However, it doesn't resolve the issue because I haven't misspelled anything. Apologies if I seem to be asking basic questions, I'm very new to both Delphi and programming in general. Being able to ask you guys questions is very helpful, so thank you.
-
Using Bass.dll and add-ons in a Delphi project
Willicious replied to Willicious's topic in General Help
Managed to grab the bass.pas file from another project and placed it into the example project folder. This seemed to satisfy the error, but now the .exe generates this error message when running: All files associated with the example project are in the same folder, "...Delphi\Tempo": -
Using Bass.dll and add-ons in a Delphi project
Willicious replied to Willicious's topic in General Help
Hi @programmerdelphi2k, thanks for your reponse. I've downloaded the examples and I'm attempting to run them in RAD. I have both bass.dll and bass_fx.dll in the project example's folder (which, I assume, is where the .exe will be generated - I can't know this for sure because something is preventing me from getting that far). I get the following error, in spite of these files appearing in the project explorer window: -
Beginner to Delphi. Have no idea what I'm doing wrong here
Willicious replied to Willicious's topic in Delphi IDE and APIs
Thanks so much for your help so far, everyone! Apologies that these are such basic questions! 🤦♂️ -
Beginner to Delphi. Have no idea what I'm doing wrong here
Willicious replied to Willicious's topic in Delphi IDE and APIs
@Lajos JuhászHow would you specify a single line of keyboard input? if key = Ord('w') then ... isn't working for me OK, it works if you make the letter capital, so: if key = Ord('W') then -
Beginner to Delphi. Have no idea what I'm doing wrong here
Willicious replied to Willicious's topic in Delphi IDE and APIs
@GaryThanks for the suggestion, but tbh I'd like to try doing it as a Windows app. Later, I'll try again following the tutorial as you've suggested, for sure. For now though, the important thing is that I learn to bind keyboard input to movement. -
Beginner to Delphi. Have no idea what I'm doing wrong here
Willicious replied to Willicious's topic in Delphi IDE and APIs
Got rid of the TTimer altogether, to even further simplify what I'm trying to do. The square is not moving: type TForm1 = class(TForm) Square: TShape; procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); private { Private declarations } public { Public declarations } end; var Form1: TForm1; Movement: String; implementation {$R *.dfm} procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if Key = Ord('w') then Square.Top := Square.Top + 10; end; end. -
Beginner to Delphi. Have no idea what I'm doing wrong here
Willicious replied to Willicious's topic in Delphi IDE and APIs
Brilliant, thanks Lajos Juhász 👍 Unfortunately, it's not actually making the square move. Maybe I need to get rid of the TTimer...? -
Beginner to Delphi. Have no idea what I'm doing wrong here
Willicious replied to Willicious's topic in Delphi IDE and APIs
Thanks for the replies, everyone! gkobler's reply solved the error, but the keydown doesn't translate to movement. I've now removed the listbox and I'm applying KeyDown code directly to the form. The form now just has a square. I'm trying to make the square move downwards by 10px when 'd' is pressed: type TForm1 = class(TForm) Square: TShape; ActualMovement: TTimer; procedure ActualMovementTimer(Sender: TObject); procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); private { Private declarations } public { Public declarations } end; var Form1: TForm1; Movement: String; implementation {$R *.dfm} procedure TForm1.ActualMovementTimer(Sender: TObject); begin if Movement = 'Down' then Square.Top := + 10; end; procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if Key = Ord('w') then Movement := 'Down'; end; end. I figured that Square.Top would do this, but perhaps there is something incorrect about the line if Movement = 'Down' then Square.Top := +10;