Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Sprite stretching on y axis for unknown reasons

Author
Message
KristianXD1
7
Years of Service
User Offline
Joined: 15th Jul 2016
Location:
Posted: 15th Jul 2016 05:17 Edited at: 15th Jul 2016 16:01
this is my first time using agk to build a game,
during an attempt to build a tilemap system i've run across a weird stretching of any tile i place.
the tiles are 16 by 16 pixels originally and then scaled up by 3 (making them 48 by 48) but as you can see in the image attached to this post this sprite/tile in the upper left corner is stretched.

this does not happen if i don't load the sprite inside a custom type, but i don't understand why it makes a difference.

if any of you guys have a clue whats going on, please let me know.



- KristianXD1

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 15th Jul 2016 11:30
nothing attached. i'm afraid you'll need to include code too for anyone to be able to help
KristianXD1
7
Years of Service
User Offline
Joined: 15th Jul 2016
Location:
Posted: 15th Jul 2016 15:59
oh, yea i messed up.
i have attached the file to this post now .

also the code i'm using to store the image and load the sprite looks something like this(i know it's messy, i'm just testing out some things):



global pixelScaleX = 3
global pixelScaleY = 3

global tileGridSizeX = 16
global tileGridSizeY = 16

tileGridSizeX = tileGridSizeX * pixelScaleX
tileGridSizeY = tileGridSizeY * pixelScaleY

type tile
idName as string
name as string
texture as integer
endtype



global tiles as tile[]

function addTileToTileset(tileIdName as string,tileName as string,imagePath as string)
tiles.length = tiles.length + 1
tiles[tiles.length].idName = tileIdName
tiles[tiles.length].name = tileName
tiles[tiles.length].texture = LoadImage (imagePath)
endfunction

addTileToTileset('dirt','Dirt','tiles/dirt.png')

type tilesInMap
tileId as integer
sprite as integer
x as float
y as float
endType

type tilemap
tiles as tilesInMap[]
endtype

global tilemap as tilemap

function addTileToWorld(tileId,gridX,gridY)
tilemap.tiles.length = tilemap.tiles.length + 1
tilemap.tiles[tilemap.tiles.length].tileId = tileId
tilemap.tiles[tilemap.tiles.length].x = gridX * tileGridSizeX
tilemap.tiles[tilemap.tiles.length].y = gridY * tileGridSizeY
tilemap.tiles[tilemap.tiles.length].sprite = CreateSprite (tiles[tileId].texture)
SetSpriteSize(tilemap.tiles[tilemap.tiles.length].sprite,GetImageWidth(tiles[tileId].texture),GetImageHeight(tiles[tileId].texture))
SetSpriteScale(tilemap.tiles[tilemap.tiles.length].sprite,pixelScaleX,pixelScaleY)
SetSpritePhysicsOn (tilemap.tiles[tilemap.tiles.length].sprite,1)
SetSpritePhysicsCanRotate( tilemap.tiles[tilemap.tiles.length].sprite, 0 )
SetSpritePosition(tilemap.tiles[tilemap.tiles.length].sprite,tilemap.tiles[tilemap.tiles.length].x,tilemap.tiles[tilemap.tiles.length].y)

endfunction

//add tiles to tilemap
addTileToWorld(0,0,0)
addTileToWorld(0,1,1)
addTileToWorld(0,2,1)

Attachments

Login to view attachments
KristianXD1
7
Years of Service
User Offline
Joined: 15th Jul 2016
Location:
Posted: 15th Jul 2016 20:08
ehm... i don't think i understand how this forum works...
i tried reading the rules, but i can't find any section that states i need approval to make post's (other than if you are being watched by mods).
but despite that i can't see my own posts on this thread anymore? can someone please explain? i want to post my code but my posts don't show up here...
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 15th Jul 2016 20:21
New users start out on post approval, so each post needs to be approved before anyone can see it, including yourself.

It doesn't last for too long, hang in there!
The code is dark and full of errors
KristianXD1
7
Years of Service
User Offline
Joined: 15th Jul 2016
Location:
Posted: 18th Jul 2016 03:41
i don't know why this didn't work but i wrote the entire thing from scratch and now it works!

i guess i just messed up, i'm new to this language so it makes sense.

Login to post a reply

Server time is: 2024-04-25 22:06:23
Your offset time is: 2024-04-25 22:06:23