How do you make the Images bigger?

Previous topic - Next topic

Hotshot

I want to make the image bigger but questions is which commands make the image go bigger?

mentalthink

You can make in some ways.

rotozoomsprite my_Image, pos_X, pos_Y, angle, and the zoom factor  //Be carfully, 1.0 it´s the same size, but 10 not it´s 10 times, it´s very vey huge image, values <1.0 are for minimize, and when the value it´s <0.0 then the image flips.

Another way use polyvectors, (i don´t put the code, it´s a bit large), this method i´sabit more faster than drawsprite and the other commands for draw images
This nice whit polysprites, you can rotate, scale, distor the image and change colors in each vertex, and you can repeat a lot of time the image into the rectangle made whit polyvector.

You can see in the help, a simple mode for use it.

Another way in 3D, it´s use X_Sprite, this it´s only in 3D mode, and take a look to the lib of kanonet... have a very cool X_Sprite, do it for he.

Hotshot

#2
Thanks:)

I am using 2D Sprites and hoping to create Basic 2D Shoot em up :)

Here the picture


Ian Price

Xevious is a pretty good game to help with learn the ropes of GLB.

:)
I came. I saw. I played.

Hotshot

#4
I am trying do Background scrolling of going up and I have create Global Move

Code (glbasic) Select

FUNCTION SHOW_BACKGROUND:

        DRAWSPRITE BACKGROUND, 0, -5700+Move
        Move=Move-1

ENDFUNCTION


I just dont know why it got error when it say variable is not explicitly defined : Move as I guess I have to Declare Variable before I used it.......right?

Another things I have notice that GLBASIC only accept   JPG, BMP but not PNG......By the way....I am using free version and just let you know :)

Code (glbasic) Select

GLOBAL BACKGROUND=0
GLOBAL Move AS INTEGER


LOADSPRITE "BACKGROUND2.JPG", BACKGROUND

SHOW_BACKGROUND()

SHOWSCREEN
MOUSEWAIT
END


FUNCTION SHOW_BACKGROUND:

        DRAWSPRITE BACKGROUND, 0, -5700+Move
        Move=Move-1

ENDFUNCTION




Poetronic

#5
Hi Hotshot,

GLBasic definitely supports png-files and transparency. I am making heavy use of them in my current project.

Concerning your questions:

Code (glbasic) Select
GLOBAL Move AS INTEGER

should be

Code (glbasic) Select
GLOBAL Move%

% means INTEGER, # means FLOAT, $ means STRING.

INTEGER can be used to convert floats into integers. You do it like this:

Code (glbasic) Select
INTEGER(float#)

As for the background image, try doing it like this:

Code (glbasic) Select
LOADSPRITE "yourimage.jpg", 0 // 0 instead of variable "yourimage"

This loads your image with ID 0. Use 1,2,3,4 etc. for more images. Then draw the sprite like this:

Code (glbasic) Select
DRAWSPRITE 0, x%, y% // Draws the sprite with the ID 0 at the coordinates x, y

You can also stretch, rotate, and/or zoom your sprite:

Code (glbasic) Select
STRETCHSPRITE num%, x%, y%, width%, height%
ROTOSPRITE num%, x%, y%, phi#
ROTOZOOMSPRITE num%, x%, y%, phi#, rel#
ZOOMSPRITE num%, x%, y%, relx#, rely#


I would also recommend two things for your project.

1. Try using a tile map with small images instead of one large image for the level background graphics.
2. Try coding your game so that it runs with the same speed on different computers (search for "deltatime" in this forum).

Cheers,
P.
ILI-Blocks, my first game ever - please check it out! http://www.glbasic.com/forum/index.php?topic=8654.0

Hotshot

Thanks man :)

Quote
Try using a tile map with small images instead of one large image for the level background graphics.

That take lots of work to do as I only used it for learning project

I am wondering why my background doesnt scroll up.....

Code (glbasic) Select

GLOBAL BACKGROUND=0
GLOBAL Move%


LOADSPRITE "BACKGROUND2.JPG", BACKGROUND

WHILE NOT TRUE

       SHOW_BACKGROUND()
       SHOWSCREEN

WEND

END

FUNCTION SHOW_BACKGROUND:

        DRAWSPRITE BACKGROUND, 0, -5700+Move
        Move=Move+1

ENDFUNCTION


deltatime? Yes, I will be using that when I got my learning project up, when it is ready and I will be using it :)



Poetronic

#7
This works, just try to replace the values with your own:

Code (glbasic) Select
GLOBAL Move%

SETSCREEN 640,480,0

REPEAT

     SHOW_BACKGROUND()
       
     SHOWSCREEN

UNTIL KEY(01) = 1 // ESC

END

FUNCTION SHOW_BACKGROUND:

     DRAWRECT 100, Move, 10, 10, RGB(255,255,255) // Replace with your image
       
     INC Move, 1 // This is the shorter version of Move = Move + 1; when using long veriable names this is much more handy

     IF Move > 480 THEN Move = 0

ENDFUNCTION


And tile maps are not such a great amount of work. Try using the DATA structure pointing to the specific tiles. Sounds complicated, but in fact it is rather simple. I don't have much time right now, but if you want to, I could try to explain it to you tomorrow or the day after :)

Cheers,
P.
ILI-Blocks, my first game ever - please check it out! http://www.glbasic.com/forum/index.php?topic=8654.0

Hotshot

#8
Thanks :)

Now I got Scrolling Background that go up! Nice one :)

Inc Move,1

That look like Assembler code doesnt it  LOL

Quote
And tile maps are not such a great amount of work. Try using the DATA structure pointing to the specific tiles. Sounds complicated, but in fact it is rather simple. I don't have much time right now, but if you want to, I could try to explain it to you tomorrow or the day afte

I did love know about that but no rush :)

Next step is put Spaceship in there and move about :)



Going to learn on Control the Spaceship and also Playing area to stop from Spaceship going off the screen :)

Hotshot

#9
I have managed control the spaceship and also got playing area working but one things bugged me is that Spaceship get stuck on the bottom.....

Code (glbasic) Select

FUNCTION Show_Spaceship:

        DRAWSPRITE SpaceShip,250+MX,50+MY
       
        IF KEY(203) THEN DEC MX,SPEED     // LEFT
       
        IF KEY(205) THEN INC MX,SPEED     // Right
       
        IF KEY(200) THEN DEC MY,SPEED     // UP
       
        IF KEY(208) THEN INC MY,SPEED    // DOWN
       
        // STOP SPACESHIP GOING OFF THE SCREEN
        IF MX<-250   THEN MX=-250
        IF MX>350    THEN MX=350
       
        IF MY<215  THEN MY=215  // STOP SPACESHIP GOING OFF THE SCREEN AT THE BOTTOM   ------ PROBLEM !!!
       
ENDFUNCTION



What I am trying to do is Stop Spaceship going off the bottom where everythings is working apart from one things :)


UPDATED - I Got it working :)   The Correct Code is  IF MY>215  THEN MY=215  // STOP SPACESHIP GOING OFF THE SCREEN AT THE BOTTOM :D

My Next Step is get Spaceship Shooting  =D

bigsofty

Oooh Xevious, nice shmup choice!  :good:
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Hotshot

I am learning how to used Shooting by learning this tutorials Video   http://www.glbasic.com/forum/index.php?topic=935.0   

Excellent  =D