Question about Objects

BlitzMax Forums/BlitzMax Beginners Area/Question about Objects

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

a couple things:

a) try declaring MyGun above the select. i think the not found error is caused by it being declared inside of the select

b) if i understand correctly, MyGun should probably be declared of type Firearm (or whatever both MP5 and UMP are based on) since both MP5 and UMP belong to type Firearm. unless MP5 is extended from UMP you shouldnt be able to store a UMP instance into an MP5 variable.

so the modifications would look like:

Local P1:Player = New Player;

Local UserSetup:Setup = New Setup;

Local Weap:String = UserSetup.getWeap();

Global MyGun:Firearm

Select Weap

Case "MP5" MyGun = New MP5;
Case "UMP" MyGun = New UMP;

EndSelect

Repeat
P1.Move();
MyGun.Update(P1.X, P1.Y);
Until KeyHit(KEY_ESCAPE)