How to code a radar

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by merendo.

I have a tilemap (32*24) and want to code a radar. I use the command startdrawing on the spriteouput(). Now, It looks like this:

Code: Select all

for x = 1 to 32for y = 1 to 24
  if map(x,y)=#gras
  ; Draw a gras-plot into the radarpicture...
next
next
But it doesn't work. It says something: Sprite-object not initalized.

Cu @ll, merendo
--
I've been hiding - What am I hiding from???
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Pupil.
Originally posted by merendo

I have a tilemap (32*24) and want to code a radar. I use the command startdrawing on the spriteouput(). Now, It looks like this:

Code: Select all

for x = 1 to 32for y = 1 to 24
  if map(x,y)=#gras
  ; Draw a gras-plot into the radarpicture...
next
next
But it doesn't work. It says something: Sprite-object not initalized.
You know you've provided the least interesting part of the drawing section.. It's not easy/possible to see what's wrong from this code. First of all have you created a sprite to draw to? Somewhere in you code you must have something like this:

Code: Select all

CreateSprite(#MY_MAPSPRITE, 32, 24)
 ...
StartDrawing(SpriteOutput(#MY_MAPSPRITE))
  for x = 1 to 32
    for y = 1 to 24
      If map(x,y)=#gras
        Plot(x,y, #GRAS_COLOR)
        ; Draw a gras-plot into the radarpicture...
      ...
      EndIf
    next
  next
 ...
StopDrawing()
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by merendo.

Ooops, sorry. Did I break your concentration?

Cu @ll, merendo
--
I've been hiding - What am I hiding from???
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Pupil.
Originally posted by merendo

Ooops, sorry. Did I break your concentration?
I do not know exactly how to interpret that sentence but anyhow -have you got your radar to work?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> > Ooops, sorry. Did I break your concentration?
>
> I do not know exactly how to interpret that sentence

I think Merendo's upset with you... that sentence is a quote from
"Pulp Fiction". Merendo, please don't take Pupil's initial reply
the wrong way... he's only trying to help.


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by merendo.

No, please, I'm just trying to be friendly to everybody. I know, not everybody in this forum likes me, but we should still help us. "Ooops sorry, did I break your concentration?" is the content of an mp3-file which I downloaded when I leeched FMOD, you know? The sound engine. I just wrote it because Pupil seemed a little angry and I wanted to avoid trouble. Sorry, no offence meant!

Cu @ll, merendo
--
I've been hiding - What am I hiding from???
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Pupil.
Originally posted by merendo

No, please, I'm just trying to be friendly to everybody. I know, not everybody in this forum likes me, but we should still help us. "Ooops sorry, did I break your concentration?" is the content of an mp3-file which I downloaded when I leeched FMOD, you know? The sound engine. I just wrote it because Pupil seemed a little angry and I wanted to avoid trouble. Sorry, no offence meant!
I wasn't angry, i was only trying to give you a hint about how hard it is to be able to give usefull help when the problem description is so vague, perhaps i was to blunt. To make matters worse, you and me not having English as our native language doesn't make things better. Missunderstandings is bound to happend under these circumstances...

PB was right, i thought you were upset with me, and no i didn't know, that's why i perhaps made a faulty interpretion of what you really meant with your previous post.

Well, with all this cleared up - have you've been able to make it work?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by merendo.

No! It still doesn't work, I will try to post a code:

For x = 0 To width-1
For y = 0 To height-1

DisplaySprite(editmap(x,y)\tile+45,x*93+scrollerx,y*47+scrollery)
If SpriteCollision(1,mx,my,editmap(x,y)\tile+45,x*93+scrollerx,y*47+scrollery) And mx < 600
editmap(x,y)\over = 1
overx = x+1
overy = y+1
Else
editmap(x,y)\over = 0
EndIf

If SpriteCollision(1,mx,my,editmap(x,y)\tile+45,x*93+scrollerx,y*47+scrollery)
If MouseButton(1) And mx < 600
editmap(x,y)\tile = currenttile-45
EndIf
EndIf

If editmap(x,y)\over
DisplaySprite(currenttile,x*93+scrollerx,y*47+scrollery)
EndIf

If radar
StartDrawing(SpriteOutput(#MY_RADARSPRITE))
DrawingMode(0)
If editmap(x,y)\tile = 0
Box((#RADARWIDTH*x)+3,(#RADARHEIGHT*y)+353,#RADARWIDTH,#RADARHEIGHT,65280)
EndIf
If editmap(x,y)\tile = 1
Box((#RADARWIDTH*x)+3,(#RADARHEIGHT*y)+353,#RADARWIDTH,#RADARHEIGHT,16776960)
EndIf
If editmap(x,y)\tile = 2
Box((#RADARWIDTH*x)+3,(#RADARHEIGHT*y)+353,#RADARWIDTH,#RADARHEIGHT,8454143)
EndIf
StopDrawing()
EndIf

Next
Next

Please say, If the description is still too vague.

Cu @ll, merendo
--
I've been hiding - What am I hiding from???
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> "Ooops sorry, did I break your concentration?" is the content of an
> mp3-file [...] I just wrote it because Pupil seemed a little angry
> and I wanted to avoid trouble. Sorry, no offence meant!

The quote in the movie is used in an "uncomfortable" way, which is why
I thought you were angry with Pupil -- I thought you were imitating
the actor who said it (Samuel L. Jackson). See here for details:

http://us.imdb.com/Quotes?0110912

:)


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Pupil.
Originally posted by merendo

No! It still doesn't work, I will try to post a code:
Ok, some small suggestions/comments on your code:
* I assume you have created the sprite #MY_MAPSPRITE prior to the loop you've provided, am i assuming correctly?
i.e you put some code like this near the begining(at least before the loop)

Code: Select all

#MY_RADARSPRITE = 200 ; The sprite number to use for radar sprite
 ...                  ; chose a value that suits your app.
CreateSprite(#MY_RADARSPRITE, #RADAR_SPRITEWIDTH, #RADAR_SPRITEHEIGHT)
 ...
* How big is your radar sprite, seems to be very big. Is it covering the whole screen? I thought you were doing the small kind that is located up in some corner, like in the Counter-Strike game.

* After the 'If radar ... EndIf' do you display the #MY_RADARSPRITE ?

Code: Select all

For x = ...

  For y = ...
    ...
    If radar
      ...
    EndIf
  Next
Next
DisplaySprite(#MY_RADARSPRITE, radar_xpos, radar_ypos)
 ...
* Is the loop a part of a bigger loop that starts with 'StartDrawing(ScreenOutput())' because it's probably not legal to have it like that i.e.

Code: Select all

; You shouldn't code this way!!!
StartDrawing(ScreenOutput())
  ... ; lots of stuff
  StartDrawing(SpriteOutput(#SOMESPRITE))
    ... ; even more stuff
  StopDrawing()
StopDrawing()
Please say, If the description is still too vague.
Well, it's better, but still it's hard to say what the problem is. If you want i could make a small program snipp that draws only the radar map.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by merendo.

My map has the size 32*24, but other sizes (64*48,80*60,102*76) are also available. For one tile (tiles have the size 93*47) I want a small block on the radar. I've uploaded a screenshot of the editor on my server (only for you :)) . Perhaps it can help you
Well, it's better, but still it's hard to say what the problem is. If you want i could make a small program snipp that draws only the radar map.
Well, sorry. But I was in big stress, when I made the posting above. But now I have all time of the day.

Cu @ll, merendo
--
I've been hiding - What am I hiding from???
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Pupil.

Ok nice :)
I'll send you a mail, are your registered mail address on this forum correct?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by merendo.

[url]mailto:mail@benedikt-franz.de[/url] or [url]mailto:webmaster@benedikt-franz.de[/url] or [url]mailto:benediktfranz@gmx.de[/url] ! It's your choice :wink:

Cu @ll, merendo
--
I've been hiding - What am I hiding from???
Post Reply