December 10, 2019, 06:23:59 AM

Author Topic: draw an image ?  (Read 1876 times)

Offline GaborD

  • Sr. Member
  • ****
  • Posts: 322
Re: draw an image ?
« Reply #45 on: May 19, 2019, 04:13:15 PM »
@drfloyd
Keep in mind Swap() will not auto draw anything, no 3D, no sprites, no print commands (text is also in Render2DFront(), just like sprites.)
Just adding this so you don't eventually wonder why your print commands suddenly don't work. :)

Just to clarify:
Sync() is a shortcut for
Update(), Render(), Swap()

Render() is a shortcut for
Render2DBack(), ClearDepthBuffer(), Render3D(), ClearDepthBuffer(), Render2DFront()
One step at a time, he's not got the hang of drawing sprites yet :P

:)
Yeah true ofcourse, but it's good to understand the basics right from the start when tinkering with the main rendering flow.
Otherwise he wouldn't know why his text is suddenly also gone.
This way it's clear that Swap() is just one standard part of Sync() and not some different magical command for sprites or such.
But I do get your point.

Offline drfloyd

  • Jr. Member
  • **
  • Posts: 35
Re: draw an image ?
« Reply #46 on: May 19, 2019, 05:03:14 PM »
I progress LOL

My code is about correct ? I have created function to remember classic basics…

The problem Indeed : text has desapear ! LOL
My god why text has disapear, this is Twilight zone ?????


Code: [Select]
SetVirtualResolution( 320, 240 )

////////////////////////////// DATA //////////////////////////
dim dessinperso[2]

//////////////// charger les images ////////////////////////////
dessincache=createsprite(loadimage("cache.png"))
for i=1 to 2
dessinperso[i]=createsprite(loadimage ("perso"+str(i)+".png"))
next


//////////////////////////// GAME ////////////////////////////
do

anim=anim+1:if anim=3 then anim=1

affimage(dessincache,0,0)

affimage(dessinperso[anim],50,50)

afftexte("GROUND",11,80,180)
afftexte("DAY",10,100,0)
afftexte("HELLO WORLD ! I AM A NEWBE IN PROGRAMMATION !!!!",8,0,200)

swap()
loop

////////////////// FUNCTIONS ///////////////////////////////
function afftexte(texte$,taille,tx,ty)
texte=createtext(texte$)
settextsize (texte,taille)
SetTextPosition(texte,tx,ty)
endfunction

function affimage(image,ix,iy)
setspriteposition(image,ix,iy)
drawsprite (image)
endfunction


Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 2220
Re: draw an image ?
« Reply #47 on: May 19, 2019, 07:43:57 PM »
text has desapear ! LOL
My god why text has disapear, this is Twilight zone ?????
This is all explained in the manual. I highly recommend you read it ;D

To magically make your text reappear when using virtual resolutions and the swap command :

Code: [Select]
SetVirtualResolution( 320, 240 )

Local myText As Integer
myText = CreateText( "SyntaxBomb is great..." )
SetTextPosition( myText, 100, 100 )

Do
DrawText( myText ) // <--- the magic bit

Swap()
Loop
Until the next time...

Offline drfloyd

  • Jr. Member
  • **
  • Posts: 35
Re: draw an image ?
« Reply #48 on: May 20, 2019, 07:19:45 AM »
Ok, I WILL READ THE DOCUMENTATION...

Is it a real strange language, with strange features... nothing to do with Dark Basic/Blitz 3D/SDL Basic... where you can code without any help after 5 minutes.

I understand it is an advanced & powerfull language, not a classic basic, but I am surprise that TGC do not also create a real update for DARK BASIC with classic commands/functions. AGK is not the philosophy of TGC in my opinion.

Thank you anyway for all your replies. You are all very patient with newbies LOL
It 's time for me the read the doc, and if I am bored I will come back to my past languages, BLITZ or DARK BASIC

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 2220
Re: draw an image ?
« Reply #49 on: May 20, 2019, 01:40:51 PM »
Quote
Ok, I WILL READ THE DOCUMENTATION...
We have a winner \o/ ;D

Quote
Is it a real strange language, with strange features... nothing to do with Dark Basic/Blitz 3D/SDL Basic... where you can code without any help after 5 minutes.
I think it's very simple.

Just think of Sync() as doing all the draw commands for your whereas Swap() gives you more control which means you have to draw what you want on screen ( with various draw commands like DrawSprite, DrawText and sometimes use the various Render commands ).

The easiest is Sync() but you have to hide everything you don't want shown on screen. Personally I prefer the Swap() method as it gives greater control and doesn't require me to hide 100's of tiles for example.

Quote
Thank you anyway for all your replies. You are all very patient with newbies LOL
We're a bunch of old grumpy coders but happy to help with a touch of sarcasm thrown in ;D
Until the next time...

Offline Steve Elliott

  • Hero Member
  • *****
  • Posts: 2118
  • elgol developer
Re: draw an image ?
« Reply #50 on: May 20, 2019, 11:03:57 PM »
Quote
I think it's very simple.

Just think of Sync() as doing all the draw commands for your whereas Swap() gives you more control which means you have to draw what you want on screen ( with various draw commands like DrawSprite, DrawText and sometimes use the various Render commands ).

The easiest is Sync() but you have to hide everything you don't want shown on screen. Personally I prefer the Swap() method as it gives greater control and doesn't require me to hide 100's of tiles for example.

To be honest I didn't know about Swap() I've been hiding Sprites and using Sync() because that's what the example code that I've seen shows.  Yes AGK is simple and very nice to use, but they do tend to add and add without a logical one way of doing things - there's always several ways to accomplish something, which is just chaos in my book.
Windows 10, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
MacOS Mojave, 64-bit, 8Gb RAM, CPU Intel i5, 2.3 Ghz, Intel Iris Plus Graphics 640 1536 MB.
Linux Mint 19.2, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
Raspberry pi4 4Gb RAM

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 2220
Re: draw an image ?
« Reply #51 on: May 20, 2019, 11:48:58 PM »
Quote
there's always several ways to accomplish something, which is just chaos in my book.
Probably because they wanted to cater for those who want the quickest method, Sync() and those who want more control, Swap(). Swap also allows you to later up 2D on 3D or 2D under 3D. Also if you don't use SetVirtualResolution then all sprite positions are percentage based whereas if you do use that command then you can use screen positions + all the black bars are done for you in different resolutions.
Until the next time...

Offline Steve Elliott

  • Hero Member
  • *****
  • Posts: 2118
  • elgol developer
Re: draw an image ?
« Reply #52 on: May 21, 2019, 12:12:08 AM »
Nah, sounds like a shit idea lol.  I've always been of the mindset that there is always one best way to do things.  C++ is terrible for that, there are soo many ways to code a solution and AGK is again muddying the waters.  It seems I'm not alone in this philosophy of one best way to accomplish a task, it's Python's philosophy too so I hear.  I should learn Python properly some day.
Windows 10, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
MacOS Mojave, 64-bit, 8Gb RAM, CPU Intel i5, 2.3 Ghz, Intel Iris Plus Graphics 640 1536 MB.
Linux Mint 19.2, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
Raspberry pi4 4Gb RAM

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 2220
Re: draw an image ?
« Reply #53 on: May 21, 2019, 04:31:21 AM »
Quote
Nah, sounds like a shit idea lol.  I've always been of the mindset that there is always one best way to do things.
Some people love the percentage system and some love the screen coordinates system. Having both doesn't impact on the other and gives the coder the method they want to use. Had AGK forced the Sync() and percentage system on me I wouldn't be using it. I couldn't stomach having to hide every sprite not in use, let alone positioning sprites percentage based :o - Such a scenario doesn't warrant the one way only approach especially as the Swap() method allow for more draw control where needed.

Quote
It seems I'm not alone in this philosophy of one best way to accomplish a task, it's Python's philosophy too so I hear.
What about composing music? tracker, piano roll or sheet music? :P - Options are best but I get where you are coming from in regards to coding and being able to do the exact same task in multiple ways which can be very confusing.

Quote
I should learn Python properly some day
I think you should be getting on with something else. I want to play ;D
Until the next time...

Offline Steve Elliott

  • Hero Member
  • *****
  • Posts: 2118
  • elgol developer
Re: draw an image ?
« Reply #54 on: May 21, 2019, 12:03:52 PM »
Quote
Having both doesn't impact on the other

Yes it does because it confuses people coming to AGK. Just use one good system!

Quote
Had AGK forced the Sync() and percentage system on me I wouldn't be using it. I couldn't stomach having to hide every sprite not in use, let alone positioning sprites percentage based :o

That's just what I'm saying - it's a bad idea so why offer it too?  A DrawSprite system at screen coordinates is far more intuitive than having to hide perhaps hundreds of sprites then work off a percentage system.

Quote
What about composing music?

Media is totally different to a muddled programming language structure as here.

Quote
I think you should be getting on with something else. I want to play ;D

True lol.


 
Windows 10, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
MacOS Mojave, 64-bit, 8Gb RAM, CPU Intel i5, 2.3 Ghz, Intel Iris Plus Graphics 640 1536 MB.
Linux Mint 19.2, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
Raspberry pi4 4Gb RAM