Jump to content
IGNORED

Line Draw


lwdallas

Recommended Posts

Dear GOD, how does one draw a line in JagStudio??

 

I am new to this and a decent structured language/oop programmer. I have read a lot of dtuff but I haven't found my answer. Is there a Raptor call to draw a line?

Link to comment
Share on other sites

No there isn't. Depending on what the line is for (eg, if speed is critical), then you really have 3 main options.

 

1. Use jsfPlot to draw pixels and create your own lines (slow). Note: this draws to the partial/text object later that's included by default in all projects.

2. Use the poke functions to draw pixels over any sprite object and create your own lines (slow).

3. Use the blitter (faster). See the blitline example which currently only draws horizontal lines. You'll need to read up on the blitter elsewhere to learn how to draw vertical/angled lines. This is something I'll add as a further example project one day. 

 

If you are just starting out with JagStudio then you might be better starting with something more sprite driven, instead of manually  drawing stuff.

 

  • Like 1
Link to comment
Share on other sites

@Sporadic, thank you for your reply!

 

I didn't know about jsfPlot so this is helpful. I only need simple line ATM.

 

I have been reading up on the blitter--ick. I want to eventually know more about this as I would eventually like to draw polygons.

  • Like 1
Link to comment
Share on other sites

For completeness, this is my jsfPlot solution so if anyone ever needs to know what this is not the solution... :)

It is sloooooow, but it will work for my interactive game map.


 

SUB DrawLine(x0%, y0%, x1%, y1%, Colour%)
' -----------------------------------------------------------------------
'DrawLine
' Bresenham's Algorithm (MIT)
' INPUTS
' x0%, y0% - starting point
' x1%, y1% - ending point
' Colour%  - color to draw with (0-15)
' -----------------------------------------------------------------------
    DIM dx#
    DIM dy#
    DIM sx%
    DIM sy%
    DIM err%
    DIM e2%
    DIM x%
    DIM y%
    
    
    dx = ABS( x1 - x0 )  
    dy = -ABS( y1 - y0 )
    
    if x0 < x1 THEN
        sx = 1
    ELSE    
        sx = -1
    ENDIF
    
    if y0 < y1 THEN
        sy = 1
    ELSE    
        sy = -1
    ENDIF
    
    err = dx + dy
    
    x=x0
    y=y0  
    DO
        PutPixel(x,y,Colour)  
        IF x = x1 AND y = y1 THEN
            EXIT
        ENDIF

        e2 = 2 * err

        IF e2 >= dy THEN
            err += dy
            x += sx
        ENDIF

        IF e2 <= dx THEN
            err += dx
            y += sy
        ENDIF
    LOOP
    
    
END SUB

SUB PutPixel ( x0%, y0%, Colour%)
rapLocate 10,88
Print "PutPixel( ", ", x0%:", x0, "y0%:", y0, "Colour%:", Colour, ")"
    jsfColour Colour
    jsfPlot( x0, y0 )
END SUB


 

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

  • 2 weeks later...
20 hours ago, lwdallas said:

After JagJam I want to get into it whatever it is!

Is there a tutorial for idiot beginners(like me)?

I've been trying to pick through the examples in the JagStudio files trying to learn and understand...slowly.

  • Like 1
Link to comment
Share on other sites

Without sounding rude, if this is for the JagJam, they've made it pretty clear they don't want myself or Rik involved, but are happy to tell people to run off and use JagStudio (while promoting themselves and their socials)... so, I'd suggest, maybe, asking them who is providing support for people entering... time is limited.

Helping people is fine in general
. Helping people in order to promote something for someone else, when they have made it clear they don't want the folks behind the very thing they require to be used to be not involved, is a whole other thing. If you want to make something not for JagJam, then by all means, ask away, but Rik and myself are not their IT support.

 

Organic user growth is great. Accelerated user growth is great when we're ready to be part of it or consulted. Accelerated user growth with benefit to only external parties without even being consulted... that... just isn't on IMHO.

 

  • Like 4
  • Confused 1
  • Sad 1
Link to comment
Share on other sites

11 hours ago, LordKraken said:

I really enjoy that tutorial! However, I was looking for a tutorial to concentrate on getting up to speed on the assembler side. My assembler time comes from System 370, forty years ago.. I have never written 68k or JRISC assembler.

  • Like 1
Link to comment
Share on other sites

BJL is by no means as evolved as JS, but it is assembly only. Most stuff in BJL and JaguarDemos should just compile and run, so you have examples to start from.

And, I am not related to JagJam, so I am allowed to help.

  • Like 1
Link to comment
Share on other sites

12 hours ago, CyranoJ said:

Without sounding rude, if this is for the JagJam, they've made it pretty clear they don't want myself or Rik involved, but are happy to tell people to run off and use JagStudio (while promoting themselves and their socials)...

I wasn't aware of that. If the whole thing is not just a misunderstanding, that's very unfortunate (and I don't really see a reasonable explanation for it).

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...
11 hours ago, Syntax Error said:

is there no way to #include .asm somehow in one of the files so it can be used as a userfunction ? (plz not to flame the noob here lol, just asking)

no way.

  • Sad 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...