Jump to content
IGNORED

Structured Code Question


JC Software

Recommended Posts

Hey guys back from the dead, but soon to be dead again. I won't be able to work on any bB or any 2600 games for that matter until summer begins. :P

On to the question: So lately Iv'e been learning about spaghetti code vs structured (or lasagna) code. Then I realized my bB games seem to follow a little bit of both formats.

I was wondering if spaghetti code is still as bad as a format for visual bB or if it's mostly for big programming projects made with C++ or Java.

 

I mean to be fair bB is more limited than any big programming language, so you should have to use lots of goto's and if statements right?

Link to comment
Share on other sites

I will add from my thread bogax quoted aprox 7 cycles for each if..then statement. So if you have 20 or so if..then statements in a row you can use a on..goto with 20 lables to make a select case style flow so it only needs to read which lable to goto then test the condition and do whatever then go straight out to the next section of the program.

 

For my zeldaesque game the program structure now flows like this:

-variables

-titlescreen (sub)

-gameover screen (sub)

-setup new game

-Mainloop

-check if playfield is cue to draw, if true skip next 4 sections

- player input

- enemy movement

- collision detections

- test if playfield updates (jump to draw players)

- draw playfield

- draw players

- update sound fx

-drawscreen

-goto Mainloop

- vblank (reflect players)

 

I'm sure other more experienced programmers have even more tricks to share ?

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...