Linked List Help Please

Advanced game related topics
SoulReaper
Enthusiast
Enthusiast
Posts: 372
Joined: Sun Apr 03, 2005 2:14 am
Location: England

Linked List Help Please

Post by SoulReaper »

Hello There :)

I seem to have had a little problem and was wondering is there a very kind person out there that could tell me where I am going wrong the code below use to work on 3.94 but its no go on v4.00

I have looked but I just cant see where the problem is...

Thankyou in advance :wink:
Kevin

Code: Select all


Structure enemy    
  x.f
  y.f
  SpeedX.f
  SpeedY.f
  InertiaX.f
  InertiaY.f
  MaxInertiaX.f
  MaxInertiaY.f
  InertialVelocityX.f
  InertialVelocityY.f
  Armor.b

; needed to let alien be created offscreen without dying
    OnScreen.b

; needed for pattern control on each alien
    Pattern_Number.b
    Pattern_Offset.w
    pattern_counter.w

EndStructure 
NewList Enemy.enemy()


Procedure AddEnemy(x, y, SpeedX, SpeedY, Armor)
  AddElement(Enemy())  ; Not a function, array or linked list em.....
  Enemy()\x = x
  Enemy()\y = y
  Enemy()\SpeedX = SpeedX
  Enemy()\SpeedY = SpeedY
  Enemy()\Armor = Armor 
EndProcedure

P.S. I am not to great with Link Lists LOL :oops: :lol: :wink:
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Global NewList Enemy.enemy()

3.9x linklists and arrays were all global but in v4 their scope is treated as any other variable - you must specify the scope.

Another approach you can use in v4 is to pass the linklist as parameter to the procedure if you don't want to make it global. Lots more options with this new version!
BERESHEIT
SoulReaper
Enthusiast
Enthusiast
Posts: 372
Joined: Sun Apr 03, 2005 2:14 am
Location: England

Post by SoulReaper »

Thankyou for your quick reply :)

I am getting there with pure basic version 4 :wink: There is just soo much to learn :shock: :lol: :twisted: :wink:

Best Regards
Kevin :wink:
Post Reply