English Amiga Board


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

 
 
Thread Tools
Old 02 October 2017, 00:45   #1
gazj82
Registered User
 
gazj82's Avatar
 
Join Date: Jan 2014
Location: Cambs / UK
Posts: 356
Blitz: Any idea why sprites won't work

Hi Guys,

Any idea why sprites won't work in this code? When compiling I get "No currently used object!"

Code:
getashape 24,0,97,16,16
getasprite 0,24

;further on in code;
:laserpos
if laser = 1
showsprite 0,1,plyy,0
showsprite 0,304,plyy,1
endif
return
gazj82 is offline  
Old 02 October 2017, 00:58   #2
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
To use ShowSprite, you have to have a currently active slice. How have you set up the slices? You also need to switch to Blitz mode (shuts down the OS like most older games) before displaying any slices or sprites.
Daedalus is offline  
Old 02 October 2017, 01:02   #3
gazj82
Registered User
 
gazj82's Avatar
 
Join Date: Jan 2014
Location: Cambs / UK
Posts: 356
Quote:
Originally Posted by Daedalus View Post
To use ShowSprite, you have to have a currently active slice. How have you set up the slices? You also need to switch to Blitz mode (shuts down the OS like most older games) before displaying any slices or sprites.
Well I can't seem to get the raw text to display properly on notepad++ or gvim so I have put an adf in the zone with the source code and other files on. Sorry I can't give it to you any more convineient than that. Thr file is called "bees.adf"
gazj82 is offline  
Old 02 October 2017, 01:14   #4
gazj82
Registered User
 
gazj82's Avatar
 
Join Date: Jan 2014
Location: Cambs / UK
Posts: 356
I am sure you are right by the way Daedalus! It most likely has something to do with my screen setup. As I really just thumbled my way through it and kept changing numbers until it worked. I kinda got what it all meant (well mostly) by the end.
gazj82 is offline  
Old 02 October 2017, 01:20   #5
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Ah, okay. It looks like you're using the Display Library for your display (which is good - it's more powerful than the Slices library), but you're using the Slices library sprite commands (ShowSprite). Change them to DisplaySprite instead and it should hopefully work.

The two libraries have similar functions but aren't compatible with each other, so you have DisplayBitmap and DisplaySprite instead of ShowBitmap and ShowSprite. DisplaySprite takes an extra parameter at the start that tells it which CopList to use, just be aware of that.

Other than that, a couple of tips:

When creating program labels, start them with a full stop, not a colon. For example:
Code:
.MyLabel:
instead of
Code:
:MyLabel
This will add them to the list of labels on the right of the editor, allowing you to click them to jump around your code. Also, you don't need the colon on the end unless you're using a really old editor, so simply .MyLabel will do.

Next, you can save your source as text from the SuperTED editor using the Save as ASCII... option. This will be readable in WordPad, Notepad++ or any other editor (not Windows Notepad - it doesn't understand Amiga line breaks).

Finally, it's not essential but something to consider: creating a custom datatype for common properties will make your code more readable and less prone to bugs later on. Instead of having separate arrays for position, health etc., you can have them in one array of a Newtype. For example:
Code:
Dim human.player(5)
...
human(i)\x, human(i)\y
instead of
Code:
Dim humanx.w(5), humany.w(5)
...
humanx(i), humany(i)
See here for more details on Newtypes.
Daedalus is offline  
Old 02 October 2017, 01:37   #6
gazj82
Registered User
 
gazj82's Avatar
 
Join Date: Jan 2014
Location: Cambs / UK
Posts: 356
This is great and makes sense. I am going to bed now so I will try it after work tomorrow. Thank you for all your help and the great tips. I am currently using the editor that comes with blitz2 (ped is it?). As far as i know superted comes with amiblitz. Are you saying I can use that editor and still compile blitz (i.e non fpu) code?

My Amiga has no fpu by the way I guess SuperTed itself does not require me to have one.

The label thing is a huge tip. Thanks

Not sure I quite get the variable thing yet but I will play with this tomorrow too.

Thanks again for all your help.
gazj82 is offline  
Old 02 October 2017, 02:46   #7
Shatterhand
Warhasneverbeensomuchfun
 
Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 41
Posts: 3,450
Quote:
Originally Posted by gazj82 View Post
This is great and makes sense. I am going to bed now so I will try it after work tomorrow. Thank you for all your help and the great tips. I am currently using the editor that comes with blitz2 (ped is it?). As far as i know superted comes with amiblitz. Are you saying I can use that editor and still compile blitz (i.e non fpu) code?

My Amiga has no fpu by the way I guess SuperTed itself does not require me to have one.

The label thing is a huge tip. Thanks

Not sure I quite get the variable thing yet but I will play with this tomorrow too.

Thanks again for all your help.
I code using Notepad++, test with Amiblitz2 on Winuae, Create executable with Blitz 2 on my A600.

Everything works pretty well this way You just have to be careful to not save anything on Amiblitz on Winuae when testing code, just use Notepad++ to save stuff
Shatterhand is offline  
Old 02 October 2017, 07:35   #8
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,516
Quote:
Originally Posted by Shatterhand View Post
I code using Notepad++, test with Amiblitz2 on Winuae, Create executable with Blitz 2 on my A600.

Everything works pretty well this way You just have to be careful to not save anything on Amiblitz on Winuae when testing code, just use Notepad++ to save stuff
[OT]I know that earok did show that configuration but i still cannot figure out how to do it
saimon69 is offline  
Old 02 October 2017, 09:18   #9
MickGyver
Registered User
 
MickGyver's Avatar
 
Join Date: Oct 2008
Location: Finland
Posts: 643
Quote:
Originally Posted by saimon69 View Post
[OT]I know that earok did show that configuration but i still cannot figure out how to do it
I have made a tutorial for this kind of workflow (syntax highlighting for NP++ and tools). Works pretty well once it's set up: http://eab.abime.net/showthread.php?t=86316
MickGyver is offline  
Old 02 October 2017, 10:21   #10
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Quote:
Originally Posted by gazj82 View Post
I am currently using the editor that comes with blitz2 (ped is it?). As far as i know superted comes with amiblitz. Are you saying I can use that editor and still compile blitz (i.e non fpu) code?
Nope, you've got it the wrong way around. Ted is the original editor (with the ugly menus and funky file requesters), and is made to run on a 1MB 1.3 machine. If you've got anything better than that, SuperTed is far superior. It's actually part of the original Blitz 2.1 setup, on the Extras disk, but there are newer versions available too. While you're at it, there's also an updated deflibs and debugger, both of which are much better than the basic default versions.

The editor for AmiBlitz is called Ped, and AFAIK requires an FPU to run, so don't worry about that one.

Search for the Blitz Support Suite, on blitz-2000.co.uk (it's blocked in work here so I can't get an exact link). It includes an updated SuperTed, as well as updated deflibs and debugger files, all newer versions than the ones on the Blitz Extras disk.

Quote:
Not sure I quite get the variable thing yet but I will play with this tomorrow too.
Yeah, using Newtypes is a tricky concept to quickly explain when you're coming from 8-bit BASICs, but it's essentially the same as a Struct in C, and is a standard part of all "modern" languages. Not essential, but as you go on to develop more complex programs you'll see its value

Quote:
Thanks again for all your help.
No bother!
Daedalus is offline  
Old 06 October 2017, 14:56   #11
gazj82
Registered User
 
gazj82's Avatar
 
Join Date: Jan 2014
Location: Cambs / UK
Posts: 356
Thanks everyone for all your help so far. I am learning lots.

DisplaySprite is working great. One question tho. Is there away to turn the spriite off. i.e "DontDisplaySprite" type command. At the moment I am masking the sprite with a blank image when I am finished with it. Which kinda works but creates more problems down the line.

I have look up BlitzMode at amigacoding.com but can't see any such command.

Thanks
gazj82 is offline  
Old 06 October 2017, 18:04   #12
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Hmmm... That is a slightly tricky one. AFAIK the "proper" way of disarming a sprite is to write 0 to the relevant sprite control register, referred to as SPR0CTL - SPR7CTL for channels 0 to 7 respectively (bear in mind they're 16-bit registers). However, I have never bothered doing this myself, either using a very simple single-pixel shape with no pixels as the sprite imagery when it's not needed, or else moving it to a negative X position, which puts it beyond the border of the screen and is thus invisible.
Daedalus is offline  
Old 06 October 2017, 21:23   #13
gazj82
Registered User
 
gazj82's Avatar
 
Join Date: Jan 2014
Location: Cambs / UK
Posts: 356
Well moving it off the screen works much better than masking it out. Out of sight out of mind!

Thanks
gazj82 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
How did Amiga sprites work? Foebane Retrogaming General Discussion 13 29 May 2017 16:41
SimpleFTP won't work jdog320 support.WinUAE 9 12 January 2016 21:38
Pegasus won't work Tim Janssen support.WinUAE 7 13 May 2004 09:39
miami won`t work jambamiga support.WinUAE 4 01 November 2002 03:53
HD emulation won't work Grimlock126 support.WinUAE 7 06 July 2001 19:11

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 12:29.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.12265 seconds with 15 queries