draw an image ?

Started by drfloyd, May 10, 2019, 16:49:41

Previous topic - Next topic

GaborD

#45
Quote from: Qube on May 19, 2019, 16:07:39
Quote from: GaborD on May 19, 2019, 15:59:52
@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.

drfloyd

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 ?????



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


Qube

Quote from: drfloyd on May 19, 2019, 17:03:14
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 :


SetVirtualResolution( 320, 240 )

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

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

Swap()
Loop

Mac Studio M1 Max ( 10 core CPU - 24 core GPU ), 32GB LPDDR5, 512GB SSD,
Beelink SER7 Mini Gaming PC, Ryzen 7 7840HS 8-Core 16-Thread 5.1GHz Processor, 32G DDR5 RAM 1T PCIe 4.0 SSD
MSI MEG 342C 34" QD-OLED Monitor

Until the next time.

drfloyd

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

Qube

#49
QuoteOk, I WILL READ THE DOCUMENTATION...
We have a winner \o/ ;D

QuoteIs 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.

QuoteThank 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
Mac Studio M1 Max ( 10 core CPU - 24 core GPU ), 32GB LPDDR5, 512GB SSD,
Beelink SER7 Mini Gaming PC, Ryzen 7 7840HS 8-Core 16-Thread 5.1GHz Processor, 32G DDR5 RAM 1T PCIe 4.0 SSD
MSI MEG 342C 34" QD-OLED Monitor

Until the next time.

Steve Elliott

#50
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.
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

Qube

Quotethere'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.
Mac Studio M1 Max ( 10 core CPU - 24 core GPU ), 32GB LPDDR5, 512GB SSD,
Beelink SER7 Mini Gaming PC, Ryzen 7 7840HS 8-Core 16-Thread 5.1GHz Processor, 32G DDR5 RAM 1T PCIe 4.0 SSD
MSI MEG 342C 34" QD-OLED Monitor

Until the next time.

Steve Elliott

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.
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

Qube

QuoteNah, 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.

QuoteIt 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.

QuoteI should learn Python properly some day
I think you should be getting on with something else. I want to play ;D
Mac Studio M1 Max ( 10 core CPU - 24 core GPU ), 32GB LPDDR5, 512GB SSD,
Beelink SER7 Mini Gaming PC, Ryzen 7 7840HS 8-Core 16-Thread 5.1GHz Processor, 32G DDR5 RAM 1T PCIe 4.0 SSD
MSI MEG 342C 34" QD-OLED Monitor

Until the next time.

Steve Elliott

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.


Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb