English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 28 February 2018, 00:53   #1
Marle
Pixel Vixen

 
Join Date: Feb 2018
Location: UK
Posts: 159
First Blitz code in nearly 20 years - any good?

Hi all,

I used to code a lot with Blitz Basic 2 on the Amiga in the mid to late 90s and loved it but have long since moved away from it and the Amiga.

A recent rekindling of my interest in old games made me think about possibly coding my own one, which may take years but no worries.

I have been using Ultimate Blitz Basic on an emulated Amiga on my Mac which seems to work fine although I still have an A600 in my loft but no easy way to readily connect it to my display.

My idea is to create a kind of puzzle / maze game but as a proof of concept I wrote the below code to see if I could code something that moved a character around the screen (which has multiple frames per movement), before moving on to some wider investigations.

All it does it put a character on a red screen. The character is not mine, SNES JRPG fans may recognise him I intend to draw my own in DPaint III in time.

My main questions are:
  • Any thoughts on the code? My day job is coding but for the web and not games at all, but I've tried to do this in the nicest way possible. There are no functions yet so purely linear.
  • How can I get the character to render more smoothly? I'm using an extended Vwait kludge which doesn't seem right. If I use just Vwait it runs too fast. Is this where double buffering comes in?
  • Does Blitz have a way to prematurely exit a loop without setting the iterator to its highest possible value? At the moment I can't see it does so in a loop such as For i=0 to 3 ... Next I am just setting i=3 when I want to exit the loop.

That'll do for now

Thanks!
Marle
Attached Files
File Type: txt Ark3.bb.txt (4.5 KB, 48 views)
File Type: zip Ark2.iff.zip (6.5 KB, 18 views)
Marle is offline  
Old 28 February 2018, 09:47   #2
Graham Humphrey
Moderator
Graham Humphrey's Avatar
 
Join Date: Jul 2004
Location: Norwich, Norfolk, UK
Age: 32
Posts: 11,047
Welcome aboard!

I haven't had any opportunity to look at or test your code yet but I think I can answer one of your questions...

Quote:
Originally Posted by Marle View Post
  • Does Blitz have a way to prematurely exit a loop without setting the iterator to its highest possible value? At the moment I can't see it does so in a loop such as For i=0 to 3 ... Next I am just setting i=3 when I want to exit the loop.
I think the Pop command does this, so using the line Pop For will exit the loop before it has completed.
Graham Humphrey is offline  
Old 28 February 2018, 13:05   #3
Marle
Pixel Vixen

 
Join Date: Feb 2018
Location: UK
Posts: 159
Quote:
Originally Posted by Graham Humphrey View Post
Welcome aboard!

I haven't had any opportunity to look at or test your code yet but I think I can answer one of your questions...
[/LIST]
I think the Pop command does this, so using the line Pop For will exit the loop before it has completed.
That's great thanks for the welcome! I shall look at the pop for command today and see what that has. I just wondered if I was missing something obvious.

One other question I have that I recall from my time of using BB2, was that you couldn't call a function (procedure? statement?) before it had appeared in the code, I remember this caused some problems sometimes, is this the case?

I doubt I'll encounter is now as I'm not going to code Workbench apps with serious amounts of user interface logic etc. But it's just popped back into my memory!

Thanks!
Marle
Marle is offline  
Old 01 March 2018, 14:32   #4
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 3,406
Welcome along! I haven't run your code but have had a quick read through it. First thoughts:

- The display library is more versatile than the slices library so I would recommend reading about that and using it instead.
- Generally it looks pretty good! The layout and comments give away the fact you've coded before

Now, to answer some questions:
- Yes, the Pop command is exactly what you're looking for, though it's not considered particularly great programming technique (from the same school as Goto and Gosub), so it would be preferable to work around it if possible. If needed though, Pop can get you out of any loop (For, While or Repeat), a Gosub, an If, or a Select (the Blitz equivalent of Switch).

- Yes, the procedure must be in your code before it is called for the first time. This is a limitation of the compiler, but in practice makes very little difference and shouldn't cause you any problems. Basically they're just all put at the top of your code and you're sorted. They're still called Procedures in Blitz in general, but are also called Statements and Functions, based on whether they give a return value or not.

- Without having run it, I'm not sure what the issue is with the character rendering. Does it flicker without the VWait 4? It sounds like it's just too slow to blit in a single frame if that's the case. If it doesn't flicker, but just animates or renders too quickly, you just need to remember that everything in Amigaland is timed to a frame, so for smooth animation you need to have 50 (or 60) frames per second. Double buffering won't help this, it just fixes flickering that happens when the rendering isn't finished before the next frame is due.

The ways around this are typically:
- Simply frameskip (using VWait as you're doing, or using the other frames to do other processing)
- Run at 50FPS and add more animation frames
- Run at 50FPS and only change the current animation frame every nth frame (I think a lot of games use this method)
- A combination of above (e.g., run at 25FPS and update the animation frame every 2 frames for a total of 8 FPS of animation)
Daedalus is offline  
Old 02 March 2018, 22:15   #5
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 3,665
Since all your questions have already been answered, let me just warn you that your A600 may be slowly deteriorating in your loft because the capacitors start to leak after 20 years. Send it to Daedalus and he will fix it for you.
idrougge is offline  
Old 05 March 2018, 22:52   #6
Marle
Pixel Vixen

 
Join Date: Feb 2018
Location: UK
Posts: 159
Quote:
Originally Posted by idrougge View Post
Since all your questions have already been answered, let me just warn you that your A600 may be slowly deteriorating in your loft because the capacitors start to leak after 20 years. Send it to Daedalus and he will fix it for you.
Eeek, it probably already is as I don't think it's been switched on for about 8 years now although it worked fine then. I had an Amiga 500+ that ate itself due to the battery backup clock leaking (that died in 2006).

I'll try to get it down this weekend and check it over (it's nothing special although it does have 2MB and Kickstart 3.1).
Marle is offline  
Old 05 March 2018, 22:53   #7
Marle
Pixel Vixen

 
Join Date: Feb 2018
Location: UK
Posts: 159
Quote:
Originally Posted by Daedalus View Post
- The display library is more versatile than the slices library so I would recommend reading about that and using it instead.
Thanks for your extensive reply. I have since read up on that. The manual I have here is for an older version of Blitz that didn't have the display library. There's a chance I have a copy of Ultimate Blitz 2.1 CD up in the loft as one of the few bits of Amiga stuff I kept hold of but I did eventually track down a PDF with the details in.

Quote:
Originally Posted by Daedalus View Post
- Generally it looks pretty good! The layout and comments give away the fact you've coded before
Given that I code pretty much every day, let's hope I'm up to snuff on that

Quote:
Originally Posted by Daedalus View Post
Now, to answer some questions:
- Yes, the Pop command is exactly what you're looking for,
That's great thanks, it's just on a rare occasion you find yourself in a loop that if it continues will 'overstep' the mark as it were.

Quote:
Originally Posted by Daedalus View Post
- Yes, the procedure must be in your code before it is called for the first time. This is a limitation of the compiler, but in practice makes very little difference and shouldn't cause you any problems.
Thanks, I did subsequently read just that. I just remember once instance way back when, when this caused me problems but I doubt I'll come across it these days.

Quote:
Originally Posted by Daedalus View Post
- Without having run it, I'm not sure what the issue is with the character rendering ...
I did manage to improve this in the end. Essentially the counter that steps through the character frames instead of incrementing in whole numbers I do it in fractions (+.25 on each loop) so in effect that has slowed down the sprite animation.

I will have to get somewhat more used to this kind of programming as pretty much everything I do these days is user interface related.

Thanks!
Marle is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Blitz Basic 2 source code Retro1234 Coders. Blitz Basic 8 25 May 2016 06:07
Somebody teach me to code in Blitz Basic, please!!! Toni Galvez Coders. Blitz Basic 18 21 May 2015 01:03
Source Code for finished games/demos in Blitz? diablothe2nd Coders. Blitz Basic 15 14 November 2012 23:04
BlitzOut - new Breakout game - need help with Blitz code Graham Humphrey Coders. General 29 27 June 2011 14:16
3D code and/or internet code for Blitz Basic 2.1 EdzUp Retrogaming General Discussion 0 10 February 2002 12:40

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 22:59.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.
Page generated in 0.06909 seconds with 16 queries