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.

AppGameKit Classic Chat / can't see sprite

Author
Message
cryptojoe
11
Years of Service
User Offline
Joined: 27th Sep 2012
Location: Michigan U.S.A
Posted: 27th Sep 2012 19:54
hi, I've ben trying to do a tutorial from youtube and the project compiles but I can not see the sprite...

my screen width=640 by height=480 with fullscreen=0
the sprite is a png image 80x84

hears the source code

rem
rem AppGameKit Application
rem
rem MrSovr youtube
rem tutorial #1
rem MY Version...

rem Landscape App
SetDisplayAspect( 4.0/3.0 )

rem create and set sprite
loadimage(1,"posionshroom.png")
createsprite(1,1)
setspriteposition(1,320,240)

rem A Wizard Did It!
do
Print("hello world")
Sync()
loop

when I run this all I get is a black screen with Hellow World "please help"
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 27th Sep 2012 20:21 Edited at: 27th Sep 2012 20:23
When using the percentage system (setDisplayAspect) you need to position it within 0 and 100 (%) to keep it on screen.

Try setting the position like this:
SetSpritePositionByOffset(1,50,50)

It should put your sprite in the centre of the screen.

Edit: if you use setVirtualResolution(640,480) instead of display aspect you will get the same result as it is using a resolution size instead of percentage. It's probably simpler to understand.


this.mess = abs(sin(times#))
cryptojoe
11
Years of Service
User Offline
Joined: 27th Sep 2012
Location: Michigan U.S.A
Posted: 27th Sep 2012 20:47
thank you

both work but if I use: SetSpritePositionByOffset(1,50,50)
I get a very large sprite that fills most of the screen is
thare a way to resize the sprite with a simple command?
DennisW
15
Years of Service
User Offline
Joined: 15th Jun 2008
Location: Ohio
Posted: 27th Sep 2012 22:41
Try this

SetSpriteSize( iSpriteIndex, width, height )

Dennis

Ham and Eggs Breakfast
The Chicken was involved the Pig was Committed
cryptojoe
11
Years of Service
User Offline
Joined: 27th Sep 2012
Location: Michigan U.S.A
Posted: 28th Sep 2012 00:06
worked like a charm, thank you DennisW.

now I just need to learn how to add some background music...
I belive the audio file gos into the media folder, but I don't know how to call it yet...
DennisW
15
Years of Service
User Offline
Joined: 15th Jun 2008
Location: Ohio
Posted: 28th Sep 2012 01:52
Place your music.mp3 file in your media folder

MyMusic = LoadMusic( AnyMusic.mp3 )
PlayMusic( MyMusic, 1 or 0 ) rem 1 to have music loop 0 to play once.

You can find all of this in the help files.
Also Hands On AppGameKit is also good.
Have fun

Ham and Eggs Breakfast
The Chicken was involved the Pig was Committed
cryptojoe
11
Years of Service
User Offline
Joined: 27th Sep 2012
Location: Michigan U.S.A
Posted: 28th Sep 2012 02:01
thank you once agian... I've only had the software 2 days and yes I have be reading the help files... I plan on getting the book soon...

I realy do like how easy it is to make things with agk...
cryptojoe
11
Years of Service
User Offline
Joined: 27th Sep 2012
Location: Michigan U.S.A
Posted: 28th Sep 2012 19:58
just for the record this is what I came up with... if anyone can see something I'm doing wrong or could do better please feel free to say so...

rem
rem AppGameKit Application
rem
rem MrSovr youtube
rem tutorial #1
rem MY Version 2.0

rem Landscape App
SetDisplayAspect( 4.0/3.0 )
setVirtualResolution(640,480)

rem create and set sprite
loadimage(1,"posionshroom.png")
createsprite(1,1)
SetSpriteSize(1,42,40) // used to control sprite size
SetSpritePositionByOffset(1,50,50) // sets sprites X&Y to center

rem set sprite start position X&Y
x=320
y=240

rem A Wizard Did It!
do
Print("use the arrow keys to move the Shroom")
rem show statistics for X and Y
print("X position = " + str ( GetSpriteX(1)))
print("Y position = " + str ( getspritey(1)))
Sync()

rem get input and move sprite
if getdirectionx() > 0.5 then x = x +1
if getdirectionx() < -0.5 then x = x -1
if getdirectiony() > 0.5 then y = Y +1
if getdirectiony() < -0.5 then y = y -1
setspriteposition(1,x,y) // update sprite position
loop
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 28th Sep 2012 21:57
The SetSpritePosition function takes float values for x and y, so:


And instead of this:


Try this:


Cheers,
Ancient Lady
AGK Community Tester
cryptojoe
11
Years of Service
User Offline
Joined: 27th Sep 2012
Location: Michigan U.S.A
Posted: 28th Sep 2012 23:08
if I change x=320 to x#=320
y=420 to y#=420

my sprite starts in the upper left hand corner at
X position 0.000000
Y position 0.000000

haven't tryed your other code yet...
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 28th Sep 2012 23:51 Edited at: 28th Sep 2012 23:51
One thing I noticed, yes I know it's picky but I'm an artist, is that your skewing your image. When you set sprite size do this instead:



Edit: Ah, just realized in your recent code you un-skewed it manually. Something to remember, if you put '-1' in one place it'll automatically scale the sprite in that direction so the image holds it's aspect ratio without having to use guesswork.

cryptojoe
11
Years of Service
User Offline
Joined: 27th Sep 2012
Location: Michigan U.S.A
Posted: 29th Sep 2012 00:04
your try this code snippet will not compile as writen, but if the "else" are removed it will compile but dose this...

the sprite starts at x0.00 and y0.00 and will only move 2.00 or -2.00 for as long as the arrow key is pressed down and returns to 0.00 when the key is released...
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 29th Sep 2012 01:17
Quote: "haven't tryed your other code yet..."


My posted bits are meant to be used together with the change you did make.

They included using the floating point variation for setting the position. Since you didn't change that line, it assumed a value of zero for x and y.

Cheers,
Ancient Lady
AGK Community Tester
cryptojoe
11
Years of Service
User Offline
Joined: 27th Sep 2012
Location: Michigan U.S.A
Posted: 29th Sep 2012 07:55
I did use them together... the sprite is in the upper left hand corner "not near the middle like it was to start" and the sprite only moves about 2.00 or -2.00 and stops.

yes the position text counts up and down, "but the sprite dose not move" and when the arrow key is released the sprite returns to its starting position and the text returns to 0.000000

don't get me wrong, I'm not picking on your code and I do thank you for your time and help...
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 29th Sep 2012 20:33
Can you show me the whole code to see if I gave you a bad example?

Cheers,
Ancient Lady
AGK Community Tester
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 30th Sep 2012 04:18 Edited at: 30th Sep 2012 04:20
Quote: "Can you show me the whole code to see if I gave you a bad example?"

The problem might be that in this snippet:



that x# and y# get reset (to GetDirectionX/Y respectively) each time an arrow key is released and since you're positioning the sprite to x# and y#, ....well.

But AL had the right idea, try:

Note: I'm on a mac right now so haven't tested the code.

cryptojoe
11
Years of Service
User Offline
Joined: 27th Sep 2012
Location: Michigan U.S.A
Posted: 30th Sep 2012 05:05
with the Dir added code runs fine... I did have to drop the else from 2 lines, code looks like this...
[rem get input and move sprite
Dirx# = GetDirectionX()
Diry# = GetDirectionY()
if Dirx# > 0.5 then x# = x# + 1.0
if Dirx# < -0.5 then x# = x# - 1.0
if Diry# > 0.5 then y# = y# + 1.0
if Diry# < -0.5 then y# = y# - 1.0
setspriteposition(1,x#,y#) // update sprite position
Sync()]
cryptojoe
11
Years of Service
User Offline
Joined: 27th Sep 2012
Location: Michigan U.S.A
Posted: 30th Sep 2012 06:22
when I added the .0 to my x#=320 and y#=240 the sprite started near near the middle of the screen...

thank you Hodgey and Ancient Lady...
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 30th Sep 2012 06:33
Boy, did I post the wrong stuff!

My apologies crytojoe, Hodgey caught my error (the catching and comparison of the accelerometor x/y values).

This is what happens when you write quicky code. I'm usually much better than that.

Cheers,
Ancient Lady
AGK Community Tester

Login to post a reply

Server time is: 2024-05-04 09:42:38
Your offset time is: 2024-05-04 09:42:38