Jump to content

prospeed


jpam
 Share

Recommended Posts

It's me again :)

I just wanted to know how to

* make a screenshot to memory

* put a png over it

* and save it as compressed jpg

I tried it myself but your udf isn't very selfexplainary and the examples are huge :S

thanks, suppaman2

Link to comment
Share on other sites

  • Replies 511
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

#include <Prospeed.au3>

WinMinimizeAll()
Sleep(100)

GetDesktopHDC() ; first create desktophdc (for a window use "GetHDC()")

$bitmap = CreateExtBmp(800, 600) ; Create new empty bitmap
CopyExtBmp($bitmap, 0, 0, 800, 600, $hdc, 0, 0, 0) ; copy $hdc to empty bitmap (this case its your desktop)

$png = ImportPng(0,"bal.png") ; import your png picture

PaintPng(0, $bitmap , 100, 100, $png, 0) ; Paint your png picture to $bitamp  
                                       ;(100 pixels from left and 100 pixels from top)
                                       
SaveExtImage($bitmap, "C:\new.jpg", 1, 10) ; save your new jpg picture to harddisk

Link to comment
Share on other sites

I am totally lost. I just want to create a simple sprite! I wrote my beautiful clock and use it daily, but now I am trying to write a BubbleBreaker style game and I can't for the love of me produce a sprite drawing.

The reason I'm using a sprite drawing anyway is because I can only create 11 "images" while I need 100, after that there's just no image drawn. Is that right?

So I thought I'd use sprites. But it doesn't work at all! I am overlooking something hideously obvious, I'm sure. Can anyone enlighten me?

This reproducer includes prospeed.au3, opens user32.dll, makes a gui, loadSprites a 80x80 gif file called BubbleG.gif, and creates a sprite. But it is not shown! Gui appears, msgbox appears, but nothing else.

Ofcourse I downloaded the latest files from the website. And images seem to work fine except for the 11 images limit which I asked about.

I am lost...

#include <Prospeed.au3>

$user32dll = DllOpen("user32.dll")

Global $aBubbleFile = ""

$mainGui = GUICreate("TestGui", 800, 800)
GUISetState()

$aBubbleFile = LoadSprite(@ScriptDir & "\bubbleG.gif")
$pietje = Sprite($aBubbleFile, 0, 0, 80, 80, 1, 1, 0, 10, 10)
GUISetState()

MsgBox(0, 0, "done building gui")

Exit

(the gif file I use is attached just in case anything's wrong with that, but I guess not since it can be used as an Image)

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

#include <Prospeed.au3>

$user32dll = DllOpen("user32.dll")

Global $aBubbleFile = ""

$mainGui = GUICreate("TestGui", 800, 800)
GUISetState()

$hdc = GetHDC() ; <= allway's need hDC
CreateBuffer(800,800) ; <= Create buffer for sprite and WM_PAINT
SetBuffer($hdc) ; <= Fill the buffer with background pic or hDC

$aBubbleFile = LoadSprite(@ScriptDir & "\bubbleG.gif")
$pietje = Sprite($aBubbleFile, 0, 0, 80, 80, 1, 1, 0, 10, 10)
GUISetState()

MsgBox(0, 0, "done building gui")

Exit

Prospeed.dll is limited to 32 bitmaps in memory

if you use alot of images ,then make 1 big bitmap and put all the images in that big bitmap

and create the sprite images with the offsets in the big bitmap

you use then only 1 bitmap in memory for all the sprites pictures

Edited by jpam
Link to comment
Share on other sites

#include <Prospeed.au3>

$user32dll = DllOpen("user32.dll")

Global $aBubbleFile = ""

$mainGui = GUICreate("TestGui", 800, 800)
GUISetState()

$hdc = GetHDC() ; <= allway's need hDC
CreateBuffer(800,800) ; <= Create buffer for sprite and WM_PAINT
SetBuffer($hdc) ; <= Fill the buffer with background pic or hDC

$aBubbleFile = LoadSprite(@ScriptDir & "\bubbleG.gif")
$pietje = Sprite($aBubbleFile, 0, 0, 80, 80, 1, 1, 0, 10, 10)
GUISetState()

MsgBox(0, 0, "done building gui")

Exit

Prospeed.dll is limited to 32 bitmaps in memory

if you use alot of images ,then make 1 big bitmap and put all the images in that big bitmap

and create the sprite images with the offsets in the big bitmap

you use then only 1 bitmap in memory for all the sprites pictures

Thanks for your time! But I never used the HDC thing before, my analog alarm clock script runs beautifully without it... ? The code modified by you has the same result as my reproducer: a totally empty GUI with no sprite visible. What am I missing?

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

Thanks for your time! But I never used the HDC thing before, my analog alarm clock script runs beautifully without it... ? The code modified by you has the same result as my reproducer: a totally empty GUI with no sprite visible. What am I missing?

By the way, say I have 100 images in one big bitmap, as you say, and I want to do a smooth vertical flip effect on 15 of them lasting 0.5 second. Can I just manipulate 15 of the images within the big bitmap and make them smoothly flip, or do I need to re-create the full bitmap for all different bitmap frames of the flipping 15 images?

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

you dont have to use GethDC()

But you forgot to set the background picture with Background($S_FILE, $S_POSX, $S_POSY, $N_WIDTH, $N_HEIGHT)

this function creates the hDC and the buffers automatic

i did not change anything on the sprite functions in the udf

so it all should work as before !

for the second question;

you dont have to make a second big bitmap for flipping

it can all be done in memory

example;

$load = LoadExtImage("verybig.bmp") ;<= load the big bitmap

$ufo = CreateExtBmp(60,60) ;<= create bitmap for ufo sprite

CopyExtBmp($ufo,0,0,60,60,$load,245,145,0) ; copy from verybig.bmp the ufo.bmp at offset 245x145 to $ufo (empty bitmap)

$array1 = InitExtFX($ufo) ;<= create array from ufo

FlipY(0, 0, 0, $array1) ;<= do the flip Y (first para = 0 it is flipped in $array now)

CopyArray($ufo ,0, 0, $array1) ;<= copy array back to $ufo

now your loaded sprite picture has the flipped bitmap

when you create an array of a image, you can do all kind of effects on it

Link to comment
Share on other sites

Thanks for the background hint, I didn't know that was necessary for sprites... It just happened to be the first thing I created in my clock script so that worked kinda by accident :) Now my sprites get painted.

I'll try to work your example into a system that can contain at least 100 bubble images.

I have another question though, because I experimented some more. Why does loadspriteResize(@ScriptDir & "\bubbleB.jpg", 80, 80) result in a black square after the sprite() call, while loadsprite(@ScriptDir & "\bubbleB.jpg") results in a nice picture? The picture is a 80x80 jpg.

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

you can't use loadspriteResize() after loadsprite() :)

use loadspriteResize() to load sprite picture or loadsprite()

or manual resize your spritepicture with size()

Thanks for the background hint, I didn't know that was necessary for sprites... It just happened to be the first thing I created in my clock script so that worked kinda by accident :) Now my sprites get painted.

I'll try to work your example into a system that can contain at least 100 bubble images.

I have another question though, because I experimented some more. Why does loadspriteResize(@ScriptDir & "\bubbleB.jpg", 80, 80) result in a black square after the sprite() call, while loadsprite(@ScriptDir & "\bubbleB.jpg") results in a nice picture? The picture is a 80x80 jpg.

Edited by jpam
Link to comment
Share on other sites

Wow, this is so amazing! Reading through the UDF now and exploring all the possibilities!

I do need some pointers in the right direction though..

How do you for example rotate a sprite or add effects to them?

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

add effect to sprite example;

#include <Prospeed.au3>

Opt("MouseCoordMode",0)
Opt("GUIOnEventMode", 1)
HotKeySet("{Esc}","_exit")

$gui = GUICreate("Sprites",800, 400)
GUISetState()

Background("YourBackgroundImage.bmp", 0, 0,800,400)

$load   = loadsprite("Your SpriteImage.bmp")
$Sprite = sprite($load, 0, 0, 24, 18, 4, 1, 6, 200,40)
$array  = InitExtFX($load)

While 1 
    Movesprite($Sprite,Random(0,800-24,1),Random(0,400-18,1))
    ExchangeRgb(0,0,0,$array,50,0,0)
    CopyArray($Sprite,0,0,$array)
    Sleep(1000)
    ExchangeRgb(0,0,0,$array,-50,0,0)
    CopyArray($Sprite,0,0,$array)
    Sleep(1000)
WEnd

Func _exit()
    Exit
EndFunc
Link to comment
Share on other sites

Sprite Rotate example;

#include <Prospeed.au3>

Opt("MouseCoordMode",0)
Opt("GUIOnEventMode", 1)
HotKeySet("{Esc}","_exit")

$gui = GUICreate("Sprites",800, 400)
GUISetState()

Background("Your BackgroundImage", 0, 0,800,400)

$load = loadsprite("count.gif")
$W    = GetBmpHeight($load)

$tmp    = CreateExtBmp(244,244)
CopyExtBmp($tmp,0,(244-$W)/2,244,244,$load,0,0,-1)
$array1 = InitExtFX($tmp)

$bitmap = CreateExtBmp(244,244)
$array2 = InitExtFX($bitmap)

$spritepic = CreateExtBmp(244,244)
$Sprite = sprite($spritepic, 0, 0, 244, 244, 1, 1, 1, 200,40)
SetmovingRectangle($Sprite,0, 0, 800-244, 400-244)

While 1 
    movesprite($Sprite,Random(0,800,1),Random(0,400,1))
    For $i = 1 To 359
        Rotate($spritepic,0,0,$array2,$array1,$i,0)
        Sleep(20)
    Next
WEnd

Func _exit()
    FreeAllExtBmps()
    FreeExtFX($array1)
    FreeExtFX($array2)
    Exit
EndFunc

post-5777-1206283336_thumb.gif

Edited by jpam
Link to comment
Share on other sites

Sprite Rotate example;

#include <Prospeed.au3>

Opt("MouseCoordMode",0)
Opt("GUIOnEventMode", 1)
HotKeySet("{Esc}","_exit")

$gui = GUICreate("Sprites",800, 400)
GUISetState()

Background("Your BackgroundImage", 0, 0,800,400)

$load = loadsprite("count.gif")
$W    = GetBmpHeight($load)

$tmp    = CreateExtBmp(244,244)
CopyExtBmp($tmp,0,(244-$W)/2,244,244,$load,0,0,-1)
$array1 = InitExtFX($tmp)

$bitmap = CreateExtBmp(244,244)
$array2 = InitExtFX($bitmap)

$spritepic = CreateExtBmp(244,244)
$Sprite = sprite($spritepic, 0, 0, 244, 244, 1, 1, 1, 200,40)
SetmovingRectangle($Sprite,0, 0, 800-244, 400-244)

While 1 
    movesprite($Sprite,Random(0,800,1),Random(0,400,1))
    For $i = 1 To 359
        Rotate($spritepic,0,0,$array2,$array1,$i,0)
        Sleep(20)
    Next
WEnd

Func _exit()
    FreeAllExtBmps()
    FreeExtFX($array1)
    FreeExtFX($array2)
    Exit
EndFunc
Dude you are so fricken smart. I love Prospeed, but cant use it like you can.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...